systemd-networkd: How to configure network with environment variables?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dear systemd folks,


Due to historical reasons, in our environment we have a configuration file with the network device name and the to be assigned IP address:

    $ more /etc/local/mxhost.conf
    MX_NETDEV=net02
    MX_IPADDR=141.14.18.X

Then a custom service unit `network.service` [1] configures the network with the configuration file as environment file.

    [Unit]
    Description=Network Connectivity
    DefaultDependencies=no

    [Service]
    EnvironmentFile=/etc/local/mxhost.conf
    Type=oneshot
    RemainAfterExit=yes
    ExecStart=/usr/sbin/mxnetctl start
ExecStart=/sbin/ip addr add ${MX_IPADDR}/20 broadcast 141.14.31.255 dev ${MX_NETDEV}
    ExecStart=/sbin/ip link set up dev ${MX_NETDEV}
    ExecStart=/sbin/ip route add default via 141.14.16.X
    ExecStop=/sbin/ip addr del ${MX_IPADDR}/20 dev ${MX_NETDEV}
    StandardOutput=syslog

    [Install]
    WantedBy=network.target

Wanting to use systemd-network but keeping local device configuration in `/etc/local` is there an easy way? systemd.network(5) does not say anything about, that environment variables could be used.

If that does not work, do you have another suggestion? Possible, but not nice, solutions, I came up with:

1.  Use a generator to create .network files from `/etc/local/mxhost.conf`.

2. Convert `/etc/local/mxhost.conf` manually to `/etc/local/mxhost.network` and add a symbolic link from `/etc/systemd/network` to that file.


Kind regards,

Paul


[1]: https://github.molgen.mpg.de/mariux64/mxtools/blob/master/misc_systemd_units/network.service
[2]: https://www.freedesktop.org/software/systemd/man/systemd.network.html
_______________________________________________
systemd-devel mailing list
systemd-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/systemd-devel



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux