Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I want to configure guessnet and wpa_supplicant such that if I plug in my LAN cable, it connect 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 hat 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...

share|improve this question

1 Answer 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.

I hope this helps!

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.