I've got a device that is connected to one network via ethernet and a different network via wifi. I use netctl to manage the interfaces. When both netctl profiles are active, the configuration looks like this:
$ ip a
1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether b8:27:eb:eb:ab:dc brd ff:ff:ff:ff:ff:ff
inet 192.168.1.200/21 brd 192.168.7.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::ba27:ebff:feeb:abdc/64 scope link
valid_lft forever preferred_lft forever
3: wlan0: mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether b8:27:eb:be:fe:89 brd ff:ff:ff:ff:ff:ff
inet 10.10.0.89/23 brd 10.10.1.255 scope global noprefixroute wlan0
valid_lft forever preferred_lft forever
inet6 fe80::ba27:ebff:febe:fe89/64 scope link
valid_lft forever preferred_lft forever
$ route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.0.1 0.0.0.0 UG 0 0 0 eth0
0.0.0.0 10.10.0.1 0.0.0.0 UG 303 0 0 wlan0
10.10.0.0 0.0.0.0 255.255.254.0 U 303 0 0 wlan0
192.168.0.0 0.0.0.0 255.255.248.0 U 0 0 0 eth0
What I have noticed is that, when both netctl profiles are active, I can successfully ping a host (google.com) when I specify the ethernet interface, but pings fail when I specify the wifi interface:
$ ping -c4 -Ieth0 google.com
PING google.com (74.125.136.100) from 192.168.1.200 eth0: 56(84) bytes of data.
64 bytes from 74.125.136.100 (74.125.136.100): icmp_seq=1 ttl=44 time=21.4 ms
64 bytes from 74.125.136.100 (74.125.136.100): icmp_seq=2 ttl=44 time=21.3 ms
64 bytes from 74.125.136.100 (74.125.136.100): icmp_seq=3 ttl=44 time=21.10 ms
64 bytes from 74.125.136.100 (74.125.136.100): icmp_seq=4 ttl=44 time=37.1 ms
--- google.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 7ms
rtt min/avg/max/mdev = 21.317/25.440/37.086/6.729 ms
$ ping -c4 -Iwlan0 google.com
PING google.com (74.125.136.138) from 10.10.0.89 wlan0: 56(84) bytes of data.
--- google.com ping statistics ---
4 packets transmitted, 0 received, 100% packet loss, time 154ms
When I saw this behavior, I tried pulling out the ethernet cable, after which I still couldn't ping using wlan0, and I noticed that eth0 kept its IP address, gateway, etc. The only thing that changed was that it reported
state DOWN
rather than state UP
.
I then ran netctl stop my-ethernet-profile
to *actually* stop the profile for real, after which I *could* successfully ping from wlan0. So, ICMP isn't blocked on wlan0... everything seems fine when eth0's profile is actually stopped, just not when it's running (regardless of whether the interface is UP
or DOWN
).
So, I'm trying to understand a couple things:
1. Why would the wifi ping fail when both devices are connected (or, more accurately, when both netctl profiles are active)?
2. Why does the ethernet interface keep its configuration even if the system recognizes that it is not connected?
3. Is there a way to configure netctl to stop the profile if the interface goes down?
4. Is there a way to run an arbitrary script when the state transitions from UP
to DOWN
? For example, if I need to run netctl stop my-ethernet-profile
when the cable becomes disconnected?
As a final note, I know that there are ways to do a bonded interface or wifi failover, but this is for a very purpose-built situation. It may sound like I'm reinventing the wheel here, but there is a good reason.
Asked by maldata
(165 rep)
Apr 10, 2019, 04:06 PM
Last activity: Apr 10, 2019, 05:55 PM
Last activity: Apr 10, 2019, 05:55 PM