Page 1 of 1

can't reach the internet

Posted: Fri Jan 10, 2014 9:50 pm
by eng.happy
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]

Re: can't reach the internet

Posted: Fri Jan 10, 2014 10:29 pm
by AndyD
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?

Re: can't reach the internet

Posted: Fri Jan 10, 2014 10:58 pm
by DougieLawson
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

Re: can't reach the internet

Posted: Sat Jan 11, 2014 7:13 am
by eng.happy
@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

Re: can't reach the internet

Posted: Sat Jan 11, 2014 7:30 am
by rpdom
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.

Re: can't reach the internet

Posted: Sat Jan 11, 2014 9:22 pm
by DougieLawson
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.

Re: can't reach the internet

Posted: Sun Jan 12, 2014 7:14 am
by eng.happy
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]

Re: can't reach the internet

Posted: Sun Jan 12, 2014 8:30 am
by rpdom
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?

Re: can't reach the internet

Posted: Sun Jan 12, 2014 5:54 pm
by eng.happy
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]

Re: can't reach the internet

Posted: Sun Jan 12, 2014 7:39 pm
by drgeoff
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'.

Re: can't reach the internet

Posted: Mon Jan 13, 2014 2:18 am
by AndrewS
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

Re: can't reach the internet

Posted: Thu Mar 02, 2017 10:36 am
by raginigupta6
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.

Re: can't reach the internet

Posted: Thu Mar 02, 2017 11:05 am
by Ernst
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

Re: can't reach the internet

Posted: Thu Mar 02, 2017 11:09 am
by RaTTuS
read the interfaces file and then put it back as to what it was before

Re: can't reach the internet

Posted: Thu Mar 02, 2017 10:45 pm
by DougieLawson
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.