Re: How to force DHCP renew?

On Wed, 2017-10-04 at 16:13 -0700, Stephen Hemminger wrote:
On Thu, 05 Oct 2017 00:20:28 +0200
Thomas Haller <thaller redhat com> wrote:

On Wed, 2017-10-04 at 11:07 -0700, Stephen Hemminger wrote:
On Azure (and probably other VM environments), there is a desire
cause guest VM to renew DHCP
lease in response to host infrastructure changes. These include
things like spinning up
lots of VM's then suspending them and later unfreezing them as
needed. The other scenario
is doing renew following migration.

The current kernel code has a hack to try and simulate link
but it doesn't
work very well and the old ISC DHCP client does nothing. Network
manager might be
able to do something better??  


link bounce might not work with NetworkManager, in the current

NM has a 5 seconds grace period, during which it ignores carrier
away. It does so because the link can go down unexpectedly for
Actually, after NM changes the MTU, the 5 seconds are extended to
seconds, because [1].
So, kernel would have to bounce the link for at least 10 seconds.

Then there is a setting ignore-carrier (`man NetworkManager.conf`).
That causes NM to totally ignore when the link goes down. That
is quite common, for example on the package "NetworkManager-config-
server" enables it by default on RHEL.

Appart from the above obstacles, carrier going away causes the
connection to disconnect. Later, another (or the same) connection
autoconnect again. So, that sounds like what you requested, but I
think it works well.



One alternative would be to the hyper-v daemon (doing other services)
could invoke a hook or script to request network manager do a renew?


Yes, something like:

for D in $(nmcli -f STATE,DEVICE -t device | sed -n 's/^connected://p'); do
  nmcli device reapply "$D";

But with more effort, wouldn't it be great if the hypervisor could
somehow notify the system about this generically, so that all managers
(networkd, dhclient, etc) could independently pick up the request for
renewal of the lease?
Maybe there could be a new link ifi_flags "IFF_LOWER_CHANGED". NM would
see that the link has this flag set and interpret it as command to re-
do DHCP.
Maybe triggered via

  ip link set $DEV lower-changed

which would turn on the flag. The flag cannot be cleared from user
space, kernel will reset it automatically after a timeout (one
second?). That avoids multiple scripts racing to set/clear the flag.

That is similar to bouncing the link. But without hacking the carrier
flag, which already has another meaning.


Attachment: signature.asc
Description: This is a digitally signed message part

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]