Software >> OS >> Unix >> Linux >> How to configure default gateway and DNS servers for static IP

e.g. for interface eth0

vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
IPADDR=x.x.x.x
NETMASK=x.x.x.x
GATEWAY=x.x.x.x
DNS1=x.x.x.x
DNS2=x.x.x.x

... if the gateway is the default gateway, also add following line
DEFROUTE=yes

restart networking

# /etc/rc.d/init.d/network stop

# /etc/rc.d/init.d/network start

you will notice that the file /etc/resolv.conf will then have the entry

nameserver x.x.x.x