Linux : How to change default route metric

By | November 15, 2019

Under some rare circumstances, you may require to change the default route metric. The first way of doing should be through the “ifcfg-ethX” configuration file by adding the “METRIC=” statement.

However it has been found to be inefficient for me and had to apply it using “ip route” as followed :

ip route del default via <your.default.gateway.ip> dev <interface> proto static metric <current.metric>
ip route add default via <your.default.gateway.ip> dev <interface> proto static metric <new.metric>

Example :

ip route del default via 1.2.3.4 dev eth0 proto static metric 100
ip route add default via 1.2.3.4 dev eth0 proto static metric 90

You should now be able to see the result using the following command :

ip route