Where to set DNS Servers?

Issues Related to Networking (Wired and Wireless)

Moderator: Moderators

Where to set DNS Servers?

Postby Honeyman » Fri Jan 17, 2014 0:36

I am wondering where to manually set name servers if I do not want to use those provided by my internet service company.

In the German Gentoo documentation http://www.gentoo.de/doc/de/handbook/handbook-x86.xml?part=4&chap=1 it is proposed to add a line in /etc/conf.d/net

Like this for example:
Code: Select all
# This blank configuration will automatically use DHCP for any net.*
# scripts in /etc/init.d.  To create a more complete configuration,
# please review /usr/share/doc/openrc/net.example and save your configuration
# in /etc/conf.d/net (this file :]!).

# The network scripts are now part of net-misc/netifrc
# In order to avoid sys-apps/openrc-0.12.4 from removing this file, this comment was
# added; you can safely remove this comment.  Please see
# /usr/share/doc/netifrc*/README* for more information.
dhcp_wlan0="nosendhost"
dns_domain_wlan0="localdomain"
nis_domain_wlan0="localdomain"
dhcp_eth0="nosendhost"
dns_domain_eth0="localdomain"
nis_domain_eth0="localdomain"

#My name servers put here:
dns_servers_eth0="85.214.20.141 213.73.91.35"


But in the aforementioned document the 'name servers' line is part of the configuration for a specific network interface together with static IP address and netmask as well as route information.

Another option should be the file /etc/resolvconf which is managed via /etc/resolvconf.conf if I understand correctly. There I can also set the name servers.

Which way would you recommend?

Thanks for your help


BTW: Is there a command which allows me to directly check which name servers my system uses?
Je me regarde pour me désoler,
je me compare pour me consoler

Maurice de Talleyrand
Honeyman
Growing Hen
 
Posts: 159
Joined: Sun Apr 08, 2012 2:25
Location: Berlin, Germany

Re: Where to set DNS Servers?

Postby Fitzcarraldo » Fri Jan 17, 2014 6:04

The easiest way is to use the network management GUI front-end of your DE (e.g. gnome-extra/nm-applet or kde-misc/networkmanagement on the Panel), as SL uses NetworkManager. If you have your network connection currently configured to use the method "Automatic (DHCP)", select "Automatic (DHCP) addresses only" instead and then enter the IP address(es) of the DNS(s) you wish to use. See, e.g. Using Google Public DNS (scroll down to the Linux section).
User avatar
Fitzcarraldo
Sagely Hen
 
Posts: 7981
Joined: Sat Mar 10, 2007 5:40
Location: United Kingdom

Re: Where to set DNS Servers?

Postby Honeyman » Fri Jan 17, 2014 10:49

I would like to know how to do that via the command line.

When trying to open network management GUI in MATE (The desktop I use) I get a notification windows telling me that the configuration could be loaded as I'm "not allowed to access the system configuration."

I assume that is a permission issue (I do that a normal user, not as root).

I want to set certain DNS servers as here in Germany the government "censures" the official ones of ISPs, because, as they say, they want to fight against child pornography. There are probably some other reasons as well for them doing just that and I will not raise the issue, whether that is the most sensibly way to fight against online child pornography.

I would also prefer not to use Google's name server.
Je me regarde pour me désoler,
je me compare pour me consoler

Maurice de Talleyrand
Honeyman
Growing Hen
 
Posts: 159
Joined: Sun Apr 08, 2012 2:25
Location: Berlin, Germany

Re: Where to set DNS Servers?

Postby Fitzcarraldo » Fri Jan 17, 2014 12:25

You don't have to use Google's name servers. You can use any public name server you want. The Google article shows you the method; the user can simply substitute whatever IP addresses (s)he wants for the name servers.

Please read carefully the Linux section in the Google article. If your installation uses NetworkManager then you can't do it via the command line unless you disable or un-install NetworkManager and set up networking manually (see Part 4 of the Gentoo Handbook for the way of doing that if you are using the OpenRC init system, but I have no idea how to set up networking manually if you are using the systemd init system, as I don't use systemd).

If your distribution doesn't use Network Manager, your DNS settings are specified in /etc/resolv.conf.

(My emphasis.)

If your installation uses NetworkManager, NetworkManager will overwrite any edits you make to /etc/resolv.conf. This is because NetworkManager does what its name suggests: it manages networking and will use the parameters configured via its networking GUI front-end. If you want to stop NetworkManager from doing that, you would either have to change the file's attributes (which is not advisable):

Code: Select all
chattr +a /etc/resolv.conf

or you would have to use NetworkManagerDispatcher to add lines indirectly to /etc/resolv.conf (you can see an example of NetworkManagerDispatcher being used in such a way in my blog post ‘Server not found’ by browser at launch).

If you can't enter parameters via the networking GUI front-end in MATE, something is not right. Obviously the purpose of the GUI front-end is to enable users to configure networking. I don't use MATE but, according to the SL package list for the ISO, the front-end used for NetworkManager is gnome-extra/nm-applet-gtk2. Is nm-applet running? You can check via the command line or by using e.g. top or htop. You could also have a look in the file /etc/NetworkManager/NetworkManager.conf and change "managed=false" to "managed=true" (if the former) and reboot or restart NetworkManager, to see if that has an effect.

Honeyman wrote:BTW: Is there a command which allows me to directly check which name servers my system uses?

Yes, it's:

Code: Select all
cat /etc/resolv.conf

If that just shows the IP address of your home router, then the router will be resolving names using the name server specified in the router itself. You could of course use your router's GUI (usually via a Web browser) to specify different name servers. If you had a Belkin router, for example, you would use the procedure given in Changing Belkin Router DNS servers.

Image

In fact, why don't you just do that? By configuring the name servers in the router, you would avoid having to do anything on your computer.
User avatar
Fitzcarraldo
Sagely Hen
 
Posts: 7981
Joined: Sat Mar 10, 2007 5:40
Location: United Kingdom

Re: Where to set DNS Servers?

Postby Honeyman » Mon Jan 20, 2014 23:52

Thanks for the lengthy response.

In fact I have modified the DNS settings via my router, which also saves me some work by not having to tinker around with DNS settings on different Linux distributions.

I was just intrigued by the fact that on Gentoo system there seem to be two different ways to set name servers, so I wanted to know whether one was preferable to the other.

My Sabayon uses systemd but grep'ing for a service named '*resolv*' or similiar did not bring up anything. So I will have to do some reading to figure out, whether DNS settings are also taken care of by systemd.
Je me regarde pour me désoler,
je me compare pour me consoler

Maurice de Talleyrand
Honeyman
Growing Hen
 
Posts: 159
Joined: Sun Apr 08, 2012 2:25
Location: Berlin, Germany


Return to Networking and Wireless

Who is online

Users browsing this forum: No registered users and 2 guests