What is the proper way to set network interface metrics these days?
I'm looking for command line ways for doing this. I'm currently using Arch Linux, but a distro-agnostic method would be preferred.
Here is my failed attempt:
$ sudo ifconfig wlan0 metric 1
SIOCSIFMETRIC: Operation not supported
Right-click a network interface, and then select Properties. Click Internet Protocol (TCP/IP), and then select Properties. On the General tab, select Advanced. To specify a metric, on the IP Settings tab, clear the Automatic metric check box, and then enter the metric that you want in the Interface Metric field.
To check and change your network adapters' metric: 1. Open Command Prompt and type: route print - you will see a list of active routes, the last column displaying their "metric". Lower metric routes are preferred over higher ones.
As stated in man ifconfig, metric is not a supported option for the ifconfig command on Linux systems, because when the ifconfig command is processed it doesn't create a routing table entry.
metric N
This parameter sets the interface metric. It is not available under GNU/Linux.
To answer your question, you'd have to use the route command, to add the route with the desired metric and delete the old entry. For example:
sudo route add -net default gw 10.10.0.1 netmask 0.0.0.0 dev wlan0 metric 1
sudo route del -net default gw 10.10.0.1 netmask 0.0.0.0 dev wlan0 metric 0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With