linux_wiki:static_ip

This is an old revision of the document!


Static IP

General Information

Configure static IP, Mask, Gateway, and DNS.

Checklist

  • Distros: Debian or Redhat based.

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

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=no
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
  • linux_wiki/static_ip.1455245516.txt.gz
  • Last modified: 2019/05/25 23:50
  • (external edit)