Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Using Ubuntu Server (12.04) via command line, I can access the LAN (e.g. ping local machines) but not the internet (e.g. "ping" or "sudo apt-get update"). How should I troubleshoot this?

I'll start by saying that I was able to access the internet (using sudo apt-get) but after some 'configuration work' I can now only access the LAN. It previously worked when I had a DHCP connection. I noticed the problem some time after I'd switched to a static IP. I've switched back to DHCP but with no luck.

/etc/network/interfaces currently looks like this:

auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
auto wlan0
iface wlan0 inet dhcp
wpa-ssid myrouterssid
wpa-psk myrouterpassword

ifconfig -a reports:

eth0      Link encap:Ethernet  HWaddr 00:1e:7a:d9:1b:07
          inet addr:  Bcast:  Mask:
          inet6 addr: fe80::21e:68ff:fed9:1b07/64 Scope:Link
          RX packets:217 errors:0 dropped:0 overruns:0 frame:0
          TX packets:414 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:23826 (23.8 KB)  TX bytes:47487 (47.4 KB)

lo        Link encap:Local Loopback
          inet addr:  Mask:
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:12 errors:0 dropped:0 overruns:0 frame:0
          TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:720 (720.0 B)  TX bytes:720 (720.0 B)

virbr0    Link encap:Ethernet  HWaddr 86:19:a7:9b:a6:4a
          inet addr:  Bcast:  Mask:
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

wlan0     Link encap:Ethernet  HWaddr 00:94:ea:de:1f:78
          inet addr:  Bcast:  Mask:
          inet6 addr: fe80::216:eaff:fede:1f78/64 Scope:Link
          RX packets:328 errors:0 dropped:0 overruns:0 frame:0
          TX packets:10 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:58008 (58.0 KB)  TX bytes:1852 (1.8 KB)

"ping" (gateway) works. "ping" (self) works. "ping" (another PC) works. "ping" reports "ping: unknown host". "ping" ( fails.

I can also SSH to this ubuntu server from another PC (although it now waits about 20 seconds before it asks for the password whereas it was previously instantaneous - significant?)

EDIT: route -n reports:

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface         UG    100    0        0 eth0   U     0      0        0 eth0   U     0      0        0 wlan0   U     0      0        0 virbr0
share|improve this question
What are your routes for this machine? (hint route -n) – symcbean May 21 '12 at 10:05
up vote 7 down vote accepted

Your resolv.conf entries are probably bad. You should determine the proper address(es) and write them manually in resolv.conf (removing current entries).
I guess that DNS server is the same as gateway (

You can try this before making changes in resolv.conf by command:

dig @

Above command tries to ask (not Your current set in resolv.conf) for IP, if there is working DNS server the answer will contain following text:

;; ANSWER SECTION:             300     IN      A             300     IN      A             300     IN      A

If it fails try entering different IPs in dig command

Another problem is that trying to ping google by IP fails (as you wrote). To make a quick test why it fails try following command:


You'll see which one of the hops causes the problem. It's possible that Your gateway is not working.

share|improve this answer
Ah, fantastic. You're right it was the gateway that was the problem - there were some legacy filters on the IPs I wanted to use. When I switched to static IP I ended up on those IPs and when I switched back to DHCP the router left my PC on those IPs. Thanks to everyone for really useful answers and great troubleshooting tips. I'll vote up (as soon as I have enough privileges). @daftu thanks for spotting the underlying issue (which wasn't on the PC itself at all). – Paul Masri May 22 '12 at 12:21
Just as a side note, I had this issue too, and the problem was that a computer had stolen the static ip address I had set. – leeand00 Feb 25 '15 at 19:09

Things to check:

You've got nameservers defined in /etc/resolv.conf



You've got a default gateway in your routing table:

ip route

tom.oconnor@charcoal-black:~$ ip route dev virbr0  proto kernel  scope link  src dev eth0  scope link  metric 1000 dev eth0  proto kernel  scope link  src 
default via dev eth0  metric 100 

Default route is the one that starts "default via"

share|improve this answer
/etc/resolv.conf containst 2 nameservers: nameserver nameserver ip route reports default via dev eth0 metric 100 dev eth0 proto kernel scope link src dev wlan0 proto kernel scope link src dev virbr0 proto kernel scope link src – Paul Masri May 21 '12 at 10:02
Your name servers are on .4.100 and .8.100 and your default route is 0.1...but your masks are How would it see those DNS servers? – Bart Silverstrim May 21 '12 at 14:06
@Bart You're saying that the masks mean that the nameserver IPs would be unreachable, right? Sorry I don't understand enough to see how these all hook together. Is it possible that as etc/resolv.conf is auto-generated perhaps these nameservers appeared here before I started having problems? – Paul Masri May 21 '12 at 14:31
Do you have other machines in the same network that are working, and can you check their DNS server settings and/or mask settings? – Bart Silverstrim May 21 '12 at 14:34

Sounds like your name resolution (DNS) is broken. Check your /etc/resolv.conf and the DNS settings of your network manager.

share|improve this answer
I have 2 nameservers in /etc/resolv.conf. How do I check the DNS settings of my network manager (via command line)? – Paul Masri May 21 '12 at 10:06
NB nmcli is not installed and without internet access I can't download & install it. – Paul Masri May 21 '12 at 10:11
Use dig or host. Host is installed on most systems by default. – Kyle May 21 '12 at 20:39

You haven't defined your default route. Your DHCP server for WiFi doesn't send information about it. Please, correct you DHCP configuration, or you must set it on the Ubuntu system by hand.

share|improve this answer

This can happen because of a bogus IP/MAC binding in your router. Issue the ifconfig command, check your HWaddr against the router's IP/MAC binding table.

share|improve this answer

Edit /etc/resolv.conf probably missing nameservers, then restart the network manager service NetworkManager restart.

share|improve this answer
I don't see anything new in this answer. The accepted answer has the same suggestion with more detail. – kasperd May 5 at 11:52

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.