eng.happy
Posts: 14
Joined: Fri Jan 10, 2014 9:38 pm

can't reach the internet

Fri Jan 10, 2014 9:50 pm

hey guys,

i can't access the internet on my pi via Ethernet cable... but i can ping my router 192.168.1.1
and when i ping 8.8.8.8 i received unreachable

i have used dhcp and static and in vain

it's some about the data i collect from my pi

Code: Select all

pi@raspberrypi ~ $ ifconfig
eth0      Link encap:Ethernet  HWaddr b8:27:eb:43:ce:a8  
          inet addr:192.168.1.150  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:56083 errors:0 dropped:0 overruns:0 frame:0
          TX packets:57145 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:7285611 (6.9 MiB)  TX bytes:18038635 (17.2 MiB)

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:104216 errors:0 dropped:0 overruns:0 frame:0
          TX packets:104216 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:19924628 (19.0 MiB)  TX bytes:19924628 (19.0 MiB)

Code: Select all

pi@raspberrypi ~ $ ping 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_req=1 ttl=254 time=1.28 ms
64 bytes from 192.168.1.1: icmp_req=2 ttl=254 time=0.788 ms
64 bytes from 192.168.1.1: icmp_req=3 ttl=254 time=0.721 ms
64 bytes from 192.168.1.1: icmp_req=4 ttl=254 time=0.713 ms
64 bytes from 192.168.1.1: icmp_req=5 ttl=254 time=0.665 ms
64 bytes from 192.168.1.1: icmp_req=6 ttl=254 time=0.787 ms
64 bytes from 192.168.1.1: icmp_req=7 ttl=254 time=0.734 ms
^C
--- 192.168.1.1 ping statistics ---
7 packets transmitted, 7 received, 0% packet loss, time 6007ms
rtt min/avg/max/mdev = 0.665/0.813/1.284/0.196 ms

Code: Select all

pi@raspberrypi ~ $ route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.1.0     *               255.255.255.0   U     0      0        0 eth0

Code: Select all

pi@raspberrypi ~ $ cat /etc/resolv.conf
nameserver 8.8.8.8

Code: Select all

pi@raspberrypi ~ $ ping 8.8.8.8
connect: Network is unreachable

Code: Select all

pi@raspberrypi ~ $ ping google.com
ping: unknown host google.com

Code: Select all

pi@raspberrypi ~ $ ping 192.168.1.4
PING 192.168.1.4 (192.168.1.4) 56(84) bytes of data.
64 bytes from 192.168.1.4: icmp_req=1 ttl=128 time=2.08 ms
64 bytes from 192.168.1.4: icmp_req=2 ttl=128 time=2.84 ms
64 bytes from 192.168.1.4: icmp_req=3 ttl=128 time=1.29 ms
64 bytes from 192.168.1.4: icmp_req=4 ttl=128 time=1.52 ms
64 bytes from 192.168.1.4: icmp_req=5 ttl=128 time=57.8 ms
64 bytes from 192.168.1.4: icmp_req=6 ttl=128 time=2.44 ms
^C
--- 192.168.1.4 ping statistics ---
6 packets transmitted, 6 received, 0% packet loss, time 5007ms
rtt min/avg/max/mdev = 1.299/11.339/57.839/20.801 ms
[/size][/color]

User avatar
AndyD
Posts: 2334
Joined: Sat Jan 21, 2012 8:13 am
Location: Melbourne, Australia
Contact: Website

Re: can't reach the internet

Fri Jan 10, 2014 10:29 pm

So, you are getting an IP address from your DHCP server and you are able to ping addresses on your local network, but cannot get a route to external addresses (including the google name server). Most of the home routers just work. So you are going to need to supply more information. What is your network setup? Are there other machines on the network and do they have problems connecting to the internet. Are you using a router?

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: can't reach the internet

Fri Jan 10, 2014 10:58 pm

What does
route -n
show

What's in /etc/network/interfaces?

If you're trying to set it up as static you need

Code: Select all

auto eth0
iface eth0 inet static
address 192.168.1.150 
netmask 255.255.255.0
gateway 192.168.1.1
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.

eng.happy
Posts: 14
Joined: Fri Jan 10, 2014 9:38 pm

Re: can't reach the internet

Sat Jan 11, 2014 7:13 am

@DougieLawson

this is the route -n reply

Code: Select all

pi@raspberrypi ~ $ route
Kernel IP routing table
Destination     Gateway         Genmask           Flags     Metric   Ref         Use     Iface
192.168.1.0     *                     255.255.255.0   U            0            0            0          eth0
when i changed it to static and put the static IPs ... it works fine and i reboot but come back to that problem again
but the only change is pinging google.com or 8.8.8.8 is returning the same reply

Code: Select all

connect: Network is unreachable

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

Re: can't reach the internet

Sat Jan 11, 2014 7:30 am

Your default gateway (route to the internet) isn't set.

The "route" command should give something like

Code: Select all

pi@raspberrypi ~ $ route
Kernel IP routing table
Destination     Gateway         Genmask           Flags Metric Ref    Use  Iface
default         192.168.1.1     0.0.0.0           UG    0      0      0    eth0
192.168.1.0     *               255.255.255.0     U     0      0      0    eth0
Just to test this (it should be set up automatically by DHCP, or specified in your /etc/network/interfaces as a "gateway 192.168.1.1" line)
edit: Hit submit instead of preview... oops
Try "sudo route add default 192.168.1.1" and then see if your internet connection works.

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: can't reach the internet

