Ubuntu DNS Setting Method Tutorial
Summary:It was relatively easy to set up DNS in Ubuntu system earlier, just add it in/etc/resolv.conf. Starting from Ubuntu 10.04 version, this method is not…
This book is available as an e-book in EPUB format
PayPal sponsors this website for any amount. I will send you an EPUB e-book via email. Please send me an email
Email: shuxueha@outlook.com
PayPal: https://paypal.me/zhipinglei
You can also scan the PayPal QR code below to sponsor
You can also purchase this book on Amazon: click to enter the Amazon official website
It was relatively easy to set up DNS in Ubuntu system earlier, just add it in/etc/resolv.conf. Starting from Ubuntu 10.04 version, this method is not very effective. Although this setting still works, it will be restored after restarting the system. Below, we will introduce the setting methods for both the old and new versions separately.
How to set up Ubuntu versions before 10.04:
Open/etc/resolv.conf with a text editor, add DNS settings commands, and save after completion.
nameserver 8.8.8.8
nameserver 8.8.4.4
After setting up, we can verify if it is successful by opening the Terminal terminal, entering nslookup and enter enter enter, and then enter enter enter enter for server. If it is the same as the following image, it will take effect successfully. If not, try restarting it.
How to set up Ubuntu versions after 10.04:
The new version of Ubuntu system can also be modified using the above method, but restarting will fail. The reason is that DHCP is used by default to obtain network configuration, and/etc/resolv.conf is regenerated by the DHCP service every time it is restarted. This is already indicated in the/etc/resolv.conf comment:
#Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND — YOUR CHANGES WILL BE OVERWRITTEN
If it is Ubuntu desktop version, the setup will be very simple. In the network configuration IPv4 settings, set the DNS server to the desired one, as shown in the figure below.
If it is Ubuntu server version, the setup will be more complicated. It can be set in/etc/resolv.conf, but there is still a problem of reboot failure. There are two solutions, such as adding DNS settings in the/etc/network/interfaces file (followed by dns-nameservers 8.8.8.8), or creating a new tail file in/etc/resolvconf/resolv. conf. d, as follows:
First, create a tail file:
#vim /etc/resolvconf/resolv.conf.d/tail
Then add DNS settings:
nameserver 8.8.8.8
nameserver 8.8.4.4
Finally, enter wq to save and exit, restart the resolvconf program for the settings to take effect:
#/etc/init.d/resolvconf restart
Although the above methods can solve the problem of reboot failure, they all have one drawback, which is that the DNS server priority set in/etc/resolv.conf will be lower than the DNS obtained by DHCP.
To solve this problem, you can modify the/etc/dhcp/dhclient. conf file (highlighted in red), as shown below.
The DNS server address set above will be inserted in/etc/resolv.conf, and its execution priority will be higher than the DNS obtained by DHCP.
| High-speed VPN | Fast VPN | Preferred Accelerator VPN | Reliable VPN |
| High quality VPN | Old fashioned VPN | Stable VPN(Recommend) | Smooth VPN |

