How do I turn off WLAN automatically when LAN is connected?

6,123

Solution 1

I think you might be making this harder than it has to be. I have the same situation with my laptop (except it's a normal ethernet port instead of a dock). When I plug in the wired network, it automatically takes precedence over the wireless and everything goes over the (faster) ethernet cord. The wireless was connected all along, but unused. When I unplug the cable it falls back to using the wireless connection.

So, have you tried to see if this does what you want already? I'm using nothing more than the standard network applet that comes with Ubuntu.

Solution 2

I'm also happily using a ThinkPad with a dock, but for me @Azendale's answer was not the case: after removing the laptop from the dock, internet connection would go down and required to reconnect WiFi to make it work.

So i googled up this solution and it works: https://superuser.com/a/367472/200497

As this question appears high in Google search results, i decided to share the link here.

Solution 3

If you are already using tlp for power management, it has a feature to do this.

You have to modify your conf file (/etc/default/tlp)

# Radio devices to enable/disable when docked.
#DEVICES_TO_ENABLE_ON_DOCK=""
DEVICES_TO_DISABLE_ON_DOCK="wifi wwan"

# Radio devices to enable/disable when undocked.
DEVICES_TO_ENABLE_ON_UNDOCK="wifi"
#DEVICES_TO_DISABLE_ON_UNDOCK=""
Share:
6,123

Related videos on Youtube

user1792605
Author by

user1792605

Updated on September 18, 2022

Comments

  • user1792605
    user1792605 almost 2 years

    I use my Thinkpad laptop with a docking station. The docking station is connected to my router via LAN. When I walk around the house I use my laptop with WLAN.

    Is it possible (and how) to manage these devices with a script or something to work like this:

    If a LAN-Connection is up, the OS should turn off Wifi and if LAN-Connection gets lost (undocking) Wifi should turn on automatically.

    I use Ubuntu 11.04 64bit with Gnome 2. The system works on an Lenovo ThinkPad R500 with.

    WLAN-Device: Intel Corporation PRO/Wireless 5100 AGN [Shiloh] LAN-Device: Broadcom Corporation NetLink BCM5787M Gigabit Ethernet PCI Express (rev 02)

    Any help would be appreciated. Thanks.

    • Admin
      Admin almost 13 years
      It should be possible to create a script for it, but keep in mind that you'll lost all existing network connections. Not nice if you've a SSH connection open, or are playing an online game. Most laptops have a keyboard shortcut (Fn + F11 on mine) or a switch on the front side for disabling wireless. Get in habit to use that shortcut / slide when connecting. Is there a requirement to turn wifi on automatically when disconnected from the wire? Technically, LAN counts for a wireless connection too. Wired connection is the right terminology here.
    • Admin
      Admin almost 13 years
      yes the requirement is, that I'm too lazy. ;-) and also yes: technically you wired connection may be the correct term.
  • user1792605
    user1792605 almost 13 years
    Thanks! I think I made things harder, than they have to be. I've tested that by copying a large file while being in docking station (Ethernet) and while being not (Wireless). And I think Ubuntu manages it correctly. Thanks for the hint!
  • datacarl
    datacarl almost 11 years
    You can use ifconfig and have a look at the last line with the RX/TX values, so you don't have to guess where the current traffic is going from the time, spent to transfer a large file.
  • THelper
    THelper almost 7 years
    It would still be useful to automatically turn wifi off, to reduce power consumption.