1

How shall I understand the format of /etc/resolv.conf?

$ cat /etc/resolv.conf
# This file is managed by man:systemd-resolved(8). Do not edit.
#
# This is a dynamic resolv.conf file for connecting local clients to the
# internal DNS stub resolver of systemd-resolved. This file lists all
# configured search domains.
#
# Run "systemd-resolve --status" to see details about the uplink DNS servers
# currently in use.
#
# Third party programs must not access this file directly, but only through the
# symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way,
# replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.

nameserver 127.0.0.53
search fios-router.home

Manpage of /etc/resolve.conf says

The different configuration options are:

   nameserver Name server IP address

          Internet address of a name server that the resolver should
          query...

So does nameserver 127.0.0.53 mean that my local machine is running a DNS server whose IP address is 127.0.0.53? How can I find out its process?

   domain Local domain name.

          Most queries for names within this domain can use short names
          relative to the local domain.  If set to '.', the root domain
          is considered.  If no domain entry is present, the domain is
          determined from the local hostname returned by gethostname(2);
          the domain part is taken to be everything after the first '.'.
          Finally, if the hostname does not contain a domain part, the
          root domain is assumed.

What does this part mean? The above just mentions what values that can be set to something, and does not explain what this part in /etc/resolv.conf means. Why does my /etc/resolv.conf not have this part?

   search Search list for host-name lookup.

          The search list is normally determined from the local domain
          name; by default, it contains only the local domain name.

What does this part mean? What does search fios-router.home in my /etc/resolv.conf mean?

Thanks.

  • You can run netstat -up as root to see if and who is listening on port 53 of :: or 0.0.0.0 or 127.0.0.53. – eckes Feb 11 at 21:22
  • freedesktop.org/software/systemd/man/… you might be in a systemd-resolved manging mode – 炸鱼薯条德里克 Feb 12 at 0:33
  • 1
    Just note that the netmask for localhost is 255.0.0.0, a /8. So 127.0.0.53 is also localhost. – Lenne Feb 12 at 0:49
  • 1
    @eckes netstat -up shows nothing is listening – Tim Feb 12 at 3:08
  • @Tim then there is most likely nothing listening (however as other answers mentioned this specific ip is documented as a marker for an internal mechanism which bypasses DNS) – eckes Feb 13 at 11:32
4

/etc/resolve.conf is the main configuration file for the DNS client, so its presence does not imply that you are running a DNS server.

Its primary purpose is to list the IP addresses of DNS servers, in your case:

nameserver 127.0.0.53

  • Entries of type nameserver tell the host, which DNS server to use.
  • An entry of type domain (if present) tells the system which domain it is in. This allows to be addressed by its host name. (Addition in response to a comment: The hostname is the computer's name in the network. On many systems, you can see the hostname in the command prompt; if not, you can find it by using the command hostname.)
  • An entry of type search (if present) would allow computers from different domains to address each other by their respective host names.

The file is nowadays usually generated by NeteworkManager (for example, on my system, the file starts with the comment "Generated by NetworkManager") or by systemd-resolved.

systemd-resolved

is a system service that provides network name resolution to local applications. It implements a caching and validating DNS/DNSSEC stub resolver, as well as an LLMNR and MulticastDNS resolver and responder.

Also according to systemd-resolved's manpage, the address 127.0.0.53 is a "local DNS stub listener". On related Stack Exchange sites, there have been questions about how to change this, since the file is /etc/resolv.conf is automatically generated. See for example

  • 1
    Thanks. (1) "Entries of type nameserver tell the host, which DNS server to use." 127.0.0.53 is an IP of local machine. How is that not contradictory to "its presence does not imply that you are running a DNS server"? (2) "An entry of type domain (if present) tells the system which domain it is in. This allows to be addressed by its host name." What is the difference and relation between a domain (name) and a host name? – Tim Feb 11 at 18:11
  • 1) it is only visible to your local system, not to any other systems; not even within your home network. So it does not serve any others. 2) A hostname might be short (host1) or fully-qualified (host1.fios-router.home). In this example, the domain of host1.fios-router.home would be fios-router.home. – telcoM Feb 11 at 18:38
  • So ls -al /etc/resolv.conf and cat /etc/resolv.conf will inform you which program/service is controlling resolv.conf. If you've messed about with your system then you might have a couple of programs competing for control - I had this before with dnsmasq, bind, and systemd-resolved. In addition @Tim, to what telcoM says about your questions: the DNS server and resolver ("stub resolver") can be different, you can pass DNS requests to 127.0.0.53 which pass them to your router for actual DNS (eg it could handle local hosts but pass requests for remote hosts on for full DNS). – pbhj Feb 11 at 20:36
  • 1
    @pbhj "you can pass DNS requests to 127.0.0.53 which pass them to your router for actual DNS." 127.0.0.53 refers to the local machine itself, so why does it pass DNS request to your router ? – Tim Feb 12 at 2:41
3

Yes, the first part indicates that your system is expecting a nameserver to be listening on localhost, in this case, specifically 127.0.0.53.

The second part is a search path that is appended to all searches not ending in a period (.). If you run, for instance, ssh blah, DNS will first try to look up blah, then try looking up blah.fios-router.home.

  • Thanks. I never know the local machine is running a DNS server. Can you tell me how to find out its process? – Tim Feb 11 at 18:01
  • Try pgrep systemd-resolved or systemctl status systemd-resolved. – telcoM Feb 11 at 18:39
  • @telcoM pgrep systemd-resolved returns nothing. Does nameserver 127.0.0.53 really mean the my local machine is running a DNS server? – Tim Feb 12 at 2:43
  • It means your system is expecting to have something in that address that can receive and resolve DNS requests just like a (resolver-type) DNS server. But expecting something is not the same as actually having it. And when I just tested, it looks like the way systemd starts systemd-resolved can fool pgrep. Try just pgrep resolv. – telcoM Feb 12 at 7:40
2

The search fios-router.home part is the last resolvable domain, i.e. your router (iirc Verizon).

127.0.0.53 is the IP address of the nameserver, so your assumption is correct.

  • Thanks. (1) What is "a resolvable domain" and what is "the last resolvable domain"? (2) Do you mean my local machine is running a DNS server? Which process is the DNS server? – Tim Feb 11 at 17:54
1

resolv.conf is part of the standard way to resolve a host name to an IP address. It is part of the resolver library.

There are different ways to resolve your host name:

  • files (specifically: /etc/hosts)
  • dns
  • NIS, NIS+ or yp

The sequence in which they are used is in /etc/nsswitch.conf. This normally says

hosts:      files dns

which means that the resolver library first looks in /etc/hosts and, if it cannot find it there, will use DNS.

Now DNS will query a DNS server. Which one is determined by /etc/resolv.conf. In addition, there are a number of additional parameters that you can use to help the DNS reolution, of which search (Try this domain first for the host) is probably the most used.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.