Raspbian_Thomas
Posts: 5
Joined: Mon Aug 10, 2015 4:38 pm

Can SSH over eth0 but no internet connection (B+)

Sun Oct 25, 2015 9:06 pm

Hello

I am unable to install any programs correctly or update anything using ethernet and/or wifi.

When I try to run sudo apt-get update, sudo apt-get install anyprogramhere, I will have installer errors and will get error message "Network unreachable".

I am using SSH to connect to the Pi B+.

When I run sudo route -n, I see a gateway ip (255.255.255.0) and when I run cmd in Windows 10, my Pi has a dynamic connection, yet always has the same ip adress (192.168.1.64).

How fix this connection problem? I am nearly certain ethernet works because I can use it to connect to Raspi B+ without wifi module.

(Ethernet cable is attached to my router in a port marked "ETHERNET".)

EDIT: if helpful to know, I can ping to my raspberry pi from my Windows laptop using Windows command prompt on my home network with 0% loss (connection is there, but not to internet?)

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

Re: Can SSH over eth0 but no internet connection (B+)

Sun Oct 25, 2015 9:41 pm

255.255.255.0 is not a valid gateway address. It is a netmask. Your gateway should be something like 192.168.1.1.

Could you post the output of the route -n (preferably in [ code] [ /code] tags to make it more readable), like this

Code: Select all

pi@raspi3 ~ $ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG    0      0        0 eth0
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0

Raspbian_Thomas
Posts: 5
Joined: Mon Aug 10, 2015 4:38 pm

Re: Can SSH over eth0 but no internet connection (B+)

Sun Oct 25, 2015 9:56 pm

pi@raspberrypi ~ $ sudo route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 255.255.255.0 0.0.0.0 UG 202 0 0 eth0
192.168.1.0 0.0.0.0 255.255.255.0 U 202 0 0 eth0
255.255.255.0 0.0.0.0 255.255.255.255 UH 202 0 0 eth0

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

Re: Can SSH over eth0 but no internet connection (B+)

Sun Oct 25, 2015 10:13 pm

Raspbian_Thomas wrote:pi@raspberrypi ~ $ sudo route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 255.255.255.0 0.0.0.0 UG 202 0 0 eth0
192.168.1.0 0.0.0.0 255.255.255.0 U 202 0 0 eth0
255.255.255.0 0.0.0.0 255.255.255.255 UH 202 0 0 eth0
That's wrong on three counts.

What's defined in your /etc/network/interfaces?
What's defined in your /etc/dhcpcd.conf?

What address and gateway does your Windows laptop get? Take a look with an ipconfig /all in a Windows cmd.exe window.
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.

stderr
Posts: 2178
Joined: Sat Dec 01, 2012 11:29 pm

Re: Can SSH over eth0 but no internet connection (B+)

Sun Oct 25, 2015 11:40 pm

Raspbian_Thomas wrote:pi@raspberrypi ~ $ sudo route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 255.255.255.0 0.0.0.0 UG 202 0 0 eth0
192.168.1.0 0.0.0.0 255.255.255.0 U 202 0 0 eth0
255.255.255.0 0.0.0.0 255.255.255.255 UH 202 0 0 eth0
Everything has to be working from the bottom up for apt-get to work. I'm not sure why your RPi is responding to any ip address that makes sense if the above is what is coming from route. If you have a keyboard and display on the pi, then I would just run:
ifconfig
to see what it says and then:
ifconfig eth0 192.168.1.220 up
ifconfig

If it is now saying you are eth0 with 192.168.1.220, then
find out what your router is set at by running the route command on Windows. If it is 192.168.1.1, then

route del default gw
route add default gw 192.168.1.1
route

Then I would ping google with:
ping 8.8.8.8

Then cat /etc/resolv.conf
It should have something like
nameserver 8.8.8.8

Then ping google.com to see if that is working. If you have software that automatically sets the resolv.conf, it will end up changing the settings in there, perhaps to something you don't want, so expect that. This is all just for testing, your problems will be back with the next reboot.

Then try apt-get update

If it doesn't work but everything else works, go into /etc/apt/ and look at the sources.list and the sources.d directory and file issues.

Raspbian_Thomas
Posts: 5
Joined: Mon Aug 10, 2015 4:38 pm

Re: Can SSH over eth0 but no internet connection (B+)

Mon Oct 26, 2015 1:26 am

Thanks everyone for the quick help, will use your advice ASAP.

Return to “Troubleshooting”