Posts: 2
Joined: Wed Mar 28, 2018 11:55 am

[SOLVED] ssh connection (eth0) lost when wlan0 gets static IP

Fri Jul 13, 2018 8:15 pm

Short description:
RPI ssh connection over ethernet is lost when wlan0 is not connected AND set to a static IP

Steps to reproduce:
1. Login to pi via ssh (eth0)
2. $ sudo ifconfig wlan0 (edit: same range as eth0 ip, but not the same)
3. verify that ssh locks up.
4. on a terminal on the pi:
4a. $ping (ok)
4b. $ping (fails)
4c. route (hangs)
4d. sudo ifconfig wlan0 0 (on a terminal on the pi)
5. ssh session continues
6. $ route (works)

Just me, or anyone experienced the same?

It seems that 'ifconfig address x' adds -as a side effect- a new entry with 'metric 0' in the routing table, while the default metric is 202. Hence, the new entry acquires priority over the eth0 route.
Setting the static ip using 'ip address add dev wlan0' does not have this side effect.

Actually the equivalent iproute2 command is 'ip address add dev wlan0', which does change the routing table, however using 'ip address add dev wlan0 noprefixroute' prevents this.

Linux raspberrypi 4.14.50-v7+ #1122 SMP Tue Jun 19 12:26:26 BST 2018 armv7l GNU/Linux
/boot/cmdline: dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=PARTUUID=bae958df-02 rootfstype=ext4 elevator=deadline ipv6.disable=1 rootwait
systemd-resolved: inactive (using resolvconf for /etc/resolv.conf, nameserver set by dhcpcd)

Revision: a020d3 (RPI 3B+)

Return to “Raspbian”