Add / Change dns – CentOS

The easiest to add or edit the dns servers your server uses is to edit the file at /etc/resolv.conf and then add dns entries in the following manner

nameserver 208.67.222.222
nameserver 8.8.8.8
nameserver 208.67.220.220
nameserver 8.8.4.4

So I’ve gone and set one each of Google’s DNS servers and OpenDNS servers and then their secondary IP’s.

Restart network and you’re golden.

service network restart //this command also works on CentOS 7