How to set the route metric on network interface in CentOS 7

What is a Route Metric?

In networking, the term metric is used to assign priority to network routes. The lower the metric, the lower the route’s priority.

Set Route Metric Without Network Manager

Under Red Hat Enterprise Linux, the correct way to set the route metric is to edit the appropriate <ifcfg-interface> file in the /etc/sysconfig/network-scripts/ directory, where <interface> is the name of the interface to which the metric is related. A directive like the one below should be added.

METRIC=XXXX

For changes to take effect, the network service must be restarted.

# service network restart

Set Route Metric With Network Manager

To change the connection route Metric value, use nmcli, nmtui, or the GUI tools.

Modify the ipv4.route-metric property of the connection with nmcli to add a route metric. To add a route metric 600 to a connection named external, for example.

# nmcli connection modify external ipv4.route-metric 600

After any of the modifications above, bring the connection up to put the changes into place. For example, after having modified the properties of a connection named external.

# nmcli connection up external

Leave a Reply