1

as title tells, I would like to change my DNS using terminal only. All people told me to edit /etc/resolv.conf file but I think it's auto-generated and it overwrites every change I do..I can do it using GUI but I would like get more deep and know what'going when I change my DNS..

I would like to use Open DNS

Last question : How can I check what DNS I am using on my machine? Now ( because I won't to ruin my system) I am "playing" on a virtualbox machine with Ubuntu 17 hosted on Lubuntu 17 Thank you in advance

lbat
  • 47

1 Answers1

2

Name Resolution

Name resolution as it relates to IP networking is the process of mapping IP addresses to hostnames, making it easier to identify resources on a network. The following section will explain how to properly configure your system for name resolution using DNS and static hostname records. DNS Client Configuration

Traditionally, the file /etc/resolv.conf was a static configuration file that rarely needed to be changed or automatically changed via DCHP client hooks. Nowadays, a computer can switch from one network to another quite often and the resolvconf framework is now being used to track these changes and update the resolver's configuration automatically. It acts as an intermediary between programs that supply nameserver information and applications that need nameserver information. Resolvconf gets populated with information by a set of hook scripts related to network interface configuration. The most notable difference for the user is that any change manually done to /etc/resolv.conf will be lost as it gets overwritten each time something triggers resolvconf. Instead, resolvconf uses DHCP client hooks, and /etc/network/interfaces to generate a list of nameservers and domains to put in /etc/resolv.conf, which is now a symlink.

Your current conditions suggest that you are using Network manager via the GUI. The information you edit there is stored in /etc/NetworkManager/system-connections/ConnectionName (or in my case for example /etc/NetworkManager/system-connections/Ethernet\ connection\ 1

If we add for example googles DNS at 8.8.8.8 to the Network Manager list of DNS servers we find that dns=8.8.8.8; is added to the IPv4 section of that file.

to change this from the terminal you would issue the command sudo pico /etc/NetworkManager/system-connections/Ethernet\ connection\ 1 for example changing Ethernet\ connection\ 1 to match your connection name.

The Open DNS primary and secondary servers are at 208.67.222.222 and 208.67.220.220 respectively so changing the dns= line or adding if it doesn't exist to dns=208.67.222.222;208.67.220.220; does the trick and survives reboots.

You can test that this is working as advertised by visiting https://welcome.opendns.com/ in your browser which should provide the following feedback: For listing the currently used DNS servers see: Command-line to list DNS servers used by my system

OpenDNS

Sources:

https://help.ubuntu.com/lts/serverguide/network-configuration.html

https://support.opendns.com/hc/en-us/articles/228007087-Ubuntu

testing

Elder Geek
  • 36,023
  • 25
  • 98
  • 183