This is an old revision of the document!
Table of Contents
Add DNS Server
Normally we just add the IP Address, Subnet Mask and Gateway to the ifcfg-eth0 file, as that is all we need. But if it is required that we need to update the OS, or add a piece of software (htop for example) then we may need to add the DNS settings.
There are two ways this can be done.
Method 1
Use “PEERDNS=no”. This option will prevent /etc/resolv.conf from being modified by a DHCP server. So instead of using DHCP-provided DNS, you can specify any arbitrary DNS servers you want to use in /etc/resolv.conf.
The configuration file for your network interface (e.g., eth0) looks like the following.
sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes
PEERDNS=no
Then, add static DNS to /etc/resolv.conf
sudo vi /etc/resolv.conf
nameserver 8.8.8.8
nameserver 8.8.4.4