No a direct solution but you can smooth things a little by adding options to your resolv.conf
for instance :
nameserver DNS1
nameserver DNS2
options rotate
options timeout:2
options attempts:1
the default for timeout
is 5 seconds, and default value for attempts
is 2.
What none of the answers posted so far addresses is the appearance that the questioner fails to understand that having nameserver 127.0.0.1
in /etc/resolv.conf
is correct, assuming that a local nameserver is running. And in Ubuntu 12.04 Desktop there is, by default, a local nameserver running, namely, a dnsmasq
process controlled by NetworkManager which listens on 127.0.0.1
. In Ubuntu 12.10 the listen address has been changed to 127.0.1.1
.
So the solution is not to make any changes to resolv.conf
. It is correct, assuming that the questioner wants to use the local nameserver.
If name service is not working then the local nameserver is not being given correct forwarding addresses, or there is some other networking problem.
The questioner tried using the "network settings GUI" to "generate the file with the right settings" and this failed to work. I don't know exactly what this means, but here is the right way to enter nameserver addresses so that they end up in resolv.conf
at the right time. I assume that the questioner is using NetworkManager
and not ifup
to configure interfaces.
Most often interfaces are configured using the DHCP protocol. In that case nothing needs to be configured on the local system. The DHCP server knows what nameserver address its clients should use and sends this information to the DHCP client, which sends it to NetworkManager, which sends it to resolvconf, which puts the information into resolv.conf
. So in this case it is the DHCP server that may need to be configured.
If the network interface on the local machine is statically configured then the correct nameserver addresses have to be entered into NetworkManager at, for example, network indicator | Edit Connections... | Wireless | myconnection | Edit... | IPv4 Settings | Additional DNS servers.
It is possible that the local nameserver is not working properly. In that case the questioner should edit /etc/NetworkManager/NetworkManager.conf
sudo gedit /etc/NetworkManager/NetworkManager.conf
and comment out the line
dns=dnsmasq
in the "[main]" section. To comment out the line, put a #
at the beginning of the line, then save the file. Then restart network-manager.
sudo restart network-manager
After this, non-local nameserver addresses will be entered into resolv.conf
instead of the 127.* address.
If the questioner is using ifup
rather than NetworkManager to configure network interfaces then jmartin2279's answer is correct: you have to add the nameserver addresses to /etc/network/interfaces in the way jmartin2279 described.
Contrary to what some other answers advise, in general you should not add nameserver
, domain
or search
options to files in /etc/resolvconf/resolv.conf.d/
. See my comments on those answers.
Best Answer
In 12.04, resolvconf is installed by default. Here is a quick summary of how to make DNS configuration changes for some common use cases:
For a static configuration using
ifup
, usedns-nameservers
anddns-search
entries in/etc/network/interfaces
.For a static configuration using
NetworkManager
, select theAutomatic (DHCP) addresses only
Method
and enter addresses and domain names in theAdditional DNS servers
andAdditional search domains
fields in the Connection Editor.To override resolvconf's default configuration, use
base
,head
andtail
in/etc/resolvconf/resolv.conf.d/
. Only enter addresses and domain names in these files as a temporary measure, since they really belong elsewhere, as described above.Disabling resolvconf is not recommended, but you can replace the symlink
/etc/resolv.conf
with a regular file.For more information, see Stéphane Graber's blog post.