#550712 ifupdown: kill running dhclients when switching to static adressing

Package:
ifupdown
Source:
ifupdown
Description:
high level tools to configure network interfaces
Submitter:
Patrick Schoenfeld
Date:
2021-11-18 07:21:02 UTC
Severity:
wishlist
#550712#5
Date:
2009-10-12 12:00:20 UTC
From:
To:
Hi,

I just stumbled across a unfortunate circumstance with ifupdown.
If a host is configured to DHCP adressing and you then change it
to static adressing the dhclient will still be running.
This will lead to an address-change on the given interface, once
the lease expires, because dhclient will reconfigure the interface.

Therefore I would request to kill a DHCP-client, if
the interface for which it was started, is reconfigured to
static adressing. I don't know if this is possible, because
I don't know if ifupdown is doing some state tracking,
but if not a possible solution could eventually look like that:

Interface eth0 is brought up, which uses static addressing.
Therefore we check if any dhclient is running which watches
eth0 (Don't know how this works for other dhclients, but dhclient3
gets the interface as argument, so this should be fairly easy to
determine) and kill it.

Any drawbacks with that suggestion?

Best Regards,
Patrick

#550712#10
Date:
2021-11-18 07:16:18 UTC
From:
To:
It might also be necessary/good idea to delete any lease file(s) related to
the interfaces which is not specified as dhcp-assigned in the interface
config file.

It seems, even though you kill the dhclient process, it might come back if
you don't delete the lease file.

In my view this issues is very common and there you could argue it should
be escalated to a bug and not a feature request.
I will claim that the majority of all new installations get an dhcp
assigned IP address and the majority of all server-setups will be changed
to static....and then we have the problem, that's a lot of pain out there!

Perhaps most just restart but you should be able to just do a "ifdown
--all; ifup --all" and then everything is good, but that's not the case.

(well not quite: when I change a new servers to static and add a bridge
interface, "ifdown --all; ifup --all" seems not to enable the bridge
interface. I have to do "systemctl restart networking" too, but fixing this
dhclient issue would be a good start)