17

When I type in "google.com," firefox tells me that the server is not found. When I type in the IP address of google, it works just fine.

I was playing with this computer at another place and it didn't have any problems.

I have no idea what's wrong.

Also: this is a fresh install and the computer is a little old.

3 Answers 3

22

The configuration file /etc/resolv.conf contains information that allows a computer connected to a network to resolve names into addresses.

Change it to, for example, Google's DNS servers:

nameserver 8.8.8.8
nameserver 8.8.4.4
5
  • 1
    Just curious: what gave it away? What caused it? Commented May 21, 2012 at 4:22
  • 1
    It's the first thing to check, after basic network connectivity, when diagnosing DNS resolution problems. The fact you were "playing with this computer at another place" without problems suggests a misconfigured DNS resolver, which is done in /etc/resolv.conf on UNIX-like systems. It's likely that previously, the machine was configured to use a private DNS resolver only available to machines on a specific network. Commented May 21, 2012 at 9:21
  • 1
    Remember if the machine is configured to use DHCP, resolv.conf may well get replaced at the next reboot. You need to make sure DHCP (if in use) is configured correctly, and your local DHCP server (usually your cable / adsl modem) is handing out the right details. Commented May 21, 2012 at 21:58
  • 1
    8.8.8.8 is the Google public name server. 8.8.4.4 is the secondary. You should probably add both. Commented May 22, 2012 at 5:41
  • The requested page "/linux/configreseau_en.html" could not be found. This is why links are disfavored... Commented Jan 23, 2020 at 9:54
18

Your problem sounds like a case of not having the DNS server set. Normally, you would want to edit /etc/resolv.conf, but in Debian (and Ubuntu) this file could be overwritten. The official solution to this is to install the resolvconf package: apt-get install resolvconf

Then edit (with root permissions) either /etc/resolvconf/resolv.conf.d/head or /etc/resolvconf/resolv.conf.d/tail adding

nameserver 8.8.8.8
nameserver 8.8.4.4

and then run resolvconf -u to update the file. This will keep your changes from being overwritten.

1
  • You have to do the file changes and the resolvconf update with sudo. Commented Apr 30, 2022 at 13:54
6

You'll also find that the Name Service Switch (NSS) configuration file, /etc/nsswitch.conf is a common cause of this issue. While you can resolve addresses at the command line with ping and host commands, other commands like apt-get fail.

The solution is to change this line in /etc/nsswitch.conf:

From this:

hosts:          files mdns4_minimal [NOTFOUND=return] dns myhostname

To this:

hosts:          files dns

This should instantly fix the problem.

1
  • god bless you man. you rescued me from tons of problems. This is exact answer which solved all my linux problems in an instant while I was searching everywhere no one could help. Commented Aug 15, 2023 at 10:03

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.