It's not too uncommon to have two public network interfaces, and to prefer one over another. The primary example is a laptop with both ethernet and wireless. ifplugd is good for managing the interfaces, but it has no means of doing anything with the default route. dhcpcd normally installs a default route for the interface, but does not have a means for setting the route metric/preference. The folllowing patch add the -m routemetric option to dhcpcd, which allows you to set the route metric when it creates the default route. Then you can do stuff like this in /etc/conf.d/net: dhcpcd_eth0="-m 1" # ethernet dhcpcd_eth1="-m 2" # wireless eth0 is then used as the default route; if eth0 is down, then eth1 is used: # ip route 198.137.24.0/24 dev eth1 proto kernel scope link src 198.137.24.187 128.192.120.0/22 dev eth0 proto kernel scope link src 128.192.123.45 127.0.0.0/8 dev lo scope link default via 128.192.120.1 dev eth0 default via 198.137.24.1 dev eth1 metric 1 Note that dhcpcd normally uses a metric of 1 or 0; therefore the patch uses a default (and minimum) value of 1, and in certain cases, reduces the metric by 1. You can see this in the example ip route output above. If -m is not supplied, you keep the default behavior. Two attachments to follow.
Created attachment 47661 [details, diff] dhcpcd-1.3.22_p4-routemetric.diff Patch to enable -m routemetric option
Created attachment 47662 [details, diff] dhcpcd.ebuild.diff Patch to ebuild (-r7) to apply routemetric patch against
what is the origin of the route metric patch? did you write it yourself? (once burned on patch licenses, twice shy...).
I wrote this patch myself, and consider it too trivial to consider anything other than public domain.
Fixed in -r8 Thanks Andy!
*** Bug 98852 has been marked as a duplicate of this bug. ***