Posts

Showing posts from July, 2022

Linux : Difference between /etc/hosts and /etc/resolv.conf

There are basic files to check for when we get any network related issues, Permissions of these files are very important, even if all the entries are correct, hostnames will not resolve and gives an error no host name found. Read permission is a must to resolve network issues if everything else is correct.   /etc/resolv.conf : Lists nameservers that are used by your host for DNS resolution. If you are using  DHCP , this file is automatically populated with DNS records issued by  DHCP  server. /etc/hosts/ : It is just a static lookup method for resolution. /etc/nsswitch.con f: It defined the order of resolution. Who should it consult first for resolution, a DNS or a host file? For example, if the file has the following configuration  hosts: files dns  then  /etc/hosts  the file will be checked first for resolution, if the domain is still un-resolvable, DNS will then be consulted.