The /etc/resolv.conf file is a configuration file used by the Linux operating system to store information about Domain Name System (DNS) servers.
This file contains a list of DNS server addresses, as well as other options that control how DNS resolution works on your system.
In this blog post, we will discuss the contents of this file, and explain how to configure it to meet your needs.
Table of Contents
/etc/resolv.conf file in Linux
The /etc/resolv.conf file is a text file, and each line in the file represents a different DNS server.
The order of the lines in this file determines the order in which DNS servers are queried when resolving hostnames.
For example, if you have two DNS servers listed in your /etc/resolv.conf file, the first server will be queried first, and if it is unable to resolve the hostname, the second server will be queried.
In addition to listing DNS servers, you can also use the /etc/resolv.conf file to configure other aspects of DNS resolution on your system.
For example, you can use this file to specify which DNS server should be used for resolving certain types of queries, or to configure how long the system should wait for a response from a DNS server before timing out.
Example of /etc/resolv.conf file in Linux
The typical /etc/resolv.conf file on a Linux system will look like this:
The first two lines in this file are the nameserver addresses for the Google Public DNS service.
If you want to use these servers, you can leave these lines in your file, but if you want to use a different DNS service, you can remove these lines and replace them with the addresses of your desired DNS servers.
The third line in this file is the “search” line, which tells the system which domain should be used when resolving hostnames that are not fully qualified (e.g., if you try to ping “host” without specifying a domain, the system will automatically search for “host.example.com”).
You can remove this line from your file if you do not want the system to perform this kind of searching.
How to change /etc/resolv.conf file in Linux?
If you need to change the contents of your /etc/resolv.conf file, you can do so by editing the file with a text editor such as nano or vi.
Be sure to back up your /etc/resolv.conf file before making any changes, as a mistake in this file can cause serious problems with DNS resolution on your system.
Once you have made your changes, be sure to save the file and restart any applications that may be using it, such as your web browser or email client.
Config timeout in /etc/resolv.conf file
In the /etc/resolv.conf file, you can configure how long the system should wait for a response from a DNS server before timing out.
To do this, add a “timeout” line to your file, with the desired timeout value in seconds.
For example, if you want the system to wait for two minutes before timing out, you would add the following line to your file:
Be sure to save the file and restart any applications that may be using it after making any changes.
By understanding the contents of the /etc/resolv.conf file, and how to edit it, you can easily control how DNS works on your Linux system.
With a few simple changes, you can configure your system to use different DNS servers, or to change the way that it handles DNS queries.
Please feel free to leave any questions or comments below.