Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 google.com" 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:192.168.0.101  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::21e:68ff:fed9:1b07/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          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)
          Interrupt:16

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          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:192.168.122.1  Bcast:192.168.122.255  Mask:255.255.255.0
          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:192.168.0.3  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::216:eaff:fede:1f78/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          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 192.168.0.1" (gateway) works. "ping 192.168.0.100" (self) works. "ping 192.168.0.7" (another PC) works. "ping google.com" reports "ping: unknown host google.com". "ping 173.194.34.72" (google.com) 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
0.0.0.0         192.168.0.1     0.0.0.0         UG    100    0        0 eth0
192.168.0.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0
192.168.0.0     0.0.0.0         255.255.255.0   U     0      0        0 wlan0
192.168.122.0   0.0.0.0         255.255.255.0   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

5 Answers 5

up vote 0 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 (192.168.0.1).

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

dig @192.168.0.1 google.com

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

;; ANSWER SECTION:
google.com.             300     IN      A       173.194.35.162
google.com.             300     IN      A       173.194.35.161
google.com.             300     IN      A       173.194.35.164
[...]

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:

traceroute 173.194.35.162

You'll see which hoop 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

Things to check:

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

/etc/resolv.conf:

nameserver 8.8.8.8
nameserver 8.8.4.4

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

ip route

tom.oconnor@charcoal-black:~$ ip route
192.168.122.0/24 dev virbr0  proto kernel  scope link  src 192.168.122.1 
169.254.0.0/16 dev eth0  scope link  metric 1000 
192.168.0.0/16 dev eth0  proto kernel  scope link  src 192.168.100.27 
default via 192.168.1.1 dev eth0  metric 100 

Default route is the one that starts "default via"

share|improve this answer
    
/etc/resolv.conf containst 2 nameservers: nameserver 194.168.4.100 nameserver 194.168.8.100. ip route reports default via 192.168.0.1 dev eth0 metric 100 192.168.0.0/24 dev eth0 proto kernel scope link src 192.168.0.101 192.168.0.0/24 dev wlan0 proto kernel scope link src 192.168.0.8 192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1 –  Paul Masri May 21 '12 at 10:02
1  
Your name servers are on .4.100 and .8.100 and your default route is 0.1...but your masks are 255.255.255.0. 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

Your Answer

 
discard

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.