Problem with ifupdown script

Marius Gedminas marius at pov.lt
Mon May 31 12:11:01 UTC 2010


On Sun, May 30, 2010 at 09:55:28PM +0200, Josef Wolf wrote:
> I want to configure my laptop to automatically use eth0 or wlan0 depending
> on whether the network cable is plugged or not.

This sounds like something Network Manager does quite well.

> I use traditional network configuration instead of NetworkManager because
> I configure my systems automatically with a system similar to cfengine,
> and networkmanager's interactive configuration doesn't play well with
> automatic configuration.

NetworkManager stores its system-wide configuration in plain-text config
files in /etc/NetworkManager/system-connections/

You can configure it once interactively and then manage those files
however you want.

> So I have put this into /etc/network/interfaces
> 
>   auto lo eth0 wlan0
>   iface lo inet loopback
>   
>   iface eth0 inet dhcp
> 
>   iface wlan0 inet dhcp
>   wpa-conf /var/cfsvn/conf/wpa_supplicant.conf
> 
> and installed ifplugd to configure/deconfigure eth0 when the cable is
> plugged/unplugged.

Actually, I'm not sure you can configure NetworkManager to bring down
wireless when the wired network is connected.

> Then, to configure/deconfigure wlan0, I decided to
> use the ifupdown mechanism:
> 
>   #! /bin/sh
>   # this is /etc/network/if-up.d/myifup
>   [ x$IFACE = xeth0 ] && ifdown --force wlan0
>   exit 0
> 
> 
>   #! /bin/sh
>   # this is /etc/network/if-down.d/myifup
>   [ x$IFACE = xeth0 ] && ifup --force wlan0
>   exit 0
> 
> The problem is that this mechanism works only every other time. When I
> unplug the cable and plug it again, it works. When I unplug/plug again,
> it doesn't work (wlan0 don't come up). Then I unplug/plug again and it
> works. Again unplug/plug and it don't work. and so forth.
> 
> Any ideas why wlan0 come up only every second time? Any hints?

Not really.

In the past I've often resorted to adding debug logging calls into my
if-*.d scripts (e.g. echo if-up script called >> /tmp/debug.log).

Marius Gedminas
-- 
Funny off-topic messages are always on-topic.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20100531/0e593dab/attachment.sig>


More information about the ubuntu-users mailing list