Open petefromcze opened 3 years ago
Unlike ifupdown the iface section with dhcp method ignores the metric option.
The isc-dhcp-client (/sbin/dhclient) supports custom metric by -e IF_METRIC=<value> option. In case of inet iface the change should be as easy as
-e IF_METRIC=<value>
inet
index ff6f770..8fc1f94 100644 --- a/ifupdown2/addons/dhcp.py +++ b/ifupdown2/addons/dhcp.py @@ -181,6 +181,7 @@ class dhcp(Addon, moduleBase): "inet", self.dhclientcmd.start, wait=wait, + metric=ifaceobj.get_attr_value_first('metric'), cmd_prefix=dhclient_cmd_prefix ) diff --git a/ifupdown2/ifupdownaddons/dhclient.py b/ifupdown2/ifupdownaddons/dhclient.py index c10db65..f8ef9fa 100644 --- a/ifupdown2/ifupdownaddons/dhclient.py +++ b/ifupdown2/ifupdownaddons/dhclient.py @@ -65,7 +65,7 @@ class dhclient(utilsBase): '%s' %ifacename] self._run_dhclient_cmd(cmd, cmd_prefix) - def start(self, ifacename, wait=True, cmd_prefix=None): + def start(self, ifacename, wait=True, metric=None, cmd_prefix=None): retries = 0 out = "0" @@ -88,6 +88,8 @@ class dhclient(utilsBase): '/run/dhclient.%s.pid' %ifacename, '-lf', '/var/lib/dhcp/dhclient.%s.leases' %ifacename, '%s' %ifacename] + if metric: + cmd.extend(['-e', 'IF_METRIC=%s' %metric]) if not wait: cmd.append('-nw') self._run_dhclient_cmd(cmd, cmd_prefix)
@petefromcze can you please submit your patch as a pull-request?
+1
Unlike ifupdown the iface section with dhcp method ignores the metric option.
The isc-dhcp-client (/sbin/dhclient) supports custom metric by
-e IF_METRIC=<value>
option. In case ofinet
iface the change should be as easy as