6

The Description of resolveconf in it's manual page tells us: "The resolvconf package comprises a simple database for run-time nameserver information ...".

What is clear in the manual page is how to add or remove information to that database.

But, How to query it?.

terdon
  • 234,489
  • 66
  • 447
  • 667
jgomo3
  • 161
  • 1
  • 5

1 Answers1

5
ls /etc/resolvconf/run/interface

will list all the pieces of nameserver information that have been added to resolvconf database. Their names will usually identify the interface to which they're associated, and possibly other things.

These are all text files, effectively fragments of /etc/resolv.conf. So you can view them with any text viewer utility.

For example, on my home gateway system (Debian 9):

# ls /etc/resolvconf/run/interface/
eth2.dhclient  eth2.ip6.dhclient  lo.inet  lo.named

(If your Linux distribution is new enough to have the /run tmpfs filesystem, the directory will most likely be /run/resolvconf/interface instead.)

eth2 is my external interface that gets its configuration via DHCP. The default domain and IPv4 DNS servers provided by my ISP's DHCP server are in file eth2.dhclient. The file eth2.ip6.dhclient has the same information for IPv6. lo.inet contains the domain search line I've set locally, and it overrides the default domain set by the ISP. And since I run a local BIND for my private home DNS domain, once BIND has started up, Debian's systemd configuration for it will optionally add a nameserver 127.0.0.1 line as lo.named.

Since /etc/resolvconf/interface-order file says that lo takes priority over anything else, the search line from lo.inet will always go to the real /etc/resolv.conf. If my BIND is running, it will be used as a local nameserver; but if it fails for some reason and systemd is unable to restart it, the dependencies in systemd configuration will cause the lo.named to be removed, and then nameserver 127.0.0.1 in /etc/resolv.conf will be automatically replaced by ISP's nameservers.

telcoM
  • 87,318
  • 3
  • 112
  • 232
  • 1
    I am running Ubuntu 18.04, and the `/etc/resolvconf/run/interface` directory does not exist. I did manage to find it under `/run/resolvconf/interface` – Ben Mares Mar 23 '20 at 17:04
  • @BenMares Yes, newer Linux distributions with the `/run` tmpfs filesystem generally place the `interface` directory in there like that. – telcoM Mar 23 '20 at 20:46
  • I'm running Ubuntu 20.04 and neither /run/resolvconf... or /etc/resolvconf/... exists. – jgomo3 Mar 11 '23 at 20:32
  • 1
    @jgomo3 Ubuntu 20.04 might be using `systemd-resolved`, which has integrated support for per-interface DNS settings, so it would not need the `resolvconf` package any longer. Try `resolvectl status`: if it shows you DNS settings, you are using `systemd-resolved`. – telcoM Mar 11 '23 at 21:19
  • Beautiful. You are correct. resolvectl shows that information. Thank you – jgomo3 Mar 11 '23 at 21:43