Linux – Setting Metric on Default Route in RedHat

linuxlinux-networkingredhat

I have a Redhat server with 4 virtual networks.

The problem is when the server is setting up the networks, the IP routes gets the wrong metrics on the default routes.

I have tried creating a file called route-ens3 in /etc/sysconfig/network-scripts that looks like

192.168.3.1 dev ens3 metric 99

But that does not help 🙁

So how can I setup the metrics on the default ip route?
Do I have to change the name for the networks, so it comes in the order I want the metrics, as it looks like that is the way it is ordered at the moment?

Best Answer

What version of Red Hat are you using? If it's RHEL 7 or 8 you can use a simple NetworkManager command (or GUI) to set the route metric. Take a look at man nm-settings for the "route-metric" value.

You probably want to do something like this:

# nmcli connection modify "ens3" route-metric 99

https://people.freedesktop.org/~lkundrak/nm-docs/nm-settings.html