How to Set USB Ethernet Interface Connection Priority in Ubuntu

Abstract: Resolve unpredictable network routing in Ubuntu by setting lower Netplan metrics for USB Ethernet to prioritize it over Wi-Fi or internal adapters.

Created: 2026-08-01 by

Set USB Ethernet priority in Ubuntu by editing the Netplan configuration file to assign a lower metric value to the desired interface. This ensures the system routes traffic through the USB adapter over other connections like Wi-Fi or internal Ethernet. The change requires applying the configuration and verifying the active route.

Understanding Network Metrics

In Linux networking, the kernel uses a routing table to determine which network interface handles outgoing traffic when multiple connections are active. Each route has a "metric," which acts as a cost indicator. The route with the lowest numeric metric is preferred. By default, interfaces often receive similar metrics, leading to unpredictable behavior where the system might switch between Wi-Fi and wired connections arbitrarily. To prioritize a specific USB Ethernet interface, you must manually adjust this metric in your Netplan configuration. Lower numbers indicate higher priority. For example, setting a metric of 100 for the USB adapter and 200 for Wi-Fi forces the OS to use the USB connection for general internet access unless it fails. This method is robust because it works at the kernel level, independent of desktop environment settings.

Identifying Your Interface Names

Before modifying any configuration files, you need to know the exact name of your USB Ethernet adapter. Modern Linux systems use predictable naming conventions, but USB adapters can sometimes have dynamic names depending on the port used. Open a terminal and run the following command to list all network interfaces along with their current status:
ip link show
Look for an interface that corresponds to your USB dongle. It might be named something like enx78e5d9ea46f1 (based on the MAC address) or usb0. You can also check the output of nmcli device status if you are using NetworkManager alongside Netplan. Note the exact interface name, as you will need to replace placeholder names in the configuration steps below.

Configuring Netplan for Priority

Ubuntu uses Netplan to generate network configurations. The configuration files are typically located in the /etc/netplan/ directory. There is usually one YAML file there, such as 00-installer-config.yaml or 50-cloud-init.yaml. Open this file with a text editor using sudo privileges:
sudo nano /etc/netplan/*.yaml
The structure of a Netplan config involves defining each network interface under the network key. You need to locate the section for your USB Ethernet interface and add or modify the metrics parameter. If the interface is not yet defined, you may need to add it entirely. Here is an example structure where we prioritize the USB interface named enp0s20u1:
network:
  version: 2
  ethernets:
    enx78e5d9ea46f1:  # Replace with your actual USB interface name
      dhcp4: true
      metrics: 100
    wlp2s0:            # Example Wi-Fi interface
      dhcp4: true
      metrics: 200
In this example, the USB interface has a metric of 100, while the Wi-Fi interface has 200. Since 100 is lower, the USB connection will be the primary route. Ensure that indentation is correct; YAML is sensitive to whitespace. Use spaces, not tabs. If you are connecting via DHCP, the dhcp4: true line remains essential. The metrics line is added directly under the interface definition. Do not add it inside the dhcp4 block.

Alternative: Using Static IP

Some users prefer static IP addresses for critical servers. If you are using a static configuration, the process is identical. Locate the addresses block for the interface and add the metrics field at the same level as addresses and gateway4 (if applicable).
    enp0s20u1:
      addresses: [192.168.1.10/24]
      gateway4: 192.168.1.1
      nameservers:
        addresses: [8.8.8.8, 1.1.1.1]
      metrics: 100
This approach ensures that even if the DHCP server assigns different parameters, your local priority rules remain intact.

Applying and Verifying Changes

Once you have saved the Netplan configuration file, you must apply the changes. Run the following command to validate the syntax and apply the new routing rules:
sudo netplan apply
If there are syntax errors in your YAML file, this command will report them. Fix any issues and try again. After successful application, verify that the USB interface is indeed the primary route. Use the ip route command to view the routing table:
ip route show
Look for the default route (default via ...). The interface listed next to the preferred default route should match your USB adapter. You can also check the metric associated with the route:
ip route show | grep default
The output will show the metric value. If you see metric 100 for the USB interface and metric 200 for others, your configuration is working correctly.

Testing Connectivity

To ensure the system is actually using the USB connection, try pinging an external host like Google DNS:
ping 8.8.8.8
While ping does not explicitly show the interface, you can monitor the interface statistics with ip -s link while downloading data. The USB interface should show increasing byte counts if it is handling the traffic. For more details on managing network interfaces, you might find our guide on Preventing Ubuntu from Trying to Autoconnect to New Wi-Fi Networks helpful for further control over connection preferences. Additionally, understanding how IPv6 interacts with these settings can prevent unexpected routing loops, as discussed in Interface-Specific IPv6 Forwarding Configuration Effect on Ubuntu 22.04.

Frequently Asked Questions

What happens if two interfaces have the same metric?

If multiple interfaces share the same metric, the kernel uses a tie-breaking algorithm based on interface index or administrative distance. This can lead to unstable routing where traffic jumps between interfaces. Always ensure your preferred interface has a strictly lower metric than secondary connections.

Can I set the metric dynamically after boot?

Yes, you can change the metric of an existing route using the ip route change command. However, this change will revert after a reboot unless you update the Netplan configuration file. For persistent changes, always edit the YAML files in /etc/netplan/.

Does this work on older Ubuntu versions without Netplan?

Netplan was introduced in Ubuntu 17.10. If you are running a very old LTS version like 16.04, you likely use ifupdown or NetworkManager directly. In those cases, you would configure metrics in /etc/network/interfaces or via NetworkManager's GUI settings, not Netplan.

Will changing the metric break my internet connection?

No, changing the metric only affects which interface is chosen when multiple are active. It does not disable the interface or alter its IP configuration. If the USB adapter is disconnected, the system will automatically failover to the next available route with the next lowest metric.

How do I reset to default metrics?

To remove custom metrics, simply delete the metrics: line from your Netplan YAML file and run sudo netplan apply. The system will then assign default metrics, which are typically determined by the interface type and driver.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More