10 Sep 2008 • 1 min read

You tag something with a metric. The same somethings with a lower metric take precedence over the same somethings with a higher metric.

dhcpcd has been able to apply metrics to routes on Linux so that we can prefer to route packets over wired instead of wireless. dhcpcd-git is now able to distinguish wired from wireless and can make a metric accordingly.

But how do we teach configuration files about this? Well, dhcpcd-git has an environment variable sent to each script telling it about the preferred order of interfaces (based on carrier, if we have a lease or not and metric). This works well, and we can now prefer wired nameservers over wireless ones in /etc/resolv.conf. Well, we can at least put them first in the list.

Whilst doing this, it struct me that resolvconf has no means of preferring configurations other than a static interface-order file. This is not good for automatic foo! So openresolv now understands the -m <metric> option and the IF_METRIC environment variable so it can tag resolv.confs by priority. If no metric is specified, it takes priority. If >1 interface on the same metric then we take lexical order.