Script to auto-switch between multiple LAN adapters and WiFi on IGEL OS


Hi all, after 3 hours working on network stuff for a special industry customer who want to have more than 2 eth adapters with a bridge in IGEL OS I found by chance a solution for the long problem:

Learn more, read the entire thread inside the IGEL Community o Slack

Starting your device with wifi and plugin ethernet and you want that it changes automatically

Thats the solution:

1. the problem is based on the NetworkManager.conf which is saved here /etc/NetworkManager/NetworkManager.conf

this is the normal content of this file:

[main]

plugins=ifupdown,keyfile

no-auto-default=*

rc-manager=file

dhcp=dhclient

[ifupdown]

managed=false

[logging]

level=INFO

domains=HW,RFKILL,ETHER,WIFI,BT,MB,DHCP4,DHCP6,PPP,WIFI_SCAN,IP4,IP6,AUTOIP4,DNS,VPN,SHARING,SUPPLICANT,AGENTS,SETTINGS,SUSPEND,CORE,DEVICE,OLPC,WIMAX

2. you only need to change the line

managed=false with managed=true

3. I have copied the file to the UMS, changed it and placed it to one of my machines (see screenshot below)

4. Now you only need to use the known profile with the dispatcher.d/99-wlan script (another screeshot below)

cat <<“EOF” > /etc/NetworkManager/dispatcher.d/99-wlan

#!/bin/bash

exec 19> /tmp/99-wlan.log

export BASH_XTRACEFD=19

set -x

if [ “$1” = “eth0” -o “$1” = “eth1” ]; then

case “$2” in

up)

nmcli radio wifi off

;;

down)

nmcli radio wifi on

;;

esac

fi

EOF

chmod +x /etc/NetworkManager/dispatcher.d/99-wlan

5. finally it works again –> Starting the device with Ethernet and Wifi is off; plug off Ethernet –> Wifi is on; plugin Ethernet –> Wifi is off


Very cool … Please note the following line is missing the “c” for “cat” vs “at”.

at <<“EOF” > /etc/NetworkManager/dispatcher.d/99-wlan


Thanks @member I corrected it


@member See I read your post 😉

@member Would it work if you did a sed command to change “managed=false” with “managed=true” ?


Maybe but I dont want to use sed on system files. What is also working – copy a file from /wfs to the original location, there is no need for a transport from the UMS in this case. I think this is only a workaround. I have contacted PM and want to try to find out how we can fix this in the public release

what is awesome: this is also working with ICG

I tried with a notebook now with docking station, wifi and ethernet

first prio is eth0, second is docking and third is wifi


I think I had the same problem?! This is what I did

cat <<“EOF” >/etc/NetworkManager/dispatcher.d/99-wlan

wlanstate=`cat /config/net/interfacestate.wlan0`

if [ “$wlanstate” = down ]; then

nmcli radio wifi on

fi

if [ “$1” = “eth0” ]; then

case “$2” in

up)

nmcli radio wifi off

get_rmsettings

;;

down)

nmcli radio wifi on

get_rmsettings

;;

esac

else

nmcli radio wifi on

get_rmsettings

;;

fi

EOF

chmod +x /etc/NetworkManager/dispatcher.d/99-wlan


Was this working starting 11.05.100?

All my scripts was never working since 11.05.100


I only tested it with a 11.05.xxx 11.05.xxx FW, nothing older at least.


But like I see it is only changing between wifi and Eth0


That’s true.


with the managed=true you can change also between Eth0 and Eth1 in case of docking station


Iirc my problem was that if I had connected eth0 and had wifi configured, pulling of the eth0 did not connect the wifi. – so it’s not really related to your problem, maybe an add-on though 🙂


yes, I also had this often and your solution for this is also good stuff


Hi Lars, thanks a lot of that script.

Can you maybe add also LTE/5G connection? We ran in the past in this issue that our users where connected to 5G and also to the ethernet. The interface name is called “wwan0”.


Good idea

Continue reading and comment on the thread ‘ Script to auto-switch between multiple LAN adapters and WiFi on IGEL OS’.  Not a member? Join Here!

Learn more, search the IGEL Knowledge Base



Ask a question or comment on the above message thread?

Join or log in to the IGEL Community to ask us anything and meet other IGEL customers, partners, and EUC enthusiasts.

Submit a question, or Join Today!


Popular Message Threads


Categories & Tags: