I have two ethernet interfaces, eth0, and eth1 on ubuntu 17.04. eth0 is configured for DHCP and obtains an IP address, gateway, and DNS servers. This is a mobile PC so these change everytime.

eth1 is a local network where I would like to provide a DHCP server with the basic features of supplying an IP (static or dynamic), gateway, search domain, and a primary and secondary DNS. I'd like to pass on eth0's DNS servers and not some static pre-known option. How is this accomplished?

Once I connect eth0, dnsmasq seems to be doing the resolving and I can't seem to find (a) where the two servers are stored and (b) dynamically instruct a DHCP server either isc-dhcp or dnsmasq or whatever to use those in the offers.

Much appreciated!


I wonder if you need to pass DNS servers for the second interface, because I'm pretty sure that there is only one system resolver. But you can check your DNS-servers with:

$ nmcli connection show <CONNECTION_NAME> | egrep "DNS|\sdomain_name_servers"

You can list your active connection name with:

$ nmcli connection show --active

You can set new DNS-servers ( and in this case) with:

$ sudo dbus-send --system --print-reply --dest=org.freedesktop.NetworkManager.dnsmasq /uk/org/thekelleys/dnsmasq uk.org.thekelleys.SetDomainServers "array:string:,"

And check if it is succeed with:

$ journalctl -n -b _COMM=dnsmasq


$ sudo kill -USR1 `cat /var/run/NetworkManager/dnsmasq.pid` && sleep .5; journalctl -n -b _COMM=dnsmasq

Update: If you want to provide your own DHCP server which offer DNS records it's better to let your dnmasq instanse serve DNS queries. So let dnsmasq listen on your eth0 interface:

$ sudo tee <<< "interface=eth0" /etc/NetworkManager/dnsmasq.d/bind-eth0.conf
$ sudo systemctl reload NetworkManager

And set your DHCP server to offer eth0's IP address as the DNS-server.

| improve this answer | |

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.