..

How to make permanent DNS changes to resolv.conf file on Ubuntu

DNS system is the networking service responsible with mapping IP Addresses to names or vice-versa, making easy for humans to identify hosts, servers or other equipment on a network based on their names.
On Ubuntu, the /etc/resolv.conf file is responsible with resolving system-wide domain name mapping by sending DNS queries to the nameservers IP Addresses.
The major disadvantage of resolv.conf file is that its content gets overwritten by network interface hook scripts every time the system reboots or the state of the network changes, making difficult to generate a permanent list of nameservers and domains that can be used all the time.
One of the tricks that you can use to fool down and avoid using resolv.conf nameservers list is to add DNS IP entries in/etc/network/interfaces file on the appropriate Network Interface Card as described in this article.

In order to permanently implement DNS changes to resolv.conf file on Ubuntu, you need to manually edit resolvconfutility base file located on /etc/resolvconf/resolv.conf.d/ system path and add your custom nameservers IP values as presented further on this short guide.
If  your Debian-based distribution don’t ship with resolvconf utility by default, install the resolvconf package by issuing the following command, then continue with the below steps:
sudo apt-get install resolvconf

    1.    First, open resolvconf base file for editing with a text editor with root privileges by issuing the following command:
sudo nano /etc/resolvconf/resolv.conf.d/base

    2.    By default this file should be blank, so start adding your custom DNS resolvers IP Addresses or other DNS options. Use the below file excerpt as guidance:

  1. nameserver 192.168.1.1

  2. nameserver 8.8.8.8

  3. nameserver 8.8.4.4

  4. search server.lan server1.lan

  5. options rotate



Replace the nameserver IP values and search statement to match your own DNS entries and domains. The last statement, options rotate, forces the resolver to distribute the load to the entire nameservers list in a round-robin fashion (first, second, third in a loop) rather than using the first nameserver every time.

    3.    After you have populated the file with your appropriate DNS entries , save and close it, then restart you network or reboot the system in order to reflect changes.
sudo reboot

To assure that the DNS changes applied, get the output of the resolv.conf file using cat command:
cat /etc/resolv.conf

resolv.conf output
resolv.conf output

That’s it!  Now your resolv.conf file should be populated with the same content as/etc/resolvconf/resolv.conf.d/base file and the DNS changes should be made permanent.
Previous
Next Post »

Featured post

MUST WATCH INSPIRATIONAL VIDEOS 2017 -PART 1