Wicked nanny hot-switch wlan0 and eth0 configuration

Hello,

I’m trying to config my system to be able to “hot-switch” from eth0 to wlan0 when network wire is unplugged and from wlan0 to eth0 when network wire is plugged. However, after reading wicked documentation, it’s not clear for me how to do that using wicked nanny service (I supposed this is the correct way (using nanny), as official documentation explains). First of all, it’s necessary to start enabling wicked nanny events for both devices (I guess):


wicked nanny enable eth0
wicked nanny enable wlan0

If I understood this part of the instructions, now is time to add a policy for eth0 and wlan0 (“wicked nanny addpolicy whatever.xml”), as I see in /usr/share/doc/package/wicked/samples/nanny/ sample files:


eth-all.xml
umts.xml
wlan-eap.xml
wlan.xml

Thus, how could I config a policy for my above explanation? (I don’t understand the .xml samples really well)
I’m a little bit stuck now.
Thanks a lot!

What exactly “switch between eth0 and wlan0” should do?

I’m really sorry about my explanation, I mean “switch” from eth0 to wlan0 (integrated RPi3 wifi) when network wire is unplugged (just stop getting network connection from eth0 and start getting network from wlan0) and from wlan0 (integrated RPi3 wifi) to eth0 when network wire is plugged (just stop getting network connection from wlan0 and start getting network from eth0). Any “network switch” without reboot the system.

I hope I have improved my explanation…

Is it not enough to configure better route (better metric) via wired interface? In this case traffic should flow over it when it is plugged and when it is unplugged, route is removed anyway.

Yes, sure it could be enough. I mean, my systems use a gateway for wired connection and another gateway for wireless connection. But it will be an invalid situation if both route are enabled at the same time (eth0 must be the most priority), do you know what I mean? How could I configure it?

Kernel is expected to select the best route if several otherwise equal choices are available. So if wired interface comes up and sets route with better (lower) metric kernel should start using it.

How could I configure it?

If you get address and default gateway via DHCP, you should be able to set DHCLIENT_SET_DEFAULT_ROUTE and DHCLIENT_ROUTE_PRIORITY in interface configuration. The lower priority value, the most preferred is route. For static configuration set it in /etc/sysconfig/network/routes.

This is my ifcfg-eth0:


BOOTPROTO='dhcp4'
MTU=''
REMOTE_IPADDR=''
STARTMODE='onboot'
USE_DHCP='yes'
DHCLIENT_SET_DEFAULT_ROUTE='yes'
DHCLIENT_ROUTE_PRIORITY='1'

And ifcfg-wlan0:


BOOTPROTO='dhcp4'
STARTMODE='auto'
USE_DHCP='yes'
DHCLIENT_SET_DEFAULT_ROUTE='yes'
DHCLIENT_ROUTE_PRIORITY='10'

The best route is not being selected, let me explain my tests:
[ol]
[li]Boot only with wlan0[/li][LIST=1]
[li]IP and route for wlan0 correct[/li]```
eth0 Link encap:Ethernet HWaddr B8:27:EB:19:17:DC
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0 Kb) TX bytes:0 (0 Kb)

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:227 errors:0 dropped:0 overruns:0 frame:0
TX packets:227 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:31354 (30.6 Kb) TX bytes:31354 (30.6 Kb)

wlan0 Link encap:Ethernet HWaddr B8:27:EB:4C:42:89
inet addr:192.168.43.222 Bcast:192.168.43.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:475 errors:0 dropped:332 overruns:0 frame:0
TX packets:172 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:102776 (100.3 Kb) TX bytes:23193 (22.6 Kb)


Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 192.168.43.1 0.0.0.0 UG 10 0 0 wlan0
192.168.43.0 * 255.255.255.0 U 0 0 0 wlan0

 
[/ol]
  
[li]Plugged network wire[/li][ol]
[li]IP for eth0 correct and route too (but wlan0 route still shown and IP too)[/li]```
eth0      Link encap:Ethernet  HWaddr B8:27:EB:19:17:DC
          inet addr:10.70.64.34  Bcast:10.70.64.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:4205 errors:0 dropped:41 overruns:0 frame:0
          TX packets:327 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:274222 (267.7 Kb)  TX bytes:50151 (48.9 Kb)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:227 errors:0 dropped:0 overruns:0 frame:0
          TX packets:227 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1
          RX bytes:31354 (30.6 Kb)  TX bytes:31354 (30.6 Kb)

wlan0     Link encap:Ethernet  HWaddr B8:27:EB:4C:42:89
          inet addr:192.168.43.222  Bcast:192.168.43.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:475 errors:0 dropped:332 overruns:0 frame:0
          TX packets:172 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:102776 (100.3 Kb)  TX bytes:23193 (22.6 Kb)


Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         tr1-ctu-12h     0.0.0.0         UG    1      0        0 eth0
default         192.168.43.1    0.0.0.0         UG    10     0        0 wlan0
10.70.64.0      *               255.255.255.0   U     0      0        0 eth0
192.168.43.0    *               255.255.255.0   U     0      0        0 wlan0

[/ol]

