Page MenuHomeVyOS Platform

DHCP not renewed after switching network
Closed, ResolvedPublicBUG


Since Vyos 1.2 the following bug seems to appear regarding DHCP leases. This bug does not happen with Vyos 1.1.8.
Best to test this is with VM and a passthroughed interface, like your WiFi adapter. Eg eth0:

# make sure we dhcp on the interface
set interfaces ethernet eth0 address dhcp

We get a DHCP lease and all is good:

[email protected]# run show int
Codes: S - State, L - Link, u - Up, D - Down, A - Admin Down
Interface        IP Address                        S/L  Description
---------        ----------                        ---  -----------
eth0                      u/u  Wi-Fi bridge

Now switch your WiFi network (that has a different subnet range) to for example your mobile phone's hotspot.
You will see that the lease is not renewed and keeps the same DHCP address.

Only way to fix this is to run run dhcp renew, but this is not ideal ofcourse:

# renew dhcp lease manually
[email protected]# sudo /opt/vyatta/bin/sudo-users/ --dhcp renew --dev eth0

# wait for a while
[email protected]# run show interface
Codes: S - State, L - Link, u - Up, D - Down, A - Admin Down
Interface        IP Address                        S/L  Description
---------        ----------                        ---  -----------
eth0                       u/u  Wi-Fi bridge

If you test this with Vyos 1.1.8 it works properly, when you switch from network: the link goes down, ip is not set, and correct DHCP lease is assigned after switching.
Other distributions like OpenBSD seem to handle this properly as well.

I have no idea where the bug could be, maybe dhclient?


Difficulty level
Unknown (require assessment)
VyOS 1.2.0-rc2
Why the issue appeared?
Will be filled on close

Event Timeline

syncer triaged this task as Normal priority.
syncer edited projects, added VyOS 1.2 Crux (VyOS 1.2.0-rc4); removed VyOS 1.2 Crux.

I did some of my own digging, and it seems because Vyos 1.2.x is missing the netplugd daemon.

The file /etc/netplug/linkup.d/dhclient is still created for dhcp interfaces by vyatta-cfg, but the following files are missing in action:

  • /etc/netplug/netplug
  • /etc/netplug/netplugd.conf

Vyos 1.2 is missing the "netplugd" service because the package is not installed. I fixed it by:

After adding netplugd service and required config and scripts the dhcp leases get renewed properly again.

Actually the old netplug script doesn't fully work, i had to use the original netplug script that comes with the package but I added the run-parts lines like this:

[email protected]:/etc/netplug$ cat netplug
# netplug - policy agent for netplugd
# Copyright 2003 Key Research, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License, version 2, as
# published by the Free Software Foundation.  You are forbidden from
# redistributing or modifying it under the terms of any other license,
# including other versions of the GNU General Public License.
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# General Public License for more details.

export PATH


case "$action" in
    run-parts -a $dev /etc/netplug/linkup.d
    if [ -x /sbin/ifup ]; then
	exec /sbin/ifup "$dev"
	echo "Please teach me how to plug in an interface!" 1>&2
	exit 1
    run-parts -a $dev /etc/netplug/linkdown.d
    if [ -x /sbin/ifdown ]; then
	# At least on Fedora Core 1, the call to ip addr flush infloops
	# /sbin/ifdown $dev && exec /sbin/ip addr flush $dev
	exec /sbin/ifdown "$dev"
	echo "Please teach me how to unplug an interface!" 1>&2
	exit 1
    exec /sbin/ip link set "$dev" up >/dev/null 2>&1
    echo "I have been called with a funny action of '%s'!" 1>&2
    exit 1
[email protected]:/etc/netplug$
hagbard changed the task status from Open to In progress.Jan 17 2019, 8:09 PM
hagbard claimed this task.
hagbard added a subscriber: c-po.

pending ci netplugd integration, local tests were quite successful, I think it can be release into rolling in the next few days.

hagbard changed the task status from In progress to Needs testing.Jan 18 2019, 7:07 PM

@yun should address that issue, can you please test? I only tested on VMs yet.

@yun can you please test with the latest rolling?

I was not able to test sooner. But i confirmed it works properly with rolling release vyos-1.2.0-rolling+201902060337-amd64.