docmorris
Posts: 10
Joined: Tue Feb 25, 2014 9:44 pm

No Internet Connection

Tue Feb 25, 2014 9:49 pm

Hey!

I just started my Raspberry Pi with Raspbian for the first time.
It is connected to my router/network via ethernet and I had no trouble at all connecting to it via SSH.

The thing is, when I use

Code: Select all

sudo apt-get update
, I get a lot of errors which indicate that I have no working internet connection.

I tried pinging IPs and google.com but it doesn't work either.

What can I do about this?
Thanks in advance! ;)

User avatar
rpdom
Posts: 17173
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: No Internet Connection

Wed Feb 26, 2014 5:15 am

First please show output of the following commands:

Code: Select all

cat /etc/network/interfaces
/sbin/ifconfig -a
/sbin/route
cat /etc/resolv.conf
These will show the configuration of your networking.

docmorris
Posts: 10
Joined: Tue Feb 25, 2014 9:44 pm

Re: No Internet Connection

Wed Feb 26, 2014 3:13 pm

Alright.

cat /etc/network/interfaces

Code: Select all

auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

/sbin/ifconfig -a

Code: Select all

eth0      Link encap:Ethernet  HWaddr b8:27:eb:96:f7:79  
          inet addr:192.168.178.66  Bcast:192.168.178.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:359 errors:0 dropped:0 overruns:0 frame:0
          TX packets:220 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:28504 (27.8 KiB)  TX bytes:32388 (31.6 KiB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:65536  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)



/sbin/route

Code: Select all

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.178.0   *               255.255.255.0   U     0      0        0 eth0

cat /etc/resolv.conf

Code: Select all

nameserver 8.8.8.8
Thanks a lot.

ripat
Posts: 191
Joined: Tue Jul 31, 2012 11:51 am
Location: Belgium

Re: No Internet Connection

Wed Feb 26, 2014 3:23 pm

you have no route to your gateway. Try

Code: Select all

$ sudo route add default gw <ip of your router/modem)>

# or
$ sudo ip route add default via  <ip of your router/modem)>
Using Linux command line usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.

docmorris
Posts: 10
Joined: Tue Feb 25, 2014 9:44 pm

Re: No Internet Connection

Thu Feb 27, 2014 2:11 pm

ripat wrote:you have no route to your gateway. Try

Code: Select all

$ sudo route add default gw <ip of your router/modem)>

# or
$ sudo ip route add default via  <ip of your router/modem)>

Worked! Thanks a lot!!

ripat
Posts: 191
Joined: Tue Jul 31, 2012 11:51 am
Location: Belgium

Re: No Internet Connection

Thu Feb 27, 2014 5:34 pm

You now have to make it persistent. For some reason your DHCP server (router?) failed to give you a valid route to the gateway. Investigate that first. If no luck with that and in last resort, consider giving your RPi a static address in the /etc/network/interfaces file. For example:

Code: Select all

iface eth0 inet static
    address 192.168.0.205
    netmask 255.255.255.0
    gateway 192.168.0.200
If you prefer to configure your network interfaces in DHCP and you could not find out why the DHCP failed to send a valid route, you can try this trick

Code: Select all

iface eth0 inet dhcp
post-up ip route add default via  192.168.0.200 || true
The conditional || true is there to prevent the ifup command that reads the interfaces file to stall if the post-up stanza fail for some reason.
Using Linux command line usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.

jayman27
Posts: 7
Joined: Fri Feb 28, 2014 3:05 am

Re: No Internet Connection

Fri Feb 28, 2014 3:11 am

I'm in the exact same situation.
Although, when I enter...

Code: Select all

sudo route add default gw (IP)
I get...

Code: Select all

siocaddrt: network is unreachable

ripat
Posts: 191
Joined: Tue Jul 31, 2012 11:51 am
Location: Belgium

Re: No Internet Connection

Fri Feb 28, 2014 6:03 am

Can you post the result of
sudo ifconfig
sudo route -n
Using Linux command line usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.

User avatar
DougieLawson
Posts: 39121
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: No Internet Connection

Fri Feb 28, 2014 5:45 pm

jayman27 wrote:I'm in the exact same situation.
Although, when I enter...

Code: Select all

sudo route add default gw (IP)
I get...

Code: Select all

siocaddrt: network is unreachable
The command is
sudo route add default gateway [ipaddr] dev eth0
or
sudo ip route add default via [ipaddr] dev eth0
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

User avatar
jojopi
Posts: 3268
Joined: Tue Oct 11, 2011 8:38 pm

Re: No Internet Connection

Fri Feb 28, 2014 5:55 pm

"sudo route add default gw (IP)" is absolutely fine. The error "Network is unreachable" means that the gateway IP you are trying to add is not in any of your local subnets.

So, you are not in the exact same situation. You have no IP address at all, or one that is completely wrong.

jayman27
Posts: 7
Joined: Fri Feb 28, 2014 3:05 am

Re: No Internet Connection

Fri Feb 28, 2014 6:30 pm

Thanks everyone for the help, but aparently I just needed to wait a day. I booted my pi and the internet now works. Not sure why I had no luck yesterday (booted a bunch of times), but I'm happy everything is on track. This is my first attempt at anything pi related, it's nice to know there are people ready to help so quickly. :D

Return to “Troubleshooting”