DNS server address no longer stored in resolv.conf; where is it now?
The information is managed internally by Network Manager. You can get this information on the command line using the included nmcli
tool.
You can retrieve Network Manager's information for a particular network interface with the following command:
nmcli dev list iface eth0
(replace eth0
with the interface you are connecting with). The output will include information about the interface and the currently active connection on that interface:
GENERAL.DEVICE: eth0
GENERAL.TYPE: 802-3-ethernet
...
IP4.DNS[1]: 192.168.0.1
...
It shouldn't be too difficult to extract the information you are after from this output.
If you need a programmatic method of accessing this data that doesn't rely on the output of nmcli
, this information should also be available from Network Manager's D-Bus interface.
Ubuntu developers should document these changes in /etc/resolv.conf
, but have not.
Here is a list of quick commands to get you going.
Show the current DNS servers
nm-tool | grep DNS
Define a static DNS server in
/etc/dhcp/dhclient.conf
. Add the following line, and restart local resolver:supersede domain-search "sub.mydomain.com", "domain.com"; prepend domain-name-servers 192.168.0.1;
From the command prompt:
invoke-rc.d network-manager restart
Be aware that using nmcli may not always give you the full answer. e.g. if you use openconnect (or vpnc, presumably) to start a VPN, and if you have the resolvconf package installed (to take care of automatically managing /etc/resolv.conf), you'll find that it can still automatically insert the VPN's DNS settings into /etc/resolv.conf ahead of 127.0.0.1. In this circumstance, just checking (e.g.) "nmcli -f IP4 dev list" won't give you the true current DNS list. Not sure if this scenario affects you, but figured it worth mentioning.