Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 :(

share|improve this question
up vote 3 down vote accepted

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.


if [ "$1" = "eth0" ]; then
    case "$2" in
            nmcli nm wifi off
            nmcli nm wifi on

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,

share|improve this answer

Your Answer


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.