0

I have installed a local DNS server (coredns) onto my machine and activate it by setting

name_servers=127.0.0.1

within resolvconf.conf. Now I switch networks and want to have the DHCP provided resolv settings (at the least the nameservers) in a different file where I can forward the requests to by also adding external DNS servers.

How can I tell resolvconf.conf to set nameserver 127.0.0.1 in /etc/resolv.conf but write the dhcp provided data to something like /run/resolv/dhcp?

I am running Manjaro

1

I'm assuming Debian or a related distribution; other distributions may set up resolvconf differently.

You'll need to make this command happen when your coredns server starts:

echo nameserver 127.0.0.1 | /sbin/resolvconf -a lo.coredns

And this when it stops:

/sbin/resolvconf -d lo.coredns

resolvconf will automatically set 127.0.0.1 as the preferred server in /etc/resolv.conf and won't add any others until it receives the information that the coredns daemon has been stopped (through the second command above).

You might then write your own add-on script to /etc/resolvconf/update.d/ to write the DHCP-provided information to some other configuration file (e.g. a configuration file for coredns). In Debian 9, this is exactly how BIND and resolvconf integrate with each other.

Alternatively, you might use the files in /run/resolvconf/interface/ directory to get the DHCP-provided DNS server information.

  • It is ArchBased (Manjaro), will update the question – Sascha May 22 at 15:42
0

Writing the DHCP data is a function of the DHCP Client you're using. Typically that's dhclient. You'll want to checkout dhclient-script. See

  • man dhclient-script
  • man dhclient.conf

And check out and edit,

  • /sbin/dhclient-script (this is what writes the resolv.conf stuff)
  • The problem with dhclient-script is that it only knows about one source of DNS information at a time. If you have multiple network interfaces, VPN tunnels or some other non-trivial set-up, relying on just dhclient-script or similar will require you to keep track of the order in which you start up your network connections, and shut them down in the exactly reverse order. This is awkward, and so resolvconf was developed as an intermediate layer between the producers and the consumers of DNS resolver information. It allows you to start and stop multiple NICs/VPNs/etc in any order you want. – telcoM May 22 at 15:29
  • @telcoM This is what bothers me a bit (due to having sometimes two nics online). Therefor I search for the right place to redirect the standard configuration to a separate file to read out using coredns – Sascha May 22 at 15:37
  • @Sascha: exactly, see my answer. My comment above was intended mainly for @EvanCarroll, as it looks like he might not have realized how using just dhclient-script or similar can be less than ideal with multiple network connections. – telcoM May 22 at 15:44

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.