From 04c02bcd100f253832e9a57736cf0d1a9f32fc5f Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Fri, 18 Oct 2019 18:07:21 +0200 Subject: Python/ifconfig: T1712: always start DHCP when configured DHCP was only started when the interface operstate was set to up but this is wrong. An interface can be configured as DHCP interface and DHCP client must be launched even when the physical interface becomes available n-minutes later. DHCP client then can ask for an IP assignemnt by DHCP. Tested by starting DHCP client on a not connected ethernet interface. Address was assigned later on after link became ready. --- python/vyos/ifconfig.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/python/vyos/ifconfig.py b/python/vyos/ifconfig.py index 1ffa10978..3470b3aa6 100644 --- a/python/vyos/ifconfig.py +++ b/python/vyos/ifconfig.py @@ -521,14 +521,13 @@ class Interface: with open(self._dhcp_cfg_file, 'w') as f: f.write(dhcp_text) - if self.get_state() == 'up': - cmd = 'start-stop-daemon --start --quiet --pidfile ' + \ - self._dhcp_pid_file - cmd += ' --exec /sbin/dhclient --' - # now pass arguments to dhclient binary - cmd += ' -4 -nw -cf {} -pf {} -lf {} {}'.format( - self._dhcp_cfg_file, self._dhcp_pid_file, self._dhcp_lease_file, self._ifname) - return self._cmd(cmd) + cmd = 'start-stop-daemon --start --quiet --pidfile ' + \ + self._dhcp_pid_file + cmd += ' --exec /sbin/dhclient --' + # now pass arguments to dhclient binary + cmd += ' -4 -nw -cf {} -pf {} -lf {} {}'.format( + self._dhcp_cfg_file, self._dhcp_pid_file, self._dhcp_lease_file, self._ifname) + return self._cmd(cmd) def _del_dhcp(self): -- cgit v1.2.3