CentOS: Use OpenDNS To Resolve Hostnames

How do I use OpenDNS server for my CentOS Linux vps or dedicated server to resolve hostnames?

You need to edit the /etc/resolv.conf file which is resolver configuration file for CentOS Linux server. The syntax is as follows:

nameserver {Name server IP address}

How To Use OpenDNS For Centos Server

You need to set name server that the resolver should query and up to 3 name servers may be listed in /etc/resolv.conf file. Edit /etc/resolv.conf, run:
vi /etc/resolv.conf
Append / modify the file as follows:

nameserver 208.67.222.222
nameserver 208.67.220.220

Save and close the file.

Test It

Type the following command:
dig google.com
Sample outputs:

; <<>> DiG 9.6.1-P1 <<>> google.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 51272
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;google.com.			IN	A

;; ANSWER SECTION:
google.com.		65	IN	A	74.125.67.100
google.com.		65	IN	A	74.125.53.100
google.com.		65	IN	A	74.125.45.100

;; Query time: 202 msec
;; SERVER: 208.67.222.222#53(208.67.222.222)
;; WHEN: Sun Nov 22 18:27:01 2009
;; MSG SIZE  rcvd: 76

Previous post:

Next post: