DNS Resolution

DNS Resolution


Many times when I make changes to access restrictions in my website, or when I create new domains in my host I become frustrated when I find that my computer can not recognize the DNS IP addresses of those, someone might think: Hey, why not purge DNS cache of your computer, something very easy in Linux simply running this command: /etc/init.d/dns-clean force-reload

Unfortunately for me, and maybe for some of you, this utility related with the Bind9 UNIX package does not work 100% of the time mainly because the work of resolve domain names is thing of the ISP that provide internet to your computer.

I decided to start using the Google nameservers, and yes they work very well; Wow, just had to add these lines in the domain name resolution file located generally in UNIX systems in this path: /etc/resolv.conf

$ cat /etc/resolv.conf
# Google's nameservers

# OpenDNS Resolver2

We can check the change executing a ping -c 5 www.example.com or just with one of these commands:

$ route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         UG    100    0        0 eth0     *        U     0      0        0 eth0
$ nslookup www.cixtor.com

Non-authoritative answer:
www.cixtor.com canonical name = cixtor.com.
Name: cixtor.com
$ dig www.cixtor.com

; <<>>>> DiG 9.7.0-P1 <<>>>> www.cixtor.com
;; global options: +cmd
;; Got answer:
;; ->>>>HEADER<<- opcode: QUERY, status: NOERROR, id: 54707
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 0

;www.cixtor.com.   IN A

www.cixtor.com.  1169 IN CNAME cixtor.com.
cixtor.com.  1169 IN A

;; Query time: 83 msec
;; WHEN: Mon Sep 17 09:07:30 2012
;; MSG SIZE  rcvd: 62

Sometimes after a reboot you’ll get a reset in the configuration of the resolv.conf file, one more time I’m getting frustrated; so if you have the same problem (losing the Resolv.conf settings after reboot) just add lines like these in the DHCP client configuration file located in /etc/dhcp3/dhclient.conf

# @filepath: /etc/dhcp3/dhclient.conf
supersede domain-name "example.domain.com";
prepend domain-search "example.domain.com";
prepend domain-name-servers,;

After that, execute the command dhclient as super user, and check the configurations with cat /etc/resolv.conf:

$ dhclient
Internet Systems Consortium DHCP Client V3.1.3
Copyright 2004-2009 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/wlan0/c0:18:85:16:85:34
Sending on   LPF/wlan0/c0:18:85:16:85:34
Listening on LPF/eth0/dc:0e:a1:58:18:5b
Sending on   LPF/eth0/dc:0e:a1:58:18:5b
Sending on   Socket/fallback
DHCPDISCOVER on wlan0 to port 67 interval 4
DHCPDISCOVER on eth0 to port 67 interval 6
DHCPREQUEST of on eth0 to port 67
DHCPACK of from
bound to -- renewal in 1734 seconds.

$ cat /etc/resolv.conf
Do you have a project idea? Let's make it together!