dhclient doesn't honor metric setting in network interfaces on ubuntu 16.04

Bug #1662814 reported by Randy
22
This bug affects 5 people
Affects Status Importance Assigned to Milestone
isc-dhcp (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.1 LTS"

$ dpkg-query -l isc-dhcp-client
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-================================================================-=====================================-=====================================-======================================================================================================================================
ii isc-dhcp-client 4.3.3-5ubuntu12.6 amd64 DHCP client for automatically obtaining an IP address

# configure metric in network interface
$ cat /etc/network/interfaces.d/ens4.cfg
auto ens4
iface ens4 inet dhcp
  metric 1000

# dhclient set IF_METRIC=1000 environment variable for ens4
$ ps xau|egrep -i 'dhclient'
root 27906 0.0 0.0 16120 864 ? Ss 08:35 0:00 /sbin/dhclient -1 -v -pf /run/dhclient.ens3.pid -lf /var/lib/dhcp/dhclient.ens3.leases -I -df /var/lib/dhcp/dhclient6.ens3.leases ens3
root 28392 0.0 0.0 16120 868 ? Ss 08:59 0:00 /sbin/dhclient -1 -v -pf /run/dhclient.ens4.pid -lf /var/lib/dhcp/dhclient.ens4.leases -I -df /var/lib/dhcp/dhclient6.ens4.leases ens4 -e IF_METRIC=1000

$ route -nee
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface MSS Window irtt
0.0.0.0 xxx.xxx.xxx.xxx 0.0.0.0 UG 0 0 0 ens3 0 0 0
xxx.xxx.xxx.xxx 0.0.0.0 255.255.255.192 U 0 0 0 ens3 0 0 0
172.16.0.0 192.168.12.1 255.240.0.0 UG 0 0 0 ens4 0 0 0
192.168.0.0 192.168.12.1 255.255.0.0 UG 0 0 0 ens4 0 0 0
192.168.12.0 0.0.0.0 255.255.255.0 U 0 0 0 ens4 0 0 0

After ifdown ens4, ifup ens4, dhclient doens't configure metric for ens4 routes.

below patch fix this issue.

--- /etc/dhcp/dhclient-exit-hooks.d/rfc3442-classless-routes 2017-02-08 08:59:16.407956495 +0000
+++ ./rfc3442-classless-routes 2017-02-08 08:58:58.328337696 +0000
@@ -71,7 +71,7 @@

                                # set route (ip detects host routes automatically)
                                ip -4 route add "${net_address}/${net_length}" \
- ${via_arg} dev "${interface}" >/dev/null 2>&1
+ ${via_arg} dev "${interface}" ${IF_METRIC:+metric $IF_METRIC} >/dev/null 2>&1
                        done
                fi
        fi

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in isc-dhcp (Ubuntu):
status: New → Confirmed
Revision history for this message
Stanislav Makar (smakar) wrote :

ifmetric package will help you and patch is not needed anymore

sudo apt-get install ifmetric -y

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.