0

I did the steps at https://wiki.archlinux.org/index.php/OpenVPN#DNS to set up DNS with OpenVPN so that anytime the OpenVPN connects or disconnects, it automatically updates /etc/resolv.conf.

The problem is that I've also got a DNS server (dnsmasq) running on localhost to resolve certain custom domains, and I'd like to add these entries to the generated /etc/resolv.conf. How can I do that?

I tried uncommenting the line name_servers=127.0.0.1 in /etc/resolvconf.conf, but then the generated /etc/resolv.conf contains only that single line, rather than appending it to the end.

user779159
  • 395
  • 1
  • 5
  • 10

1 Answers1

2

Something I ran into also.

Resolvconf can generate configuration which dnsmasq can read.

Add to your resolvconv.conf

dnsmasq_resolv=/etc/dnsmasq-resolv.conf

And then to your dnsmasq.conf

resolv-file=/etc/dnsmasq-resolv.conf

This way, resolvconf will write the dns servers for dnsmasq in a special configuration file, instead of dnsmasq reading it from /etc/resolv.conf.

Ikke
  • 146
  • 3
  • This isn't working for me, have I done it correctly? Added the first line to `/etc/resolvconf.conf` and the second to `/etc/dnsmasq.conf`, then did a `sudo systemctl restart dnsmasq.service`. But `/etc/dnsmasq-resolv.conf` still doesn't exist. Do I need to run some `resolvconf` command? – user779159 Nov 12 '15 at 22:10
  • The page you linked to also had some additional lines, which ones do I need to add to `/etc/dnsmasq.conf`? – user779159 Nov 12 '15 at 22:12
  • 1
    @user779159 You need to run resolvconv -u, which generates the necessary config for dnsmasq – Ikke Nov 13 '15 at 14:18
  • That command does generate `/etc/dnsmasq-resolv.conf`, but now when I bring up or down the openvpn service, both dnsmasq-resolv.conf and resolv.conf get updated and look the same as each other. But I need a `127.0.0.1` to appear in /etc/resolv.conf (which is my local dnsmasq). If I add it manually everything works great but then as soon as I bring up or down openvpn the file gets overwritten and doesn't contain 127.0.0.1. – user779159 Nov 13 '15 at 15:11
  • 1
    Did you remove the nameserver=127.0.0.1 part? This is still required. – Ikke Nov 13 '15 at 18:36
  • Does this still work for you after the latest update to dnsmasq? It's no longer working for me. – user779159 Nov 06 '18 at 18:21