<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Silvio, thanks for the suggestion. I'm not concerned with keeping
the lease forever; the system actually experiences a topology
change as it's switched from one network to another, and I can
catch that from the DBus events that occur. The problem we're
trying to solve is to contact some address that we're sure exists
on the network, without knowing anything about that network. The
default gateway was an obvious choice, but someone wants to cover
the case of there being a private LAN with no gateway. The only
other choice I could see is the DHCP server that issues the lease.</p>
<p>As my thinking has evolved, I really want to get at more DHCP
lease information when it comes in, like a private DHCP option
code that conveys something about the environment. I came across a
comment somewhere that said the only way is to set the
systemd-networkd client to use debug log level and read from the
journal, but isn't there a more direct way, like with the Dbus
signals that tell subscribers about network interface status?<br>
</p>
<pre class="moz-signature" cols="72">Bruce A. Johnson | Firmware Engineer
Blue Ridge Networks, Inc.
14120 Parke Long Court Suite 103 | Chantilly, VA 20151
Main: 1.800.722.1168 | Direct: 703-633-7332
<a class="moz-txt-link-freetext" href="http://www.blueridgenetworks.com">http://www.blueridgenetworks.com</a>
OpenPGP key ID: 296D1CD6F2B84CAB <a class="moz-txt-link-freetext" href="https://keys.openpgp.org/">https://keys.openpgp.org/</a></pre>
<div class="moz-cite-prefix">On 21/04/2021 15:34, Silvio Knizek
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:dc9b3af4e71be10531c80e6aab8c7ba88137cc58.camel@gmx.net">
<pre class="moz-quote-pre" wrap="">Am Mittwoch, dem 21.04.2021 um 14:24 -0400 schrieb Bruce A. Johnson:
</pre>
<blockquote type="cite">
<pre class="moz-quote-pre" wrap="">Is there a correct way to obtain information about the DHCP lease
received by systemd-networkd's DHCP client functionality? It was easy
enough to find SERVER_ADDRESS in /var/run/systemd/netif/leases/4, but
there is a big fat warning stamped at the top of the file:
</pre>
<blockquote type="cite">
<pre class="moz-quote-pre" wrap=""># This is private data. Do not parse.
</pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">I'd like to be able to make a widget that can tell me which DHCP server
issued my lease, how much more time I have, etc., mainly because I want
to be able to ping something that is known to be on the network. I'm
dealing with a lazy sysadmin who doesn't want to put a gateway on this
private network, I haven't found a solution using the CLI tools.
Thanks in advance.
</pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">Hi Bruce,
IMHO "having a lease" is not a good metric to determine if you can
access something.
I would suggest something along this line:
--- /etc/systemd/system/internal-network-accessable.target
[Unit]
Description=Internal System Accessable
---
--- /etc/systemd/system/check-if-internal-system-is-accessable.service
[Unit]
Description=Check if internal system can be reached
[Service]
ExecStart=/usr/local/bin/check-if-internal-system-is-accessable.sh
Restart=always
[Install]
WantedBy=multi-user.target
---
--- /usr/local/bin/check-if-internal-system-is-accessable.sh
#!/usr/bin/bash
while :; do
if wget -q --spider $INTERNAL_RESOURCE; then
systemctl start internal-network-accessable.target
else
systemctl stop internal-network-accessable.target
fi
sleep 600
done
---
Than you can check just the status of the .target. You may need to
tweak the lifeness probe, YMMV.
Also in sd-networkd you can configure a .network to never loose its
lease, see <a class="moz-txt-link-freetext" href="man:systemd.network">man:systemd.network</a> → KeepConfiguration=
HTH
Silvio
</pre>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
systemd-devel mailing list
<a class="moz-txt-link-abbreviated" href="mailto:systemd-devel@lists.freedesktop.org">systemd-devel@lists.freedesktop.org</a>
<a class="moz-txt-link-freetext" href="https://lists.freedesktop.org/mailman/listinfo/systemd-devel">https://lists.freedesktop.org/mailman/listinfo/systemd-devel</a>
</pre>
</blockquote>
</body>
</html>