Sat Jan 11, 2014 9:22 pm

What's in /etc/network/interfaces?

We can fix the missing default route (temporarily) with
sudo route add default gateway 192.168.1.1
but that will disappear at the next reboot.
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.

eng.happy
Posts: 14
Joined: Fri Jan 10, 2014 9:38 pm

Re: can't reach the internet

Sun Jan 12, 2014 7:14 am

thank you all,,, it works now

i've tried

Code: Select all

sudo route add default 192.168.1.1
but it replies

Code: Select all

SIOCADDRT: No such device
so i tried

Code: Select all

sudo route add default gw 192.168.1.1
and it works fine :)[/color][/size]

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

Re: can't reach the internet

Sun Jan 12, 2014 8:30 am

Good, but now we have to find out why that doesn't get set automatically.

If you are using DHCP to get an IP address then the server or router that provides the IP address should also give the default gateway address.

If you are using a static IP defined in /etc/network/interfaces then you have to put a "gateway 192.168.1.1" line in the definition for the network interface. Normally this bit will look something like this

Code: Select all

auto eth0
iface eth0 iface static
    address 192.168.1.100
    netmask 255.255.255.0
    gateway 192.168.1.1
    nameservers 8.8.8.8
It may have "allow-hotplug eth0" instead of "auto eth0". This means pretty much the same thing in this case.

Perhaps if you can post the contents of your /etc/network/interfaces file?

eng.happy
Posts: 14
Joined: Fri Jan 10, 2014 9:38 pm

Re: can't reach the internet

Sun Jan 12, 2014 5:54 pm

i have changed the connection to hdcp before the problem is solved and it's now as shown

Code: Select all

auto eth0
iface eth0 iface hdcp
and before it was

Code: Select all

auto eth0
iface eth0 iface static
    address 192.168.1.100
    netmask 255.255.255.0
    gateway 192.168.1.1
the problem happens each time i restart the raspberry and i need to reset the default gateway[/color][/size]

drgeoff
Posts: 10765
Joined: Wed Jan 25, 2012 6:39 pm

Re: can't reach the internet

Sun Jan 12, 2014 7:39 pm

eng.happy wrote:i have changed the connection to hdcp before the problem is solved and it's now as shown

Code: Select all

auto eth0
iface eth0 iface hdcp
You'll have a much greater chance of success if you change 'hdcp' to 'dhcp'.

User avatar
AndrewS
Posts: 3625
Joined: Sun Apr 22, 2012 4:50 pm
Location: Cambridge, UK
Contact: Website

Re: can't reach the internet

Mon Jan 13, 2014 2:18 am

drgeoff wrote:You'll have a much greater chance of success if you change 'hdcp' to 'dhcp'.
Yeah, there's a big difference between Dynamic Host Configuration Protocol and High-bandwidth Digital Content Protection ;) :geek:
Gotta love all them acronyms :D

raginigupta6
Posts: 2
Joined: Thu Mar 02, 2017 10:29 am

Re: can't reach the internet

Thu Mar 02, 2017 10:36 am

Hi guys, I am facing a very similar issue with my RPi. I had tried connecting my RPi to both LAN and wifi, but in vain. I am able to ping other Raspberries in the local network but when i try to access the internet on my Pi it shows " this site can't be reached". I even tried the following two options:
1. setting up the static ip from /etc/ network/ interfaces
2. setting up the default gw using : sudo route default gw 192.168.1.1

However, the problem still persists.

Ernst
Posts: 1334
Joined: Sat Feb 04, 2017 9:39 am
Location: Germany

Re: can't reach the internet

Thu Mar 02, 2017 11:05 am

raginigupta6 wrote:Hi guys, I am facing a very similar issue with my RPi. I had tried connecting my RPi to both LAN and wifi, but in vain. I am able to ping other Raspberries in the local network but when i try to access the internet on my Pi it shows " this site can't be reached". I even tried the following two options:
1. setting up the static ip from /etc/ network/ interfaces
2. setting up the default gw using : sudo route default gw 192.168.1.1

However, the problem still persists.
Can we have more information?
Why are you not using dhcp ?

Code: Select all

ifconfig -a
route
The road to insanity is paved with static ip addresses

User avatar
RaTTuS
Posts: 10559
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: can't reach the internet

Thu Mar 02, 2017 11:09 am

read the interfaces file and then put it back as to what it was before
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

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: can't reach the internet

Thu Mar 02, 2017 10:45 pm

raginigupta6 wrote:Hi guys, I am facing a very similar issue with my RPi. I had tried connecting my RPi to both LAN and wifi, but in vain. I am able to ping other Raspberries in the local network but when i try to access the internet on my Pi it shows " this site can't be reached". I even tried the following two options:
1. setting up the static ip from /etc/ network/ interfaces
2. setting up the default gw using : sudo route default gw 192.168.1.1

However, the problem still persists.
Wow! Great Wheezy thread necro. Everything before your post is 100% irrelevant for Raspbian Jessie.
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.

Return to “Troubleshooting”