[systemd-devel] One-Command complex network reconfiguration, was: propagate reload from other events

Andrei Borzenkov arvidjaar at gmail.com
Mon Oct 12 01:20:34 PDT 2015


On Mon, Oct 12, 2015 at 1:40 AM, Johannes Ernst
<johannes.ernst at gmail.com> wrote:

> I guess I need to explain what I’m trying to do:
>
> I want a single command to reconfigure networking for different situations
> that a device running UBOS [2] might encounter. Example syntax:
>
>> ubos-admin setnetconfig client
> # sets up DHCP client on all network interfaces, advertises http and https
> sites on device via Avahi, runs firewall
>> ubos-admin setnetconfig static
> # allocates static IP addresses on all network interfaces, advertises http
> and https sites via Avahi, runs firewall
>> ubos-admin setnetconfig gateway
> # sets up DHCP client on first Ethernet interface (WAN), allocates static IP
> addresses to all other interfaces (LAN), advertises via Avahi but only on
> LAN, runs firewall and NAT
>> ubos-admin setnetconfig cloud
> # sets up DHCP client on all network interfaces, no Avahi, runs firewall,
> also runs cloud-init
>
> The idea is to take drudgery and needed competence out of network
> configuration and make it “fool proof” by identifying the situation on a
> high level (“this is my home gateway”, “this is just some device on my
> network” etc) and let software make it so.
>
> My implementation of ‘ubos-admin setnetconfig XXX’ basically goes like this:
>
> 1. Generate/update configuration files for the configuration XXX
> 2. systemctl start ubos-networking-XXX.service (where XXX=client, static,
> gateway, …), with all the ubos-networking-XXX.service files declaring a
> Conflict with all others, so systemd will only run one of them at a time.
>
> To get back to the problem on the beginning of the thread, let’s take an
> example:
>
> ubos-networking-client.service depends on systemd-networkd.service, with a
> config file like this:
>
> [Match]
> Name=*
> [Network]
> DHCP=ipv4
>
> ubos-networking-gateway.service depends on systemd-networkd.service, with a
> config file like this:
>
> [Match]
> Name=enp0s3
> [Network]
> DHCP=ipv4
> [Match]
> Name=*
> [Network]
> Address=0.0.0.0/16
>
> Now, if the current state is “client” and the user executes “ubos-admin
> setnetconfig gateway”, after updating the config files, the following things
> need to occur:
> 1. ubos-networking-client.service needs to be stopped
> 2. ubos-networking-gateway.service needs to be started

I still fail to see how ubos-networking-client.service or
ubos-networking-gateway.service come in play here. You changed
networkd configuration and need restart/reload networkd. That can be
done directly by ubos-admin. What is the purpose of other services?

> 3. systemd-networkd.service needs to be reloaded, because its configuration
> has changed.
>
> So I was wondering whether there is a mechanism to have systemd reload
> systemd-networkd, in response to an event such as
> ubos-networking-client.service being stopped, or
> ubos-networking-gateway.service being started.
>
> Does this make sense?
>

Not really :)


More information about the systemd-devel mailing list