2

My HTPC has a wireless and a wired connection. When I start ubuntu both get an IP-adress. I don't see any inherent problem with this, but XBMC seems to default to the wireless, even if the wired is available.

How can I force precedence of the wired connection above the wireless?

  • I'm not looking to shutdown/disable the wireless: I do use both, but not at the same time per se.
  • There shouldn't be any interaction for this, as I don't have a keyboard connected. Currently I ssh to the box to shut down wireless manually if needed, but that's ridiculous :)

Basically what I expected was that when the wired connection gets an IP, the wireless releases it's connection, and as soon as the wired IP is gone, wireless comes in again. But that doesn't seem to happen :(

1 Answer 1

3

You can create a script and put it in the /etc/NetworkManager/dispatcher.d folder; the scripts in that folder will be executed every time a connection is (dis)established. The number with which you start the filename determines the order of execution, so we will give our script the number 99 to make sure that it is executed last.

Run the following command in a terminal

gksudo gedit /etc/NetworkManager/dispatcher.d/99-wlan

then copy the following, save and close.

#!/bin/bash

if [ "$1" = "eth0" ]; then
    case "$2" in
        up)
            nmcli nm wifi off
            ;;
        down)
            nmcli nm wifi on
            ;;
    esac
fi

you should replace "eth0" with your network device (e.g., the one you see when you type ifconfig. it could be "eth1" for instance).

Make the script executable by running

sudo chmod +x /etc/NetworkManager/dispatcher.d/99-wlan

Now if a wired connection is established the wireless will be turned off, if the wired connection is disestablished the wireless will be turned back on.


Acknowledgment: credit to this superuser answer,

You must log in to answer this question.

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