FS#41359 - [netctl] ExecDownPre lines do not run with netctl-ifplugd/netctl-auto

Attached to Project: Arch Linux
Opened by John (graysky) - Sunday, 27 July 2014, 07:53 GMT
Last edited by Jouke Witteveen (jouke) - Tuesday, 05 August 2014, 12:33 GMT
Task Type Bug Report
Category Arch Projects
Status Closed
Assigned To Jouke Witteveen (jouke)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 1
Private No

Details

I'm using a wireless/wired profile pair with netctl-ifplugd and netctl-auto. I'd like active sshd connections to get killed when the switch from wired to wireless or from wireless to wired takes place. I have a line in both profiles to do this, via ExecDownPre but it doesn't happen. Should I be using a different prefix since the wireless network is never actually taken down?

ls -l /etc/systemd/system/multi-user.target.wants/netctl*
lrwxrwxrwx 1 root root 44 Jul 24 16:09 netctl-auto@wlp4s0.service -> /usr/lib/systemd/system/netctl-auto@.service
lrwxrwxrwx 1 root root 47 Jul 24 16:11 netctl-ifplugd@enp0s10.service -> /usr/lib/systemd/system/netctl-ifplugd@.service

Wired profile:
# cat /etc/netctl/dhcp
Description='A basic dhcp ethernet connection'
Interface=enp0s10
Connection=ethernet
IP=dhcp
ExecUpPost='/usr/bin/ethtool -s enp0s10 wol g'
ExecDownPre='/usr/bin/pkill sshd'

Wireless profile:
# cat /etc/netctl/wireless
Description='A simple WPA encrypted wireless connection'
Interface=wlp4s0
Connection=wireless
Security=wpa
IP=dhcp
ESSID='mysiddgoeshere'
Key='mykeygoeshere'
ExecDownPre='/usr/bin/pkill sshd'


Additional info:
* package version(s) 1.8-1
This task depends upon

Closed by  Jouke Witteveen (jouke)
Tuesday, 05 August 2014, 12:33 GMT
Reason for closing:  Not a bug
Comment by Jouke Witteveen (jouke) - Sunday, 27 July 2014, 19:02 GMT
This should work. Does the journal (journalctl) contain anything useful?
Comment by John (graysky) - Sunday, 27 July 2014, 20:52 GMT
My goal is to have netctl connect to the WIRED interface as #1 priority. If the wired interface is unplugged, it should then connect to the WIRELESS interface automatically. I just noticed that netctl is not behaving correctly at all with my setup -- that is if I am understanding the wiki page on this functionality.[1]

I have both of these enabled:
netctl-auto@wlp4s0.service
netctl-ifplugd@enp0s10.service

What happens now on a boot up with the WIRED plugged in is netctl connects me to both the 'wireless' and the 'dhcp' (wired) profile at the same time. I can ssh into the wired IP address and open a 2nd term and ssh into the wireless IP address both assigned by my router. Do I have something incorrectly configured?

1. https://wiki.archlinux.org/index.php/Netctl#Automatic_switching_of_profiles
Comment by Jouke Witteveen (jouke) - Sunday, 27 July 2014, 21:23 GMT
The two services you mention work independently. If you want some kind of failover configuration, I think you need a bonding connection. I am no expert on those, but you're welcome to start a thread on the forums about your attempts and post a link here so that I can look into it if I have some time to spare.

The $ExecDownPre command should be called when you unplug your cable, or move out of the range of your wireless network. I presume it is?
Comment by John (graysky) - Sunday, 27 July 2014, 22:57 GMT
When I unplug the cable, and I am connected to that IP address, journalctl does show the link going down, but it does not show the killing of the sshd connection.

Link to discussion thread you requested that does not mention the kill issue but does focus on the wired vs wireless issue: https://bbs.archlinux.org/viewtopic.php?pid=1440595
Comment by John (graysky) - Monday, 28 July 2014, 20:02 GMT
I think netctl is not playing well with these two services. One service should take priority over the other (i.e. the wired profile controlled by netctl-auto).

