
interfaces
# The loopback network interface auto lo iface lo inet loopbackLet's assume your network interface is eth0. To assign it a static IP address, add the following lines to /etc/network/interfaces:
auto eth0 iface eth0 inet static address 192.168.0.41 netmask 255.255.255.0 broadcast 192.168.0.255 gateway 192.168.0.1You should of course replace the values for address, netmask, gateway, and broadcast with values specific to your desired IP address and network. Additional static IP's can be added by repeating the above code in the interfaces file. Just increment the interfaces using "eth0:1", "eth0:2", etc, for each IP address. Example:
# The loopback network interface auto lo iface lo inet loopback auto eth0 iface eth0 inet static address 192.168.0.41 netmask 255.255.255.0 broadcast 192.168.0.255 gateway 192.168.0.1 auto eth0:1 iface eth0:1 inet static address 192.168.0.56 netmask 255.255.255.0 broadcast 192.168.0.255 gateway 192.168.0.1 auto eth0:2 iface eth0:2 inet static address 192.168.0.89 netmask 255.255.255.0 broadcast 192.168.0.255 gateway 192.168.0.1If you're not using DHCP at all, you may need to add/edit your DNS servers. Open up /etc/resolv.conf and make sure the IP's of your DNS servers are in there. For example:
nameserver 192.168.0.1 nameserver 192.168.0.2Finally, restart the network interfaces.
/etc/init.d/networking restartIf you're SSH'd into the box, don't log out yet. Log into the box with a new SSH session to verify the network interface came back up. Once verified, try pinging the new IP from a different box.
# ping 192.168.0.41 PING 192.168.0.41 (192.168.0.41) 56(84) bytes of data. 64 bytes from 192.168.0.41: icmp_seq=1 ttl=64 time=0.051 ms 64 bytes from 192.168.0.41: icmp_seq=2 ttl=64 time=0.061 ms 64 bytes from 192.168.0.41: icmp_seq=3 ttl=64 time=0.068 msOptional: remove dhcp clientIt may be necessary to remove the dhcp client in order to keep your IP address static. It seems that by default, dhcp3-client is setup to automatically renew it's lease 1 per day. You can remove dhcp3-client like this:
apt-get remove dhcp3-client
Leave a Comment