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.conf: 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.

Comments

Popular posts from this blog

AWS CLI Script to list all the EC2 Servers in all AWS Accounts in all Regions

Linux : Special permissions to users for file & directories using "setfacl"

Linux : Port Numbers for common services