Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

When I attempt to ping google's dns or any outside the network I get connect: Network is unreachable?

I can't update either which I put down to this

I am new to networking... And Ubuntu. But these are results of some commands I thought might help

ip a:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
    link/ether 00:0e:7f:a9:10:54 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.5/24 brd 192.168.0.255 scope global eth0
    inet6 fe80::20e:7fff:fea9:1054/64 scope link 
       valid_lft forever preferred_lft forever
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN 
    link/ether 86:0b:cb:43:63:a5 brd ff:ff:ff:ff:ff:ff
    inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
mcserver@helloworld:~$ 

vi /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.0.5
nameserver 8.8.8.8

vi /etc/network/interfaces:

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
        address 192.168.0.5
        netmask 255.255.255.0
        network 192.168.1.0
        broadcast 192.168.0.255
        post-up iptables-restore < /etc/iptables.up.rules
        dns-nameservers 192.168.0.5 8.8.8.
share|improve this question
    
What's the output of ip route show –  gnp Feb 3 at 22:08
    
192.168.0.0/24 dev eth0 proto kernel scope link src 192.168.0.5 192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1 –  user240010 Feb 3 at 22:59
2  
ip route add default via 192.168.0.1 dev eth0 should get you connectivity, assuming your routers ip address is 192.168.0.1. If this works (try ping 8.8.8.8 first, then google.com) check my answer for persisting the changes. –  gnp Feb 4 at 14:49
1  
@user240010 Thanks your solution saved my day –  mko Mar 13 at 6:45
add comment

1 Answer 1

up vote 2 down vote accepted

The following line is wrong:

iface eth0 inet static
    address 192.168.0.5
    netmask 255.255.255.0
    network 192.168.1.0 <<<<<<<<<<<<<<<<<<<<<<<< It should be 192.168.0.0
    broadcast 192.168.0.255
    post-up iptables-restore < /etc/iptables.up.rules
    dns-nameservers 192.168.0.5 8.8.8.8

Also, there doesn't seem to be any default gateway setup.

Not having more info about your network, I would suggest adding the following line at the end:

    gateway <YOUR.ROUTER.IP.ADDRESS>
share|improve this answer
add comment

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.