[CentOS] Static routes with a metric?

Matt Garman

matthew.garman at gmail.com
Wed Dec 7 18:03:37 UTC 2011


Hi,

How can I define static routes to be created at boot time with a specific
metric? I have two NICs that ultimately end up at the same peer, but
literally go through two completely different networks. IOW, each NIC
connects to a different layer 3 device.

Also, note that the machine actually has three total NICs: the third is the
owner of the default route. The two mentioned above are for a specialized
sub net.

What I basically need to be able to do is this:
route add -host h1 gw g1 metric 0
route add -host h1 gw g2 metric 10

Notice that everything is the same except the gateway and metric. I could
put this in /etc/rc.local, but was wondering if there's a cleaner way to do
it in e.g. the network-scripts directory.

Thanks,
Matt



More information about the CentOS mailing list