DNS Resolution

DNS Resolution

README

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
nameserver 8.8.8.8
nameserver 8.8.4.4

# OpenDNS Resolver2
nameserver 208.67.220.220
nameserver 208.67.222.222

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         192.168.0.1     0.0.0.0         UG    100    0        0 eth0
192.168.0.0     *               255.255.255.0   U     0      0        0 eth0
$ nslookup www.cixtor.com
Server:  8.8.8.8
Address: 8.8.8.8#53

Non-authoritative answer:
www.cixtor.com canonical name = cixtor.com.
Name: cixtor.com
Address: 199.188.200.231
$ 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

;; QUESTION SECTION:
;www.cixtor.com.   IN A

;; ANSWER SECTION:
www.cixtor.com.  1169 IN CNAME cixtor.com.
cixtor.com.  1169 IN A 199.188.200.231

;; Query time: 83 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; 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 8.8.8.8, 8.8.4.4;

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 255.255.255.255 port 67 interval 4
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 6
DHCPOFFER of 192.168.0.21 from 192.168.0.1
DHCPREQUEST of 192.168.0.21 on eth0 to 255.255.255.255 port 67
DHCPACK of 192.168.0.21 from 192.168.0.1
bound to 192.168.0.21 -- renewal in 1734 seconds.

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