This website is dedicated to information about the /etc/resolv.conf
file, and other networking utilities that are a part of unix.
By it’s own description:
NAME
resolv.conf - resolver configuration file
SYNOPSIS
/etc/resolv.conf
DESCRIPTION
The resolver is a set of routines in the C library that provide access to the Internet Domain Name System(DNS).
The resolver configuration file contains information that is read by the resolver routines the first time they are invoked by a process.
The file is designed to be human readable and contains a list of keywords with values that provide various types of resolver information.
The configuration file is considered a trusted source of DNS information (e.g., DNSSEC AD-bit information will be returned unmodified from this source).
If this file does not exist, only the name server on the local machine will be queried; the domain name is determined from the hostname and the domain search path is constructed from the domain name.
The resolv.conf
file will contain a few different types of entries:
Type | Description | Example |
nameserver | An internet address of a nameserver the resolver should query | nameserver 10.0.0.1 |
domain | A local domain name | |
search | Search list for host-name lookup | |
sortlist | Sorts addresses returned by gethostbyname(3) | |
options | Modifies certain internal resolver variables |
Lines that start with ;
or #
are treated as comments.
This directive points to the IP address of a nameserver.
Examples:
nameserver 10.0.0.1
nameserver 8.8.8.8
Defines the local domain. This can assist you in resolving shortened domain names.
For example, having the entry domain resolv.to
would mean that when you try to resolve blog
, it will query for blog.resolv.to
:
❯ host -V
host 9.11.3-1ubuntu1.13-Ubuntu
❯ host blog
❯ cat /etc/resolv.conf | grep domain
❯ sudo vim /etc/resolv.conf
❯ cat /etc/resolv.conf | grep domain
domain resolv.to
❯ host blog
blog.resolv.to has address 127.0.0.1
❯ host blog.sdfsdfh
Host blog.sdfsdfh not found: 3(NXDOMAIN)
❯
Once the domain is added to the conf file, the domain will be used for requests that don’t have a domain.
This defines a search list used for host-name lookup.
/etc/resolv.conf
filesWSL2:
❯ uname -sro
Linux 4.4.0-19041-Microsoft GNU/Linux
❯ cat /etc/resolv.conf
# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
# [network]
# generateResolvConf = false
nameserver 10.35.53.1
nameserver 10.35.53.2
nameserver 10.0.0.1
❯
❯ host
Usage: host [-aCdilrTvVw] [-c class] [-N ndots] [-t type] [-W time]
[-R number] [-m flag] hostname [server]
-a is equivalent to -v -t ANY
-c specifies query class for non-IN data
-C compares SOA records on authoritative nameservers
-d is equivalent to -v
-i IP6.INT reverse lookups
-l lists all hosts in a domain, using AXFR
-m set memory debugging flag (trace|record|usage)
-N changes the number of dots allowed before root lookup is done
-r disables recursive processing
-R specifies number of retries for UDP packets
-s a SERVFAIL response should stop query
-t specifies the query type
-T enables TCP/IP mode
-v enables verbose output
-V print version number and exit
-w specifies to wait forever for a reply
-W specifies how long to wait for a reply
-4 use IPv4 query transport only
-6 use IPv6 query transport only