<div dir="ltr"><div>My current solution with dhcpcd is a sleep service sending signals to dhcpcd (give back the lease/reclaim it), something which could be extended to systemd-networkd, with other signals for other meanings that you may not want by default, like:<br> - removing the configuration it did (which is currently kept when systemd-networkd is stopped, which could be useful in some scenarios to avoid asking an additional IP address every time)<br> - starting or stopping the DHCP servers services (which once started keep running)<br><br></div>Even if systemd-networkd does not support a fine grained logic as I regretted in another message about br0, this would at least support most of the basic scenarios many people will need.<br><div><div><br>$ cat /dhcpcd-sleep.service <br>[Unit]<br>Description=DHCP client sleep hook<br>Before=sleep.target<br>ConditionVirtualization=no<br><br>[Service]<br>Type=oneshot<br>RemainAfterExit=yes<br>ExecStart=/usr/bin/killall -USR1 dhcpcd<br>ExecStop=/usr/bin/killall -SIGALRM dhcpcd<br><br>[Install]<br>WantedBy=sleep.target<br><br><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Feb 3, 2015 at 11:27 AM, Lennart Poettering <span dir="ltr"><<a href="mailto:lennart@poettering.net" target="_blank">lennart@poettering.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>On Tue, 03.02.15 18:20, Patrik Flykt (<a href="mailto:Patrik.Flykt@linux.intel.com" target="_blank">Patrik.Flykt@linux.intel.com</a>) wrote:<br>
<br>
> On Tue, 2015-02-03 at 11:46 +0100, Lennart Poettering wrote:<br>
> > On Mon, 02.02.15 23:12, Charles Devereaux (<a href="mailto:systemd@guylhem.net" target="_blank">systemd@guylhem.net</a>) wrote:<br>
> ><br>
> > > Another problem with systemd-networkd is that the lease is not renewed<br>
> > > after sleep.<br>
> > ><br>
> > > This is a basic feature, a laptop is frequently physicially moved, which<br>
> > > means another DHCP lease should be acquired, but I don't see how to<br>
> > > do that.<br>
> ><br>
> > Hmm, I figure all DHCP leases should be refreshed when we come back<br>
> > from suspend. Hooking that up should be pretty easy. Added to the TODO<br>
> > list.<br>
> ><br>
> > That said, isn't the link beat lost anyway during suspend, and thus we<br>
> > should refresh automatically, anyway?<br>
> ><br>
> > Either way refreshing on resume can't hurt...<br>
><br>
> Is the resume event detected somehow in systemd?<br>
<br>
</span>The kernel unfortunately provides no API for this right now. However,<br>
if logind is the one suspending the machine, then it sends out a<br>
PrepareForSleep() signal before doing so. systemd-resolved already<br>
hooks into that:<br>
<br>
<a href="http://cgit.freedesktop.org/systemd/systemd/tree/src/resolve/resolved-bus.c#n684" target="_blank">http://cgit.freedesktop.org/systemd/systemd/tree/src/resolve/resolved-bus.c#n684</a><br>
<br>
Tom mentioned he's already looking into adding similar code to<br>
networkd to handle this properly.<br>
<div><div><br>
Lennart<br>
<br>
--<br>
Lennart Poettering, Red Hat<br>
</div></div></blockquote></div><br></div></div>