I have 4 ubuntu machines connected in a LAN network by a single switch.Their IP address is from after I restarted one of them since disk problem,I find that this machine cannot access internet(others can access internet),but all the 4 machines can be accessed from each other. I use "sudo ufw status" ,it shows inactive.

I use "cat /etc/hosts" , it shows:       localhost   mongodb

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

The others have the same config(of cource the LAN ip is different).

So , I really don't know what happened. I tried to use command "sudo ifconfig eth0 restart",it reports:

Host name lookup failure

mongodb@mongodb:/var$ ifconfig eth0
eth0      Link encap:Ethernet  HWaddr d4:ae:52:c9:61:5f  
          inet addr:  Bcast:  Mask:
          inet6 addr: fe80::d6ae:52ff:fec9:615f/64 Scope:Link
          RX packets:16199 errors:0 dropped:91 overruns:0 frame:0
          TX packets:14260 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:2198421 (2.1 MB)  TX bytes:2664354 (2.6 MB)

mongodb@mongodb:/var$ cat /etc/resolv.conf 
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)

mongodb@mongodb:/var$ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface         UG    100    0        0 eth0   U     0      0        0 eth0
  • 2
    Can you provide the output of ifconfig eth0, cat /etc/resolv.conf, and route -n?
    – DopeGhoti
    Jan 10, 2014 at 7:51
  • @DopeGhoti Thank you.The question has been edited!
    – wuchang
    Jan 10, 2014 at 7:58

1 Answer 1


You are missing a default gateway. Add a default gateway like this:

route add default gw

Replace by your gateway. You should be able to see your gateway using the route command on the known good computers. See my wikiblog TroubleShooting network.

To set your gateway persistent (after reboot) look at /etc/network/interfaces on the known good computers.

  • Hi , thank you ,you answer absolutely solved my problems.But I still have some questions.On a good machine(,I use 'route' command , it show its gateway is is just ip of on machine in this LAN,this machine has 2 NICs,one has direct access to internet , the other is connected to this LAN switch),but when I run "cat /etc/network/interfaces" ,it says gateway is “”,why they are different in the same machine(
    – wuchang
    Jan 10, 2014 at 8:47
  • First there can be multiple gateways; and I cannot see route's output on here. Second, if the route output differs from the configuration in /etc/network/interfaces there may have been some changes after boot. Third /etc/network/interfaces can contain configs for several network cards, maybe the other gateway is for another network card. Fourth there may be changes by dhcp, but I do not know what happends if dhcp defines another gateway than /etc/network/interfaces. So, first step: reboot and see if it continues working. Jan 11, 2014 at 9:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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