0

I have Raspbian Jessie in a Raspberry 3b. My test experiment is ping google.com, which I do when studying network. My configs in Raspberry in /etc/network/interfaces based on this thread but changed lan-ip to 192.169.1.0 (also tried 192.168.1.1)

iface eth0 inet static
address 192.168.1.0
netmask 255.255.255.0
gateway 192.168.1.254
broadcast 255.255.255.255

My Router settings (Firmware: DD-WRT v24-sp2 (01/04/15) std)

Router Model TPLINK WR1043ND V2 
WAN IPv4 10.10.11.59 
LAN IP 192.168.1.1 

I do ifconfig in Raspian and see that

eth0      Link encap:Ethernet  HWaddr b8:27:eb:af:7b:89  
          inet addr:192.168.1.0  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::ba27:ebff:feaf:7b89/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:10 errors:0 dropped:0 overruns:0 frame:0
          TX packets:58 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1851 (1.8 KiB)  TX bytes:10287 (10.0 KiB)

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:304 errors:0 dropped:0 overruns:0 frame:0
          TX packets:304 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:24096 (23.5 KiB)  TX bytes:24096 (23.5 KiB)

wlan0     Link encap:Ethernet  HWaddr b8:27:eb:fa:2e:dc  
          inet6 addr: fe80::ba27:ebff:fefa:2edc/64 Scope:Link
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:24 errors:0 dropped:24 overruns:0 frame:0
          TX packets:22 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:11676 (11.4 KiB)  TX bytes:4607 (4.4 KiB)

I did also sudo ip link set dev eth1 down and sudo dhclient eth1 but no positive result.

After GAD3R's proposal

I completed GAD3R's proposal. My ifconfig gives now

eth0      Link encap:Ethernet  HWaddr b8:27:eb:af:7b:89  
          inet addr:192.168.1.0  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::511d:2a5a:7049:4087/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:25 errors:0 dropped:0 overruns:0 frame:0
          TX packets:216 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:2298 (2.2 KiB)  TX bytes:43352 (42.3 KiB)

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:856 errors:0 dropped:0 overruns:0 frame:0
          TX packets:856 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:68368 (66.7 KiB)  TX bytes:68368 (66.7 KiB)

wlan0     Link encap:Ethernet  HWaddr b8:27:eb:fa:2e:dc  
          inet6 addr: fe80::ba27:ebff:fefa:2edc/64 Scope:Link
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:184 errors:0 dropped:184 overruns:0 frame:0
          TX packets:16 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:92808 (90.6 KiB)  TX bytes:3173 (3.0 KiB)

I do ping google.com unsuccessfully.

GAD3R's Addition

I change gateway from 192.168.1.1 to 192.168.0.1. Output of ifconfig

eth0      Link encap:Ethernet  HWaddr b8:27:eb:af:7b:89  
          inet addr:192.168.1.0  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::511d:2a5a:7049:4087/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:3 errors:0 dropped:0 overruns:0 frame:0
          TX packets:114 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:712 (712.0 B)  TX bytes:21781 (21.2 KiB)

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:384 errors:0 dropped:0 overruns:0 frame:0
          TX packets:384 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:31104 (30.3 KiB)  TX bytes:31104 (30.3 KiB)

wlan0     Link encap:Ethernet  HWaddr b8:27:eb:fa:2e:dc  
          inet6 addr: fe80::ba27:ebff:fefa:2edc/64 Scope:Link
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:309 errors:0 dropped:309 overruns:0 frame:0
          TX packets:22 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:158484 (154.7 KiB)  TX bytes:4345 (4.2 KiB)

I do ping google.com unsuccessfully.

DAP3R's 2nd Addition

I change address from 192.168.1.50 to 192.168.0.50 and broadcast from 192.168.1.255 to 192.168.0.255. Output of ifconfig

eth0      Link encap:Ethernet  HWaddr b8:27:eb:af:7b:89  
          inet addr:192.168.1.0  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::511d:2a5a:7049:4087/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6 errors:0 dropped:0 overruns:0 frame:0
          TX packets:107 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:850 (850.0 B)  TX bytes:21039 (20.5 KiB)

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:432 errors:0 dropped:0 overruns:0 frame:0
          TX packets:432 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:34464 (33.6 KiB)  TX bytes:34464 (33.6 KiB)

wlan0     Link encap:Ethernet  HWaddr b8:27:eb:fa:2e:dc  
          inet6 addr: fe80::ba27:ebff:fefa:2edc/64 Scope:Link
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:217 errors:0 dropped:217 overruns:0 frame:0
          TX packets:19 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:111112 (108.5 KiB)  TX bytes:4094 (3.9 KiB)

I do ping google.com unsuccessfully.

Output of roiama's answer

