On Ubuntu, to change DNS we must change file /etc/resolv.conf but it will be overwritten after the system reboots. To resolve this problem, we must install the resolvconf package by using these steps below
sudo apt-get install resolvconf
root@tutorialspots:~# sudo apt-get install resolvconf Reading package lists... Done Building dependency tree Reading state information... Done The following NEW packages will be installed: resolvconf 0 upgraded, 1 newly installed, 0 to remove and 42 not upgraded. Need to get 53.5 kB of archives. After this operation, 243 kB of additional disk space will be used. Get:1 http://archive.ubuntu.com/ubuntu/ precise-updates/main resolvconf all 1.63 ubuntu16 [53.5 kB] Fetched 53.5 kB in 0s (334 kB/s) Preconfiguring packages ... Selecting previously unselected package resolvconf. (Reading database ... 23468 files and directories currently installed.) Unpacking resolvconf (from .../resolvconf_1.63ubuntu16_all.deb) ... Processing triggers for man-db ... Setting up resolvconf (1.63ubuntu16) ... resolvconf start/running Processing triggers for resolvconf ...
Now, we change the /etc/resolvconf/resolv.conf.d/base file, instead of /etc/resolv.conf file
Add your owner DNS like:
nameserver 2001:4860:4860::8844 nameserver 2001:4860:4860::8888
Step 3: restart system
Done! the /etc/resolv.conf file will be automatically changed.
We can test by using the command:
# 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 nameserver 2001:4860:4860::8844 nameserver 2001:4860:4860::8888 nameserver 22.214.171.124 nameserver 126.96.36.199