Using ifup/down with local Lan and Wireless
Wonko| Mon 23 August 2010I have a Notebook sitting in the living room. Its mostly for reading Mails/Blogs, checking the Weather. Occasionally I hook it up to the TV to watch Movies. Here's where the trouble starts: To do that I connect the Notebook to a Physical Network for Bandwidth reasons. The Movies sit on a NAS. I configured the Notebook to be on IfUp/-Down in contrast to using Networkmanager since It will only connect to one pre-configured Wireles LAN. This way I am able to remotely connect to the Notebook even though nobody is logged in. The NM will only connect on login. My FritzBox hands out IP-Addresses from the same Subnet to all Clients on WLAN and LAN. This causes troubles when the Notebook is connected to the Physical LAN. The WLAN and LAN interface compete to be the default gateway. After plugging in the routing gets mixed up and I loose connection. The solution is easy: Tell ifplugd to switch off the other Card on Ifup. In Yast I configured the Devices to be started on cable connect. This changes the /etc/sysconfig/network/ifcfg-eth0 and ifcfg-wlan0 files to : ... STARTMODE='ifplugd'... Then I changed the Script /etc/ifplugd/ifplugd.action. The script is called whenever a change in connection is detected by ifplugd. Its called with the Device (et0/wlan0) as \$1 and the command (up/down) as \$2. My change simply Downs the respective "other" Interface: ...[ "$1" = eth0 ] OTHER = wlan0 [ "$1" = wlan0 ] OTHER = eth0 [ "$2" = "up" ] && exec /sbin/ifup $1 -o ifplugd && exec /sbin/ifdown $OTHER [ "$2" = "down" ] && exec /sbin/ifdown $1 -o ifplugd && exec /sbin/ifup $OTHER ... I only tested this on OpenSuse 11.3 but I think it will work with most other Distros that have ifplugd,