Linux : How to change default route metric
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 :
1 2 |
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 :
1 2 |
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 |