1

I am wondering if I actually need dnsmasq or Bind to apply the following simple DNS server rule:

Forward DNS lookups for *.mydomain.com to 10.0.0.2;

Forward DNS lookups for anything else to 8.8.8.8 or 8.8.4.4

Or can I do that in a /etc/netplan/*.yaml file using the nameserver field somehow?

1

It is possible to configure systemd-resolved to do this, but not through netplan. E.g. systemd-resolve -i ens2 --set-dns=10.0.0.2 --set-domain=~mydomain.com

You should also be able to configure this statically with a .network file; see systemd.network(5) for information.

| improve this answer | |
  • I tried creating a foo.network file in /etc/systemd/network and populating it simply with [Network]\nDNS=10.0.0.2\nDomains=mydomain.com but it didn't work. – JSStuball Feb 8 '19 at 4:29
  • You may need to make sure you apply a [Match] rule as well, and you also need to make sure the filename you use lexically sorts before 99-default.link, otherwise /lib/systemd/network/99-default.link will take precedence. To be honest I have not used .network files like this myself however, so I only know the generalities of how it's supposed to work. – slangasek Feb 8 '19 at 19:39

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.