Ubuntu uses the resolvconf program in the standard to configure local DNS resolution.The resolvconf package includes a simple database and a runtime for dynamically modifying name server information.Typically, the program resolvconf runs through a network interface to push routines such as ifup, ifdown, NetworkManager, dhclient, and pppd, or local name servers such as dnsmasq to update the name server information.
If static IP addresses and DNS records are used on a host, the resolvconf package should be deactivated under Ubuntu, so that the DNS configuration from the dnsmasq daemon is not automatically made, the configuration that has been edited in /etc/resolv.conf and /etc/network/interfaces, will otherwise be overwritten by the resolvconf program.
Disable resolvconf
1 2 |
resolvconf --disable-updates |
Disable resolvconf from boot level and quit the program.
1 2 3 |
systemctl disable systemd-resolved.service service systemd-resolved stop |
Customize The Network Manager with default DNS.
1 2 3 4 5 |
vi /etc/NetworkManager/NetworkManager.conf .. dns=default .. |
Remove the symlink resolv.conf under /etc.
1 2 |
rm /etc/resolv.conf |
and create a new resolv.conf file with the name servers. in this example, it’s Google Public DNS.
On a local network or ADS, the internal name servers should be used.
1 2 3 4 5 |
vi /etc/resolv.conf nameserver 8.8.8.8 nameserver 8.8.4.4 |
Delete the resolv.conf file of the systemd configuration program.
1 2 |
rm /etc/systemd/resolved.conf |
change the configuration.
1 2 |
service network-manager restart |
The name servers can also be entered in the interface configuration.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
vi /etc/network/interfaces auto lo iface lo inet loopback auto ens160 iface ens160 inet static address 10.10.0.8 gateway 10.10.0.1 netmask 255.255.255.0 network 10.10.0.0 broadcast 10.10.0.255 dns-nameservers 8.8.8.8 8.8.4.4 dns-search my.local |
The interface name (ens160) may differ and must correspond to that of the respective host.
The /etc/resolv.conf file should not be missing.
To enable the changed network configuration, it must be read into memory.
1 2 |
/etc/init.d/networking restart |
Troubleshooting
Many network issues are due to incorrect DNS or incorrect configuration of resolver. In a home network there is often no internal DNS, whereby the router or the firewall can be used as a name server, such as the FRITZ!Box. Basically, it should be ensured that the firewall used has a DNS cache, with semi-professional firewalls such as the FortiGate, not every model has such a cache. For open source-based firewalls, on the other hand, most provide a cache through DNS forwarder or dnsmasq.
After changes to the name servers in Windows, the DNS cache should be reset. Open the prompt.
1 2 |
ipconfig /flushdns |
For Linux, the DNS cache can be reset, with one of the following commands, depending on which service is installed.
1 2 3 4 5 6 7 |
sudo /etc/init.d/nscd restart service nscd restart service nscd reload sudo /etc/init.d/dnsmasq restart service dnsmasq restart rndc reload |
In the Mac OS X terminal as root.
1 2 |
lookupd -flushcache |
If there is no internal DNS, the name servers of the respective Internet provider can be used, with Swisscom the following are.
1 2 3 |
cns7.bluewin.ch, 195.186.1.162 cns8.bluewin.ch, 195.186.4.162 |
Example of a name server querying its provider on Windows.
1 2 3 4 5 6 7 8 9 10 |
C:'> nslookup -type=ns green.ch Server: dns1.agrinet.ch Address: 81.221.250.11 Non-authoritative response: green.ch nameserver = dns2.agrinet.ch green.ch nameserver = dns1.agrinet.ch dns1.agrinet.ch internet address = 81.221.250.11 |
Example name server lookup query on Linux.
1 2 3 4 5 6 7 8 9 |
host -t ns green.ch green.ch name server dns1.agrinet.ch. green.ch name server dns2.agrinet.ch. host dns1.agrinet.ch & host dns2.agrinet.ch dns1.agrinet.ch has address 81.221.250.11 dns2.agrinet.ch has address 81.221.252.11 dns2.agrinet.ch has IPv6 address 2a01:2a8:2001:252::11 |
A ping -n1 resolves addresses to host names with parameters –a and –4 for IPv4 address.
1 2 3 4 5 6 7 8 9 10 11 |
C:'> ping -4 -n 1 -a www.google.com Ping runs for www.google.com with [216.58.201.4]32 bytes of data: Response from 216.58.201.4: Bytes=32 Time=32ms TTL=50 Ping statistics for 216.58.201.4: Packages: Sent = 1, Receive = 1, Lost = 0 (0% loss), Approx. times in millisec.: Minimum = 32ms, Maximum = 32ms, Mean = 32ms |