CentOS 7 Networking – How to Add Route with Metric in Network-Scripts

linux-networkingstatic-routes

On centos 7 server, I'd like to set the follow routes

172.22.55.0/26 via 10.1.1.6 dev eno5.xxx metric 100 
172.22.55.0/24 via 10.1.1.5 dev eno5.xxx metric 200

in the /etc/sysconfig/network-scripts/route-eno5.xxx file, how do I do that? This is an existing network setup which I cannot change and I cannot find any documentation that allows metric in the route file.

Best Answer

It should just be a case of adding the following into the route-eno.xxx file:

172.22.55.0/26 via 10.1.1.6 metric 100
172.22.55.0/26 via 10.1.1.5 metric 200

and then run ./ifup-routes in the /etc/sysconfig/network-scripts directory.

Also, you may want to check the subnet masks/cidr notation in your question as they appear to be different (that might be by design, just uncommon)

Related Topic