[li]Unplugged network wire[/li][ol]
[li]Still IP for wlan0 but no network connection because route is wrong[/li]```
eth0 Link encap:Ethernet HWaddr B8:27:EB:19:17:DC
inet addr:10.70.64.34 Bcast:10.70.64.255 Mask:255.255.255.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:4205 errors:0 dropped:41 overruns:0 frame:0
TX packets:327 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:274222 (267.7 Kb) TX bytes:50151 (48.9 Kb)

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:227 errors:0 dropped:0 overruns:0 frame:0
TX packets:227 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:31354 (30.6 Kb) TX bytes:31354 (30.6 Kb)

wlan0 Link encap:Ethernet HWaddr B8:27:EB:4C:42:89
inet addr:192.168.43.222 Bcast:192.168.43.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:475 errors:0 dropped:332 overruns:0 frame:0
TX packets:172 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:102776 (100.3 Kb) TX bytes:23193 (22.6 Kb)


Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default tr1-ctu-12h 0.0.0.0 UG 1 0 0 eth0
default 192.168.43.1 0.0.0.0 UG 10 0 0 wlan0
10.70.64.0 * 255.255.255.0 U 0 0 0 eth0
192.168.43.0 * 255.255.255.0 U 0 0 0 wlan0

 
[/ol]
  
[li]If I plug network wire again it works but wlan0 never works again unless y run:[/li]```
wicked ifdown eth0
wicked ifup wlan0
wicked ifreload eth0

to reload route properly.
[/LIST]
What’s wrong with my config so it does not work properly automatically?

[/LIST]
Route is correct, the problem is that interface is not stopped. What ifplugstatus says when cable is connected and disconnected?

  • Cable connected:

lo: link beat detected
wlan0: link beat detected
eth0: link beat detected

  • Cable diconnected:

lo: link beat detected
wlan0: link beat detected
eth0: unplugged

Maybe the problem would be wlan0?

Why not just use NetworkManger.it handles both wired and wireless much easier then wicked :confused:

Our first systems were configured manually, the last were configured using NM and now our next systems will be configured, if possible, using wicked wich seems to be the future network manager in openSUSE.

If that’s not possible we will continue using NM, however we would like to make an effort to make it work using wicked before discard this solution in case.
Currently it is not working yet.

Thanks

Am Mon, 05 Dec 2016 11:26:02 GMT
schrieb dpatino82 <dpatino82@no-mx.forums.microfocus.com>:

> gogalthorp;2801198 Wrote:
> > Why not just use NetworkManger.it handles both wired and wireless much
> > easier then wicked :confused:
>
> Our first systems were configured manually, the last were configured
> using NM and now our next systems will be configured, if possible, using
> wicked wich seems to be the future network manager in openSUSE.
>
> If that’s not possible we will continue using NM, however we would like
> to make an effort to make it work using wicked before discard this
> solution in case.
> Currently it is not working yet.
>
> Thanks
>
>

In “ye olden days” you had ifup/ifdown implemented via a series of scripts and
using several “backend” programs.

Amongst others there was “ifplugd” and a script called “ifplugd-selectif”,
and it’s job was to check for STARTMODE=ifplugd and IFPLUGD_PRIOTITY=SOME_VALUE
and set up interfaces accordingly.

This was complicated, somehow slow, quite some overhead (starting several
scripts for one job) but in a way it worked quite well.

Now there is wicked, a framework to replace all of this old-fashioned stuff
by a nice, lean set of programs with the potential of even extending
functionality.

So far, so good, but there’s a little problem.

In order to replace all this you have to implement the same functionality,
otherwise your new solution will lack features which were already there (and
people might have used/relied on them),

If you read “man 5 ifcfg” you will not find anything about “ifplugd” nowadays,
and if you have a look at the template used to create that manual page, you
will find these comments:

…“TODO: rewrite ifplugd when nanny handles it correctly.
…”.TP
…".B ifplugd
…".br
…"The interface will be controlled from ifplugd. At initial ifup only ifplugd will
…"be started for this interface. Then if ifplugd detects a link if calls ifup
…“again which finally sets the interface up. See also variable
…”.B IFPLUGD_PRIORITY
…"below.

and

…“TODO: reintroduce when ifplugd supported
…”.TP
…".BR IFPLUGD_PRIORITY
…“If there multiple interfaces have
…”.B STARTMODE=ifplugd
…"and a nonzero priority, only one of them will be set up at a time. Every time one
…"of these interfaces is (un)plugged the interface with highest priority (and
…"plugged cable) will be set up. Default is IFPLUGD_PRIORITY=‘0’ causing set up as
…"when the cable is plugged. Note: This is not supported for e.g. bridge interfaces
…"or bridge ports.

So if you want to have this feature (back), you should write a bug report on
bugzilla.opensuse.org or create a feature request on github.com/opensuse/wicked
and hope you will get a response (regarding my last two bug reports on wicked,
iw wish you good luck for that).

AK

– Never attribute to malice that which can be adequately explained by
stupidity. (R.J. Hanlon)

Well, I’ve writtten a bug report for it and the answer is “this feature is currently not implemented”: Wicked hot-switch wlan0 and eth0 configuration · Issue #684 · openSUSE/wicked · GitHub
So from now on I’ll try to use NM. And we’ll see if I can properly config my system to use a hot-switching wlan0 & eth0 with it, if not I’ll try to configure it using a completely manual network config similar to my old system…

Thanks