From 3610ec6099e1995cccde67ff87df146ae204a8e6 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Mon, 23 Sep 2019 21:19:33 +0200 Subject: Python/ifconfig: T1680: fix dhclient shutdown Tell DHCP server we release the IP address and also remove it from the interface by properly calling dhclient shutdown. Syslog: Sep 23 21:20:34 vyos dhclient: Killed old client process Sep 23 21:20:35 vyos dhclient: DHCPRELEASE on eth2 to 172.16.35.254 port 67 --- python/vyos/ifconfig.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/python/vyos/ifconfig.py b/python/vyos/ifconfig.py index e8ff59891..8d4923957 100644 --- a/python/vyos/ifconfig.py +++ b/python/vyos/ifconfig.py @@ -610,9 +610,19 @@ class Interface: self._debug_msg('No DHCP client PID found') return None - # stop dhclient - cmd = 'start-stop-daemon --stop --quiet --pidfile {}'.format( - self._dhcp_pid_file) + # stop dhclient, we need to call dhclient and tell it should release the + # aquired IP address. tcpdump tells me: + # 172.16.35.103.68 > 172.16.35.254.67: [bad udp cksum 0xa0cb -> 0xb943!] BOOTP/DHCP, Request from 00:50:56:9d:11:df, length 300, xid 0x620e6946, Flags [none] (0x0000) + # Client-IP 172.16.35.103 + # Client-Ethernet-Address 00:50:56:9d:11:df + # Vendor-rfc1048 Extensions + # Magic Cookie 0x63825363 + # DHCP-Message Option 53, length 1: Release + # Server-ID Option 54, length 4: 172.16.35.254 + # Hostname Option 12, length 10: "vyos" + # + cmd = '/sbin/dhclient -cf {} -pf {} -lf {} -r {}'.format( + self._dhcp_cfg_file, self._dhcp_pid_file, self._dhcp_lease_file, self._ifname) self._cmd(cmd) # cleanup old config file -- cgit v1.2.3