Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set Network Interface Metric [closed]

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
like image 413
Thomas Hunter II Avatar asked May 15 '12 00:05

Thomas Hunter II


People also ask

How do I change network interface metric?

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.

How do I check NIC metric?

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.


1 Answers

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
like image 192
AlexT Avatar answered Sep 25 '22 10:09

AlexT