I just installed Ubuntu Server yesterday on my old laptop. I can't ping externally or my router. To start, I figured out that instead of "eth0" I have "em1", and I got it so I now see em1 in ifconfig.
/etc/networks/interfaces
auto em1
iface em1 inet loopback
address 192.168.1.120
netmask 255.0.0.0
network 192.168.1.1
broadcast 192.168.1.255When I ping my router, I get "Destination Host Unreachable"
And when I ping google.com, I get "Unknown host google.com"
And when I ping a computer on this network, I get "Network is unreachable"
I took note of my computer that is connected to this network properly, so I changed /etc/networks/interfaces to
auto em1
iface em1 inet loopback
address 192.168.1.120
gateway 10.0.0.1
netmask 255.255.255.0
network 192.168.1.1
broadcast 192.168.1.255 Now I can't see the IP4 address in ifconfig and it says "Network is unreachable" when I ping the router.
Is there something I'm missing? I don't have much experience with networking.
edit 1
Thanks! After some changes I am able to ping my router and 8.8.8.8. Another problem I had was my router's gateway was actually 10.0.0.1, I forgot because I'm used to 192.168.1.1. For some reason though I have to assign a temporary IP via command line, shouldn't that file do that automatically?
Also, while I can ping 8.8.8.8, I can't ping google.com, even after adding it in the interfaces file. nsloopup isn't working either, it times out.
ip route
default via 10.0.0.1 dev em1
10.0.0.0/24 dev em1 proto kernel scope link src 10.0.0.10 edit 2
spelling error, now I can ping google :D
2 Answers
You shouldn't have messed with the pre-existing lo (loopback) interface: you need to revert that to
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopbackand then add your external static interface, for example
auto em1
iface em1 inet staticaddress 192.168.1.120
netmask 255.255.255.0network 192.168.1.0
gateway 192.168.1.1(these are not necessarily correct for your network: you will need to verify). You will also likely need to add at least one DNS nameserver e.g. to use Google's public DNS servers
dns-nameservers 8.8.8.8 8.8.4.4Alternatively, if your router supports DHCP address reservation you might want to use that instead - it's arguably simpler, especially for home networks.
2Your gateway needs to be 192.168.1.1 it cannot be on a different network of class A "10.0.0.0", your network cannot be an ip address 192.168.1.1, it should be 192.168.1.0 since you are using 24 bit netmask, make sure the address you use 192.168.1.120 is not assigned to any other computer or device. finally add dns-nameservers 8.8.8.8 8.8.4.4
As for your name em1 if you are concerned and want to rename it to eth0 read