Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I often connect to multiple network simultaneously. Each of these networks provide nameserver configuration via dhcp. E.g. Network 1: (eth0):

domain company1.corp #
nameserver 192.168.0.253
nameserver 192.168.0.254

Network 2 (tun0):

domain company2.corp #
nameserver 10.102.204.51
nameserver 10.102.208.51

# Names changed

When connected to both networks simultaneously:

# resolv.conf from NetworkManager
domain company1.corp, company2.corp
nameserver 192.168.0.253
nameserver 192.168.0.254
nameserver 10.102.204.51
# NOTE: the libc resolver may not support more than 3 nameservers.
# The nameservers listed below may not be recognized.
nameserver 10.102.208.51

Resolving service.company2.corp does not work because the first name server only knows about company1.corp names.

So inspired by this article, I've setup openresolv (a resolvconf implementation) configuring a local dnsmasq service on my Arch linux install.

If I configure the nameservers manually using resolvconf:

# resolvconf -d NetworkManager
# echo "domain company1.corp
nameserver 192.168.0.253
nameserver 192.168.0.254
" | resolvconf -a eth0
# echo "domain company2.corp
nameserver 10.102.204.51
nameserver 10.102.208.51
" | resolvconf -a tun0

Then I am able to resolve names from both company1.corp and company2.corp (the local dnsmasq server handles this.)

Note that after the manual config, resolveconf -l shows the 2 configurations separately:

~ # resolvconf -l
# resolv.conf from tun0
domain company2.corp
nameserver 10.102.204.51
nameserver 10.102.208.51

# resolv.conf from eth0
domain company1.corp
nameserver 192.168.0.253
nameserver 192.168.0.254

However, when letting network manager do the configuration, the 2 configurations are not separate, as the would be if network manager was writing to /etc/resolve.conf

~ # resolvconf -l
# resolv.conf from NetworkManager
# Generated by NetworkManager
domain company1.corp, company2.corp
nameserver 192.168.0.253
nameserver 192.168.0.254
nameserver 10.102.204.51
# NOTE: the libc resolver may not support more than 3 nameservers.
# The nameservers listed below may not be recognized.
nameserver 10.102.208.51

My question is how can I get network manager to correctly call resolveconf so the the name servers for each interface are registered separately. (Unfortunately googling for this is useless because google thinks that "resolveconf" == "resolve.conf")

share|improve this question
    
On Google, search for "resolvconf" with the quotes. Always put quotes around proper names on Google. –  Gilles Apr 25 '12 at 23:45

2 Answers 2

up vote 6 down vote accepted

NetworkManager has the functionality to manage a local dnsmasq server built in. It is not necessary to use resolvconf/openresolv to do this.

To enable this:

  • Disable the resolvconf/openresolv dnsmasq configuration if it was previously enabled, and ensure there are no instances of dnsmasq running.
  • Ensure dnsmasq is installed
  • Add dns=dnsmasq to /etc/NetworkManager/NetworkManager.conf.
  • Restart NetworkManager

Once you have done this, you will see that NetworkManager has started a dnsmasq process:

$ pgrep dnsmasq -fl
1697 /usr/bin/dnsmasq --no-resolv --keep-in-foreground --no-hosts --bind-interfaces --pid-file=/var/run/nm-dns-dnsmasq.pid --listen-address=127.0.0.1 --conf-file=/var/run/nm-dns-dnsmasq.conf --cache-size=400 --proxy-dnssec

/etc/resolve.conf should be pointing to the local dnsmasq instance:

$ cat /etc/resolv.conf
# Generated by NetworkManager
domain company1.corp
search company1.corp
nameserver 127.0.0.1

and we can see what servers dnsmasq is using:

# cat /var/run/nm-dns-dnsmasq.conf 
server=/company2.corp/10.102.208.51
server=/10.in-addr.arpa/10.102.208.51
server=192.168.1.244
server=192.168.1.239
share|improve this answer
    
real nice, thank you! very straightforward and easy solution but sadly not well known -- couldn't resist, sorry –  akostadinov Dec 7 '12 at 22:46
    
This seems to work when combining a local connection with one or two VPNs. It seems it doesn't work with two local connections. Currently I'm connected to the office network over Ethernet, where sadly the upstream Internet connection has failed. Also I'm connected over USB Ethernet (my phone) to a functioning Internet. I can't get NetworkManager to apply the domain-name to the office DNS server. –  Oskar Berggren Aug 6 at 9:10
    
@OskarBerggren: On your office ethernet, under the IPv4 tab, tick the "Use this connection only for resources on it's network." –  Gary van der Merwe Aug 8 at 10:56
    
@GaryvanderMerwe That's exactly what I tried, forgot to write it. There seems to be a related bug/feature request: bugzilla.gnome.org/show_bug.cgi?id=685962 –  Oskar Berggren Aug 11 at 11:59

It looks like NetworkManager is simply overwriting /etc/resolv.conf and not using openresolv. According to FS#24635, NetworkManager does have support for openreslov, but it wasn't initially enabled in the build. What version of Arch Linux are you running and what is the version of the networkmanager package?

share|improve this answer
    
networkmanager 0.9.4.0-6 NetworkManager is calling resolveconf, and not writing to /etc/resolev.conf. The issues is that NetworkManager is merging the dns information, and passing it to resolveconf as one interface, and not as information for the separate interfaces. –  Gary van der Merwe Jun 26 '12 at 11:15

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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