There are a few ways to change your DNS Servers and this is specifically created with CentOS but can basically be applied to any Linux distro as they all use the /etc/resolv.conf file. To configure your DNS manually you will need to modify the /etc/resolv.conf file, if you are using DHCP this will reset when you reboot the system so you will need to do one of the below methods.

Option 1: Edit your /etc/resolv.conf (Static IP)

You will replace the DNS in the /etc/resolv.conf file. After replacing the IP your resolve.conf file should look similar to the one below.

[root@hostname]# cat /etc/resolv.conf

search dynamichosting.biz

nameserver 123.123.123.1

nameserver 123.123.123.2

Note: You do not need to restart the network as the changes are instant.

If you are using CentOS you can also change this from a text-gui while ssh’d into the server by typing system-config-network as root.

You will enter “Edit DNS configuration”

You will see something similar to the above photo.

These are the correct DNS Servers you should have now and you should be able to hit the tab button down to the OK button.

tab down to save and quit and that is it.

Option 2: Configure dhclient.conf

The /etc/dhclient.conf or /etc/dhcp/dhclient.conf file contains configuration information for dhclient. You can turn on or off DNS update and other options for specific interfaces or all interfaces using this file. You should add this to the file to prevent DHCP from resetting the DNS after reboot:

option domain-name-servers 123.123.123.1, 123.123.123.2