[systemd-devel] Changing configurations with networkd
Michael Olbrich
m.olbrich at pengutronix.de
Wed Jul 23 05:40:38 PDT 2014
On Wed, Jul 23, 2014 at 12:47:37PM +0200, Tom Gundersen wrote:
> 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.
That sounds interesting.
> In the meantime, you could hack this by doing:
>
> systemctl stop systemd-networkd
> ip link address flush dev <your device>
> systemctl start systemd-networkd
I know, but that's not very nice, and I need to handle nfs-root special
cases manually...
> > 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 looked at the code, but I need to learn more about netlink before I
understand the little details there.
> > 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.
I get the same address at first, but after several minutes the DHCP server
decides to offer a new address. I should note, that I have a 10 minute
lease time for debugging purposes, so that might make the problem more
prominent. I'll see if I can figure out what happens here.
Michael
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
More information about the systemd-devel
mailing list