Here is a good test case:
* Booting with the cable DISCONNECTED has just the wireless up, but booting with the cable CONNECTED has both interfaces up.
* Fresh boot with cable DISCONNECTED.
* I ssh'ed into the wireless IP address.
* Note that the wired network 'enp0s10' is DOWN and wireless 'wlp4s0' is UP:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
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
2: enp0s10: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
link/ether 01:2a:34:12:a9:b7 brd ff:ff:ff:ff:ff:ff
3: wlp4s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 01:12:42:29:21:ad brd ff:ff:ff:ff:ff:ff
inet 10.1.1.233/24 brd 10.1.1.255 scope global wlp4s0
valid_lft forever preferred_lft forever

* Now I plug the cable in and my ssh session that was connected via the wireless IP address is frozen.
* I can ssh into the wired IP address.
* I can no longer ssh into the wireless IP address BUT as you see, the interface is still UP. It should be DOWN I think.

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
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
2: enp0s10: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 01:2a:34:12:a9:b7 brd ff:ff:ff:ff:ff:ff
inet 10.1.1.105/24 brd 10.1.1.255 scope global enp0s10
valid_lft forever preferred_lft forever
3: wlp4s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 01:12:42:29:21:ad brd ff:ff:ff:ff:ff:ff
inet 10.1.1.233/24 brd 10.1.1.255 scope global wlp4s0
valid_lft forever preferred_lft forever

* If I reverse things, and reboot the machine with the cable CONNECTED, both interfaces are up and I can ssh into either IP address (wired or wireless).
* As you can see, both interfaces are UP.
* This should not be the case I think.
* The wired interface should have priority over the wireless.
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
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
2: enp0s10: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 01:2a:34:12:a9:b7 brd ff:ff:ff:ff:ff:ff
inet 10.1.1.105/24 brd 10.1.1.255 scope global enp0s10
valid_lft forever preferred_lft forever
3: wlp4s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 01:12:42:29:21:ad brd ff:ff:ff:ff:ff:ff
inet 10.1.1.233/24 brd 10.1.1.255 scope global wlp4s0
valid_lft forever preferred_lft forever
Comment by Jouke Witteveen (jouke) - Monday, 28 July 2014, 22:22 GMT
I think you misinterpret the purpose of netctl-auto and netctl-ifplugd. Their task is to automatically connect to profiles whenever possible. For wired interfaces this is done through netctl-ifplugd, for wireless interfaces this is done through netctl-auto. The two services are not supposed to interact.

What you want should be done through bonding. In case you just want to prioritize one network interface over the other, you should use metrics. The freezing of your SSH connection could indicate a routing misconfiguration.
Comment by John (graysky) - Tuesday, 29 July 2014, 00:37 GMT
Thanks for the suggestion and clarification. Can you advise me on how to proceed with a bonding setup with metrics? Over my head amd can't seem to find a good example configuration... Surely I am not the first to want this feature.
Comment by Jouke Witteveen (jouke) - Friday, 01 August 2014, 10:34 GMT
I believe you can get what you want by specifying a gateway with a (unique) metric in both profiles. The route with the lowest metric value 'wins'. I have never tried this, though.

As I am a bit busy at the moment, here is a collection of links that might help you:
https://wiki.archlinux.org/index.php/Netctl#Wired_to_wireless_failover
http://unix.stackexchange.com/questions/35713/adding-two-default-gateways-in-debian-interfaces-file (in netctl, there is the Routes= variable)
http://www.linuxhorizon.ro/iproute2.html
http://www.policyrouting.org/iproute2.doc.html#ss9.5
http://www.policyrouting.org/iproute2.doc.html#ss9.16

It is best to take this to the forums and open a new bug if there is room for improvement in netctl. This bug will be closed shortly.

Loading...