JackElliott
Posts: 35
Joined: Wed May 03, 2017 11:57 pm

wlan0 not configured correctly?

Fri Jun 23, 2017 5:12 pm

Raspbian GNU/Linux 8 (jessie)

I've assigned a static IP address to eth0 and everything is working fine on that interface.

But wlan0 is not connecting right. It correctly fetches an IP address from the router (192.168.1.1), so DHCP is working. I can ping the router, but I can't ping 8.8.8.8

With wlan0 as the active interface:

Code: Select all

pi@FestiPi_2:~/mopower $ 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_seq=1 ttl=64 time=1.62 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=6.73 ms
64 bytes from 192.168.1.1: icmp_seq=3 ttl=64 time=4.39 ms
64 bytes from 192.168.1.1: icmp_seq=4 ttl=64 time=4.45 ms
^C
But:

Code: Select all

pi@FestiPi_2:~/mopower $ ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
From 192.168.7.10 icmp_seq=1 Destination Host Unreachable
From 192.168.7.10 icmp_seq=2 Destination Host Unreachable
From 192.168.7.10 icmp_seq=3 Destination Host Unreachable
^C
Seems like a gateway problem? But:

Code: Select all

pi@FestiPi_2:~/mopower $ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.7.1     0.0.0.0         UG    202    0        0 eth0
0.0.0.0         192.168.1.1     0.0.0.0         UG    303    0        0 wlan0
192.168.1.0     0.0.0.0         255.255.255.0   U     303    0        0 wlan0
192.168.7.0     0.0.0.0         255.255.255.0   U     202    0        0 eth0

routing:

Code: Select all

pi@FestiPi_2:~/mopower $ ip route
default via 192.168.7.1 dev eth0  metric 202 
default via 192.168.1.1 dev wlan0  metric 303 
192.168.1.0/24 dev wlan0  proto kernel  scope link  src 192.168.1.229  metric 303 
192.168.7.0/24 dev eth0  proto kernel  scope link  src 192.168.7.10  metric 202 
ifconfig shows (trimmed to wlan0 entry):

Code: Select all

wlan0     Link encap:Ethernet  HWaddr b8:27:eb:72:83:f8  
          inet addr:192.168.1.229  Bcast:192.168.1.255  Mask:255.255.255.0
That looks right.

and my /etc/network/interfaces:

Code: Select all

pi@FestiPi_2:~/mopower $ sudo cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)

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

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

iface eth0 inet manual

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

allow-hotplug wlan1
iface wlan1 inet manual
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
Ideas?

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

Re: wlan0 not configured correctly?

Fri Jun 23, 2017 6:08 pm

You can't have two default routes. If 192.168.1.1 is your route to the public internet, why are you sending your internet traffic to 192.168.7.1? You either need to lower the metric for wlan0 relative to eth0 or delete that default route through 192.168.7.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.

JackElliott
Posts: 35
Joined: Wed May 03, 2017 11:57 pm

Re: wlan0 not configured correctly?

Fri Jun 23, 2017 6:38 pm

DougieLawson,
Thank you. The Pi is sometimes wired into a LAN that uses a router at 192.168.7.1, and has a static IP address of 192.168.7.10. That should take precedence. So, fixed IP address and the gateway as shown.

When not plugged into that LAN, I want it to connect to any available wireless networks. So normal DHCP / wireless action there.

I honestly don't know why my settings are as weird as this.

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

Re: wlan0 not configured correctly?

Fri Jun 23, 2017 7:06 pm

Do both networks have an internet connection? Because network bonding isn't something that the average user would want to do.

Pick one interface that has the highest speed, lowest latency and make that the default route. You can do that in /etc/dhcpcd.conf or with a post-up script. By default a DHCP server will tend to announce itself as the default route when it configures any interface. If that isn't true then things will break (unless both interfaces are configured by the same DHCP server).
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.

JackElliott
Posts: 35
Joined: Wed May 03, 2017 11:57 pm

Re: wlan0 not configured correctly?

Sun Jun 25, 2017 2:17 pm

Thank you. I was away for a couple of days when my wife sprung a surprise camping trip on me.

I think I want the Pi to exhibit what I consider to be normal behavior for a laptop and, if I am not mistaken, for how the Pi normally runs when new.

The wired network takes precedence. There will only be one wired network this thing will be connected to, with gateway at 192.168.7.1, and with a static IP of 192.168.7.10. It works fine in that arrangement now.

If not connect to that wired network, then I want to be able to select from available wireless networks and let the Pi fetch an IP address from that network.

Except for wanting that one fixed IP address when connected to that one wired network, this is normal behavior for an out-of-the-box Pi (and any laptop I've ever owned), yes?

So I'm asking for help getting there. At the moment, the wired setup works fine. The wireless partially works: the wireless router assigns the Pi an IP address, and I can then ping the router, but it doesn't look like the Pi is looking to that router as the gateway. So I have something messed up.

How can I get from here to where I need to be?

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

Re: wlan0 not configured correctly?

Sun Jun 25, 2017 6:09 pm

That's all done in /etc/dhcpcd.conf with

Code: Select all

interface eth0
static ip_address=192.168.7.10/24
static routers=192.168.7.1
static domain_name_servers=192.168.7.1 8.8.8.8
the WiFi will look after itself when the eth0 isn't connected.
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.

JackElliott
Posts: 35
Joined: Wed May 03, 2017 11:57 pm

Re: wlan0 not configured correctly?

Sun Jun 25, 2017 8:42 pm

AND like magic, I can ping the internet with wlan0:

Code: Select all

wlan0     Link encap:Ethernet  HWaddr b8:27:eb:72:83:f8  
          inet addr:192.168.1.229  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::788f:aa02:9555:19e5/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:5523 errors:0 dropped:632 overruns:0 frame:0
          TX packets:6507 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:603531 (589.3 KiB)  TX bytes:1166055 (1.1 MiB)

pi@FestiPi_2:~ $ ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=58 time=29.0 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=58 time=32.2 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=58 time=32.0 ms
Thank you!

JackElliott
Posts: 35
Joined: Wed May 03, 2017 11:57 pm

Re: wlan0 not configured correctly?

Wed Jun 28, 2017 6:50 pm

But wait. The Pi is now connected to the wired network (router at 192.168.7.1) and eth0 now cannot ping the internet. It can ping the router. So previously I could ping internet using etho0 but not wlan0. I edited /etc/dhcpcd.conf as shown above (merely adding 8.8.8.8 to the static domain_name_servers line) and that fixed wlan0, but now eth0 is being difficult.

My goal is to use a static IP address when eth0 is connected to the 192.168.7.1 router, and let wlan0 act like you standard wireless adapter, letting me connect to any available hotspot and use it. At the moment, wifi is fine (can ping internet), eth0 cannot see internet (can ping router only).

Return to “Troubleshooting”