| Article Index |
|---|
| DNS resolution explained |
| Part 2 - Basic Dns Guide |
| All Pages |
The nsswitch.conf file is used for much more than just storing the configuration order of DNS resolution, but for this example this is the only aspect we are interested in.
Notice the lines:
#hosts: db files nisplus nis dns
hosts: files dns
The upper line is commented with the hash character '#' so it not actually active, but serves to remind of the available options.
This is known as commenting a line ( starting the line with a hash causes it to be skipped in the config and treated as a comment )
The lower line sets the DNS resolution order on this Linux system, specifying that it will look at files ( meaning the hosts file ) , and then dns in order to resolve a dns name request. Here is a practicle example of how this works in every day use
[sshtest@littlemac ~]$ ping black
PING black (192.168.1.10) 56(84) bytes of data.
--- black ping statistics ---
2 packets transmitted, 0 received, 100% packet loss, time 1009ms
[sshtest@littlemac ~]$ ping black.com
PING black.com (208.122.60.250) 56(84) bytes of data.
64 bytes from server3.fkmod.com (208.122.60.250): icmp_seq=1 ttl=52 time=87.5 ms
In this example ( and using the above example files ) , the first ping command shows that the host black is resolved by looking at the local /etc/hosts file. It also just so happens that the server black is down, and not responding, so I am 100% assured by the result.
The second part demonstrates that while the host black was featured in the /etc/hosts file, black.com is not present in the hosts file, so the resolution came from dns as configured in the /etc/nsswitch.conf file.
There is a further twist in the story of the basic config files, as we look at the role of the /etc/resolv.conf file





