Prefer Ethernet over Wi-Fi automatically in Ubuntu (with NetworkManager)

Ethernet cables plugged in to a switch

Sometimes you do not need complex scripts or hacks. You just want Ubuntu to behave like a grown-up laptop: when Ethernet is plugged in, use it. When you unplug, fall back to Wi-Fi.

The good news: if you use NetworkManager (which Ubuntu does by default), you can solve this by adjusting connection priorities. No cronjobs, no dispatcher scripts, no extra packages.

What this does (and what it does not)

With connection priorities you are not “turning Wi-Fi off”. Instead, you are telling Ubuntu:

  • Ethernet should always be preferred when it is available.
  • Wi-Fi is still your backup connection.
  • When Ethernet disconnects, Wi-Fi can reconnect automatically.

This is perfect if you dock your laptop at home or at the office and you want a stable connection without thinking about it.

A real use case

My typical workflow looks like this:

  • Laptop on Wi-Fi while moving around the house, working from the couch, or grabbing coffee.
  • Then I drop it on a desk dock or plug in a cable for calls, uploads, or anything that benefits from stability.
  • Without priorities, the machine might keep Wi-Fi connected anyway (and sometimes even keep routing traffic through it resulting in slower connection speeds).
  • With priorities set, Ethernet takes over immediately, and I stop wondering why my “wired” connection still feels like Wi-Fi.

How to set it up

First, list your connection profiles:

nmcli connection show

Now set a low priority for your Wi-Fi connection:

nmcli connection modify "YOUR_WIFI_NAME" connection.autoconnect yes
nmcli connection modify "YOUR_WIFI_NAME" connection.autoconnect-priority -999

And set a high priority for your wired connection:

nmcli connection modify "YOUR_WIRED_NAME" connection.autoconnect yes
nmcli connection modify "YOUR_WIRED_NAME" connection.autoconnect-priority 999

If you want to apply it right away, reconnect:

nmcli connection down "YOUR_WIFI_NAME" 2>/dev/null
nmcli connection up "YOUR_WIRED_NAME"

Notes and tips

  • If you have multiple Wi-Fi profiles (home + office), repeat the Wi-Fi command for each profile.
  • These are just numbers: higher wins. I use 999 and -999 because it makes the intent obvious.
  • This keeps Wi-Fi available as a fallback, which is exactly what you want on a laptop.

The result

From now on, plugging in Ethernet becomes a silent upgrade. Ubuntu will prefer the wired network automatically, and when you unplug, Wi-Fi can take over without drama.

If you are like me and you want fewer surprises in your work setup, this is a tiny tweak that pays off every single day.

Share on Mastodon

About Marcel Bootsman

Marcel discovered the web in 1995. Since then he has paid attention to and worked with lots of technologies and founded his own WordPress oriented business nostromo.nl in 2009.

Currently Marcel is Partnerships & Community Manager EMEA at Kinsta. where he helps clients and partners grow with their business with Managed Hosting for WordPress.

You can contact Marcel on a diverse range of online platforms. Please see the Connect section on the homepage for the details.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *