What is route metric?
The term metric as applied to networking, is used to assign priority to network routes. The higher the metric, the lower the priority of the route.
To set route metric for a specific route without NetworkManager
1. To add a route metric for a specific route, create or modify a route-[interface] file in the /etc/sysconfig/network-scripts/ directory where [interface] is the name of the interface the routes metric are related to. Each route should appear on a single line and take the basic form [network/prefix] via [gateway] [metric “value”] where [network/prefix] is the remote network’s address with prefix, [gateway] is the IP address of the next hop and [metric “value”] is a priority to a specific route. The higher the metric, the lower the priority of the route.
# cat /etc/sysconfig/network-scripts/route-[interface] 10.20.30.0/24 via 192.168.100.10 metric 200 10.0.1.0/24 via 192.168.10.20 metric 50
2. The interface must be brought up again for changes to take effect:
# ifup [interface]
To set route metric for a specific route with NetworkManager
1. To add a route metric for a specific route with nmcli, modify the connection’s ipv4.routes property. For example, to add a route metric 400 for a specific route on the connection named ens192:
# nmcli connection modify ens192 ipv4.routes "10.0.30.0/24 192.168.100.10 400"
2. To add additional routes with metric, use the + (plus) modifier on the connection’s ipv4.routes property:
# nmcli connection modify external +ipv4.routes "10.10.2.0/24 192.168.110.30 350"
3. After any of the modifications above, bring the connection up to put the changes into place:
# nmcli connection up ens192