Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have 4 ubuntu machines connected in a LAN network by a single switch.Their IP address is from 192.168.10.10-192.168.10.13.But 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:

127.0.0.1       localhost
192.168.10.12   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:192.168.10.12  Bcast:192.168.10.255  Mask:255.255.255.0
          inet6 addr: fe80::d6ae:52ff:fec9:615f/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          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)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 192.168.10.1

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

1 Answer 1

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

route add default gw 192.168.10.1

Replace 192.168.10.1 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.

share|improve this answer
    
Hi , thank you ,you answer absolutely solved my problems.But I still have some questions.On a good machine(192.168.10.11),I use 'route' command , it show its gateway is 192.168.10.10(which 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 “192.168.10.1”,why they are different in the same machine(192.168.10.11)? –  Vico_Wu Jan 10 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. –  Thorsten Staerk Jan 11 at 9:10

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.