[systemd-devel] Changing configurations with networkd

Tom Gundersen teg at jklm.no
Wed Jul 23 03:47:37 PDT 2014


On Wed, Jul 23, 2014 at 9:50 AM, Michael Olbrich
<m.olbrich at pengutronix.de> wrote:
> I've been experimenting with systemd-networkd to see where it fits my
> use-cases. I'm looking for some insight if the issues I'm seeing are bugs,
> features just not implemented yet or if my use-case is out of scope for
> networkd.
> The most common use-case I have is rather simple: One ethernet interface
> that can be configured either with a static IP address or via DHCP. The
> configuration usually comes from some custom configuration data, so I'll
> probably have a default config as part of the rootfs and generate the real
> config during startup in /run. This works rather well and is much nicer
> than some custom shell scripts.
> The interesting part is, when the configuration changes: I'm working with
> embedded devices and network access is rarely part of the primary function
> of the device. As a result, rebooting the device to change the network
> config is not acceptable.
>
> So I tried to change a static IP address by changing the config and
> restarting networkd. The result was an interface with two addresses. And
> worse, the old address was still the preferred on.
> I realize, that a smooth transition is probably impossible for complex
> configuration possibilities of networkd. But I don't need smooth. How about
> optionally shutting down an interface when networkd stops?
> ShutdownWithNetworkd=yes or something like that in the config file?

Dynamic changing of settings has not been implemented yet, we are so
far only focussing on the static setups. We definitely will cover more
dynamic things in the future though, such as your usecase.

We'll have a dbus interface, and not use stop/restart as a
configuration mechanism, so I don't think tearing things down on
shutdown of the demon makes much sense.

In the meantime, you could hack this by doing:

systemctl stop systemd-networkd
ip link address flush dev <your device>
systemctl start systemd-networkd

> Another thing I noticed is with DHCP without changing the configuration:
> Networkd forgets the lease during restart and sends a dhcp discover. Then
> the server might offer a different address. The problem is, that the new
> address is in the same subnet as the old address, so it is added as
> secondary address. When the valid_lft of the old address expires then
> _both_ addresses are removed :-/.

Thanks for this report, we should figure out a way that the new
address is not lost when the first one is.

> I think the lease should be remembered and reused in this case.

Hm, this sounds like a bug somewhere. When the new discover is sent
out it should send the same identifying information to the server, and
hence be given the same lease back again. Wireshark should tell you if
the fault is networkd's or the DHCP server.

In general, saving the lease to disk is probably not a good idea. We
would need to store it on /var, and we may need to start the DHCP
server before /var has been mounted. To the extent possible I would
prefer to avoid that problem.

Cheers

Tom


More information about the systemd-devel mailing list