The command netstat -rn gives me

Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt 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
192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 eth0

instead of your one line of 192.168.1.1.0.... Pings

  • ping 192.168.1.2 where I get host unreachable
  • ping 192.168.1.1 like 0.3ms so within <10ms
  • ping 8.8.8.8 like 8ms so within <30ms
  • ping google.com successful with 8ms

How can you Connect Raspbian to Internet by Eth0?

  • 1
    Do you intend for your Pi to have a static IP address or (for now) can you grab one with DHCP from your router? It would "prove" that networking is possible and you can then move from that to a static configuration knowing you're going to win. – roaima Apr 4 '16 at 21:07
  • @roaima Yes, I can grap for now one IP with DHCP. Please, show you would do it. – Léo Léopold Hertz 준영 Apr 4 '16 at 21:10
2

You would be well advised to convert the Static configuration to DHCP until you have proven connectivity. (There are several faults in your configuration and a dynamic configuration would have avoided them all.)

iface eth0 inet dhcp

If this doesn't work you need to look at your local network before proceeding any further.


This is what you have for the at the moment:

iface eth0 inet static
address 192.168.1.0
netmask 255.255.255.0
gateway 192.168.1.254
broadcast 255.255.255.255

Host addresses for a 24-bit netmask go from 1 to 254. Zero and 255 are reserved, so your suggested address is "illegal". Change it from 192.168.1.0 to 192.168.1.2.

Your router's LAN address is 192.168.1.1 so this is what you need to declare here as your upstream gateway. Change it from 192.168.1.254 to 192.168.1.1.

The broadcast address must belong to the LAN, not to the world. Change it from 255.255.255.255 to 192.168.1.255.

Now restart the interface (or reboot your Pi). You should see two entries in your network table (netstat -rn), something like this:

Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt 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

You should also be able to ping places by address, but probably not by name. Try these tests as a starting point:

ping 192.168.1.2        # Should be <1ms response as this is you
ping 192.168.1.1        # Should be <10ms response as this is your router
ping 8.8.8.8            # Expect ~30ms response as this is a Google node on the Internet

If, and only if, this all works you can proceed to the configuration of your nameserver, which translates names to IP addresses. (These would also normally be assigned via DHCP.) Either configure this as your router's address or, if you must, choose one or two upstream servers. Create the file /etc/resolv.conf containing the single line nameserver 192.168.1.1.

Note: if the file has a warning about the file being overwritten, delete it first and then recreate it.

  • I have two lines of 192.168.1.0... in netstat -rn. I updated the body. Is everything ok to proceed for etc/resolv.conf? – Léo Léopold Hertz 준영 Apr 5 '16 at 6:46
  • 1
    @Masi you've got Internet connectivity to 8.8.8.8 so yes do proceed. – roaima Apr 5 '16 at 10:18
  • I just did sudo touch /etc/resolv.conf and the line nameserver 192.168.1.1 was automatically added to the file. It seems that dhcp is controlling the file carefully. – Léo Léopold Hertz 준영 Apr 10 '16 at 15:21
  • 1
    @Masi if you're happy with DHCP then this is enough. Otherwise follow the tail end of my instructions, starting with "delete [or rename] the file..." – roaima Apr 10 '16 at 16:56
1

edit /etc/network/interfaces like:

auto lo
iface lo inet loopback

auto eth0
allow-hotplug eth0
iface eth0 inet static
address 192.168.1.50
netmask 255.255.255.0
gateway 192.168.1.1
broadcast 192.168.1.255

Save an exit

Then type the following command:

sudo rm /var/lib/dhcp/*

Reboot your system

to bring up your interface eth0 type :

sudo ip link set eth0 down
sudo ip link set eth0 up
  • I completed your proposal. I added the output of ifconfig in the body. Still, no successful ping to google. Why did you choose to set address to 192.168.1.50? Why particularly 50? – Léo Léopold Hertz 준영 Apr 4 '16 at 20:00
  • 1
    What is the exact internal IP of the router? according to setuprouter.com/router/linksys/dd-wrt-v24-sp2/login.htm may be 192.168.0.1 Please change the gateway from 192.168.1.1 to 192.168.0.1 – GAD3R Apr 4 '16 at 20:17
  • 1
    from your router setting you can choose the ip adress e,g: DHCP IP Address Range by default is from 50 to 199 you can modify the default settings but do not use the Gatway IP. – GAD3R Apr 4 '16 at 20:26
  • See the body. Still unsuccessful ping to google after the change of gateway to 192.168.0.1. – Léo Léopold Hertz 준영 Apr 4 '16 at 20:32
  • 1
    change address from 192.168.1.50 to 192.168.0.50 and broadcast from 192.168.1.255 to 192.168.0.255 – GAD3R Apr 4 '16 at 20:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.