How to configure the /etc/resolv.conf file in Linux

Home > Search > How-to

The /etc/resolv.conf file contains the nameservers that the system can use. In this example, the /etc/resolv.conf file contains two nameservers.

[root@server1 ~]# cat /etc/resolv.conf

If the system is configured with one or more nameservers in the /etc/sysconfig/network-scripts/ifcfg-xxxxxxxxx file (Red Hat) or the /etc/network/interface file (Debian), and these files have PEERDNS=yes or IPV6_PEERDNS=yes, the /etc/resolv.conf file will use the nameservers listed in the files. If the system is configured to use DHCP to obtain nameservers, the /etc/resolv.conf file will use the nameservers provided by the DHCP server.

The /etc/resolv.conf file is not manually edited. If the network interface is brought down and then up, or if networking is restarted, or if the operating system is restarted, the /etc/resolv.conf file will be automatically updated.



The resolvconf service is responsible for updating the /etc/resolv.conf file. The resolvconf file is located at /sbin/resolvconf. The resolvconf service is used when the network interface is brought up, or when the dhclient command is used.



When dhclient leases IP confirmation information from a DHCP server, the information will be written to the dhclient.leases or dhclient6.leases files. These files are located in the /var/lib/dhclient or /var/lib/dhcp directory. These files can be viewed to ensure the IP address of the nameservers was successfully leased from the DHCP server.

[john.doe@client1 ~]# cat /var/lib/dhcp/
lease {
  interface "eth0";
  option domain-name-servers;


Add a Comment

We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.

Please enter in the box below so that we can be sure you are a human.