This is an old revision of the document!
Static IP
Distro(s): Debian and Redhat based.
Description: Configure static IP, Mask, Gateway, and DNS.
Assuming eth0 is the network interface to edit;
Debian/Ubuntu Systems if possible, bring interface down first: ifdown eth0.
1) Edit /etc/network/interfaces
nano /etc/network/interfaces
2) DHCP Setup Example (Default)
auto eth0 iface eth0 inet dhcp
3) Static Setup Example
auto eth0 iface eth0 inet static address 192.168.0.100 netmask 255.255.255.0 gateway 192.168.0.254 dns-nameservers 8.8.8.8 8.8.4.4
4) Bring the interface up (if brought down at the start)
ifup eth0
5) Otherwise, restart to fix nameserver conflicts between dhclient and static.
shutdown -r now
Redhat/CentOS Systems
1) Edit /etc/sysconfig/network-scripts/ifcfg-eth0
vi /etc/sysconfig/network-scripts/ifcfg-eth0
2) DHCP Setup Example (Default)
DEVICE=eth0 ONBOOT=no (change to yes to have DHCP start automatically) NM_CONTROLLED=yes BOOTPROTO=dhcp
3) Static Setup Example
DEVICE=eth0 ONBOOT=yes NM_CONTROLLED=yes BOOTPROTO=static IPADDR=192.168.0.101 NETMASK=255.255.255.0 GATEWAY=192.168.0.254
4) Edit /etc/resolv.conf
vi /etc/resolv.conf nameserver 8.8.8.8 nameserver 8.8.4.4
5) Restart network service
/etc/init.d/network restart