3

I want to configure guessnet and wpa_supplicant such that if I plug in my LAN cable, it connects to the network via the cable and if I unplug it, it automatically switches to WLAN and vice versa. I managed to make it work, however if I unplug the cable, it takes 10 to 20 seconds to connect to the WLAN network, which is pretty slow. In contrast, if I plug in the cable, it takes just a second to disconnect from WLAN and connect to LAN.

Is there any way to get a better configuration to make the switching to WLAN much faster?

By the way, when I tried new settings I often had to reboot, which was very annoying, a simple service networking restart was not enough - perhaps this has to do something with my configuration.

My system is Ubuntu 13.10. Here are my config-files:

/etc/network/interfaces

auto lo
iface lo inet loopback

#use guessnett
mapping eth0
        script /usr/sbin/guessnet-ifupdown
        #map timeout: 3
        map default: unknown


iface home inet static
      address 192.168.1.80
      netmask 255.255.255.0
      gateway 192.168.1.1
      dns-nameservers 192.168.1.1
      test1 peer address 192.168.1.1


iface no-net inet manual
      test2  missing-cable

iface unknown inet dhcp

iface wlanWork inet dhcp

auto wlan0
iface wlan0 inet manual
       wpa-roam  /etc/wpa_supplicant/wpa_supplicant.conf

And this is my /etc/wpa/supplicant.conf

ctrl_interface=/var/run/wpa_supplicant

eapol_version=1

ap_scan=1

network={
    ssid="mywlan"
    scan_ssid=1
    psk="1234"
    proto=RSN
    key_mgmt=WPA-PSK
    pairwise=CCMP
    group=CCMP
    id_str="home" ## specified in /etc/network/interfaces
}


network={
    ssid="wlanWork"
    scan_ssid=1
    psk="1234"
    proto=RSN
    key_mgmt=WPA-PSK
    pairwise=CCMP
    group=CCMP
    id_str="wlanWork" ## specified in /etc/network/interfaces
}

Finally this is /etc/default/ifplugd as generated by dpkg-reconfigure ifplugd

INTERFACES="eth0"
HOTPLUG_INTERFACES=""
ARGS="-q -f -u0 -d10 -w -I"
SUSPEND_ACTION="stop"

Edit I noticed some wired problems with this setup which I cannot reproduce. One time WLAN worked, but LAN didn't have the proper route/gateway. After setting the gateway manually via route add default gw 192.168.1.1 and rebooting, it worked again. After a second reboot nothing worked despite the fact that I got the correct IP (even ping 192.168.1.1 didn't work). Then I had to do sudo dhclient to get a working Internet connection again...

1 Answer 1

1

Try looking into route metrics. You should be able to sort this by inserting two default routes with different metrics to your routing table. Metrics are used to determine the cost of a route, a route with a lower cost is considered better and will be chosen over other higher cost path.

If you want your LAN-interface to be your primary route you assign it a lower metric than the WLAN one. This way you will always have the WLAN running, but will not used unless the LAN interface is unavailable.

You can use iproute2 to achieve this. iproute2

Your commands will look something similiar to:

ip ro add 0.0.0.0 0.0.0.0 via 192.168.1.1 dev eth0 metric 1
ip ro add 0.0.0.0 0.0.0.0 via 192.168.2.1 dev wlan metric 50

Dont forget to remove your preinstalled default route.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .