4

I have upgraded to 12.10 from 12.04 recently and I am having issues with connecting to the Internet.

I got an IP address and am able to ping other LAN IPs in the local network but I am unable to connect to the Internet and am even unable to ping www.google.com from a terminal.

Somehow making changes in /etc/resolv.conf and restarting resolvconf service and rebooting works but I need to do this every time I connect to a new network. How do I make these changes permanent?

Can someone suggest a solution to this issue?

jdthood
  • 12,625
sudheer
  • 49
  • 1
  • 1
  • 2

4 Answers4

2

As per the header on /etc/resolv.conf:

# 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

Try putting your change in

/etc/resolvconf/resolv.conf.d/base and they should get added to /etc/resolv.conf when it gets re-written every 15 minutes.

fabricator4
  • 8,471
  • 1
  • 37
  • 39
1

DISCLAIMER! Following this answer may cause unexpected problems if your DNS servers are managed as a part of network manager - while this will force the usage of the DNS servers you want above the dnsmasq system and the DNS servers in network manager's settings, it will do this for everything. As well, certain networks and/or connections may require you to use their DNS server(s) to get out to the internet with resolving things.

Edit /etc/resolvconf/resolv.conf.d/head and add the nameserver 1.2.3.4 record here.

This works on 14.04 even on a Desktop install. I know this because I have a locally running DNS server (via bind9) on my laptop locally for local zone resolution (since I do a lot of virtual machine stuff), and it becomes necessary to query my local DNS first above all else.

Thomas Ward
  • 78,878
0

Here is a generic procedure which fixes a couple of known bugs in nameserver information handling.

Is resolvconf installed? If so then do the following.

sudo dpkg-reconfigure resolvconf

If it is not installed then do the following.

sudo apt-get install resolvconf

Now that resolvconf is installed correctly, reboot so that resolvconf will be provided with nameserver information.

If name service is still broken and you are using NetworkManager to manage networking then open /etc/NetworkManager/NetworkManager.conf in an editor and comment out the line "dns=dnsmasq". To comment it out, put a '#' character at the beginning of the line.

gksudo gedit /etc/NetworkManager/NetworkManager.conf

Next go into the connection editor and make sure that the connection you are using is properly configured. E.g., most often "network indicator | Edit Connections... | Wired | Wired connection 1 | Edit... | IPv4 Settings | Method" is set to "Automatic (DHCP)" and no "Additional DNS server" addresses are set.

Then restart network-manager.

sudo restart network-manager

Now confirm that the expected nameserver address(es) appear in /etc/resolv.conf.

If you aren't using NetworkManager to configure interfaces and you are using ifup then edit /etc/network/interfaces and include dns-nameservers and dns-search lines in the appropriate iface stanza as needed. Make sure that /etc/resolvconf/resolv.conf.d/head only contains comment lines and that /etc/resolvconf/resolv.conf.d/base and /etc/resolvconf/resolv.conf.d/tail are absent or empty. Then ifdown and ifup the interface. Confirm that the nameserver address(es) that you added to /etc/network/interfaces now appear in /etc/resolv.conf.

If name service still does not work then there's most likely a local problem: a misconfigured DHCP server, for example. Another known cause of problems is third-party VPN clients which trash the symbolic link /etc/resolv.conf. If your LAN seems OK and you aren't using third-party networking software then file a bug report against NetworkManager or resolvconf, whichever you think is more likely the culprit.

jdthood
  • 12,625
0

I've struggled with dns myself and have posted a question and solution to it, which lists some of the ways you can change dns settings. Basically, there are two ways - either edit any of 3 files in /etc/resolvconf/resolv.conf.d/ or edit /etc/dhcp/dhclient.conf. I personally prefer the first one.

Bellow are some of the methods i apply to my ubuntu and linux mint systems. Use at your discression.

/etc/dhcp/dhclient.conf

I will start with this since others have covered already resolv.conf files. What you see bellow is portion of this file. Look at line 18, which says prepent name server . It will add your specified dns to the settings, no matter what connection you use.

1 # Configuration file for /sbin/dhclient, which is included in Debian's

 2  #       dhcp3-client package.
 3  #
 4  # This is a sample configuration file for dhclient. See dhclient.conf's
 5  #       man page for more information about the syntax of this file
 6  #       and a more comprehensive list of the parameters understood by
 7  #       dhclient.
 8  #
 9  # Normally, if the DHCP server provides reasonable information and does
10  #       not leave anything out (like the domain name, for example), then
11  #       few changes must be made to this file, if any.
12  #

13  option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;

14  #send host-name "andare.fugue.com";
15  send host-name = gethostname();
16  #send dhcp-client-identifier 1:0:a0:24:ab:fb:9c;
17  #send dhcp-lease-time 3600;
18  #supersede domain-name "fugue.com home.vix.com";
19  #prepend domain-name-servers 127.0.0.1;
20  prepend domain-name-servers 208.67.220.220;
21  request subnet-mask, broadcast-address, time-offset, routers,
22          domain-name, domain-name-servers, domain-search, host-name,
23          dhcp6.name-servers, dhcp6.domain-search,
24          netbios-name-servers, netbios-scope, interface-mtu,
25          rfc3442-classless-static-routes, ntp-servers,
26          dhcp6.fqdn, dhcp6.sntp-servers;
27  #require subnet-mask, domain-name-servers;
28  #timeout 60;
29  #retry 60;
30  #reboot 10;
31  #select-timeout 5;
32  #initial-interval 2;
33  #script "/etc/dhcp3/dhclient-script";
34  #media "-link0 -link1 -link2", "link0 link1";
35  #reject 192.33.137.209;

36  #alias {
37  #  interface "eth0";

/etc/resolvconf/resolv.conf.d/

The text from either of 3 will be added to /etc/resolv.conf, so I don't think it matters which one you choose. I'd use tail, personally. Simply open it with any text editor and add nameserver 8.8.8.8 , where 8.8.8.8 is google's public dns but you can use whatever dns you like.

A small tip

In /etc/Network-Manager/Network-Manager.conf I suggest you comment out dns=dnsmasq line, which is a plugin for network manager, which goes automatically to the nearest/easiest to reach dns, which might not be what you want, if you want to by pass the network's dns, and use your own.

Side note: The fact that resolv.conf gets rewritten is actually normal - it does so upon every new connection on my machine as well. While I can't answer why, my guess is that NetworkManager gets dhcp lease from the local connection, and uses that local connection's settings, dns, and whatever else, so resolv.conf needs to be adapted to that.