carilwang
Posts: 8
Joined: Fri Dec 06, 2013 1:19 am

static ip doesn't have internet access

Fri Oct 16, 2015 6:45 pm

I don't get internet access, even ping gateway doesn't work, and ssh into it take long time
here is my /etc/network/interfaces

Code: Select all

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 192.168.8.21
netmask 255.255.255.0
network	192.168.8.0
broadcast 192.168.8.255
gateway 192.168.8.1
ifconfig

Code: Select all

eth0      Link encap:Ethernet  HWaddr b8:27:eb:75:ba:8b  
          inet addr:192.168.8.21  Bcast:192.168.8.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:86519 errors:0 dropped:0 overruns:0 frame:0
          TX packets:43711 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:120471080 (114.8 MiB)  TX bytes:3425212 (3.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:106 errors:0 dropped:0 overruns:0 frame:0
          TX packets:106 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:9328 (9.1 KiB)  TX bytes:9328 (9.1 KiB)
route -n
Kernel IP routing table

Code: Select all

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.8.1     0.0.0.0         UG    0      0        0 eth0
192.168.8.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0
It has been like that for couple months, I have to use static dhcp to get static ip. Does anyone know what is going on.

I am using raspbian

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: static ip doesn't have internet access

Fri Oct 16, 2015 7:36 pm

Delete the lines

Code: Select all

network   192.168.8.0
broadcast 192.168.8.255
they aren't needed.

Are you sure that 192.168.8.1 is your gateway router address? Check on a system that's working or check what you get if your RPi is re-configured to use DHCP.
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.

carilwang
Posts: 8
Joined: Fri Dec 06, 2013 1:19 am

Re: static ip doesn't have internet access

Fri Oct 16, 2015 8:49 pm

I am very sure those two line is not a problem

here is the ifconfig for the dhcp

Code: Select all

eth0      Link encap:Ethernet  HWaddr b8:27:eb:0a:31:d1  
          inet addr:192.168.8.245  Bcast:192.168.8.255  Mask:255.255.255.0
          inet6 addr: fe80::ba27:ebff:fe0a:31d1/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:3090528 errors:0 dropped:0 overruns:0 frame:0
          TX packets:146750 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:157797933 (150.4 MiB)  TX bytes:18156754 (17.3 MiB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:88 errors:0 dropped:0 overruns:0 frame:0
          TX packets:88 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:8857 (8.6 KiB)  TX bytes:8857 (8.6 KiB)
and the route -n

Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.8.1 0.0.0.0 UG 0 0 0 eth0
192.168.8.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0

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: static ip doesn't have internet access

Fri Oct 16, 2015 9:27 pm

So when you switch back to a static address can you try
ping -c3 192.168.8.1
ping -c3 8.8.8.8
ping -c3 google.com


Those two lines are 100% pointless, with a known address, gateway and netmask your system can calculate the network ID and the broadcast address (and it will always get the right answer).
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
rpdom
Posts: 17173
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: static ip doesn't have internet access

Sat Oct 17, 2015 4:54 am

Hang on... your interfaces file says

Code: Select all

address 192.168.8.21
but your ifconfig shows

Code: Select all

          inet addr:192.168.8.245
perhaps you are getting a dhcp address instead/as well and that is messing things up?

This has been happening since the decision to drop support for interfaces and move to dhcpcd5 instead. You may need to either tell dhcpcd5 (if it is installed) to let interfaces handle eth0, or set your static address there instead (/etc/dhcpcd.conf) http://manpages.debian.org/cgi-bin/man. ... hcpcd.conf
Look at either "deny interfaces", or "static value" in that man page.

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: static ip doesn't have internet access

Sat Oct 17, 2015 7:25 am

With the new raspberrypi-net-mods you CAN NOT set static addresses in /etc/network/interfaces.

You MUST have this

Code: Select all

# Please note that this file is written to be used with dhcpcd.
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'.

auto lo
iface lo inet loopback

auto eth0
allow-hotplug eth0
iface eth0 inet manual

auto wlan0
allow-hotplug wlan0
iface wlan0 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

auto wlan1
allow-hotplug wlan1
iface wlan1 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
in your interfaces file.

The place to set your static address is in /etc/dhcpcd.conf by adding this

Code: Select all

interface eth0
static ip_address=192.168.0.10/24
static routers=192.168.0.1
static domain_name_servers=192.168.0.1
to the bottom of that file.
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”