diff options
author | Christian Poessinger <christian@poessinger.com> | 2019-10-18 18:07:21 +0200 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2019-10-18 18:07:26 +0200 |
commit | 04c02bcd100f253832e9a57736cf0d1a9f32fc5f (patch) | |
tree | 5346fc5d6da57cd1fecbde8d42c979348c934167 /python/vyos | |
parent | ca4f0dc76f918323c69905399a2dba9b2a21a8ec (diff) | |
download | vyos-1x-04c02bcd100f253832e9a57736cf0d1a9f32fc5f.tar.gz vyos-1x-04c02bcd100f253832e9a57736cf0d1a9f32fc5f.zip |
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.
Diffstat (limited to 'python/vyos')
-rw-r--r-- | python/vyos/ifconfig.py | 15 |
1 files 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): |