[systemd-devel] can I use network-online.target without NM and networkd

Zbigniew Jędrzejewski-Szmek zbyszek at in.waw.pl
Tue Mar 26 07:04:46 UTC 2019


On Mon, Mar 25, 2019 at 10:18:06PM +0100, Reindl Harald wrote:
> 
> 
> Am 25.03.19 um 22:00 schrieb Belisko Marek:
> > in my app I need to delay startup until network is really up & running.
> > I go through [1] and it mentions that it works only with NetworkManager
> > and systemd-networkd. I'm using ifup configuration for network so can I
> > use this target to be sure that app will be called only when network is
> > up? Thanks.
> > 
> > [1] - https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget/
> 
> surely

To expand a bit on this: it is possible to hook arbitrary network
setup service on the other side of network-online.target. The only issue
is that somebody has to do it, i.e. provide mynetworkconfig-wait-online.service
and make it hooked into network-online.target.

The config below is a nice example...

Zbyszek

>, switched months ago to my own network "scripts" because NM is
> terrible slow and nobody needs a process running after boot on static
> configured networks
> 
> [root at testserver:~]$ cat /etc/systemd/system/network-up.service
> [Unit]
> Description=Network
> After=systemd-udev-trigger.service systemd-udev-settle.service
> Wants=systemd-udev-trigger.service systemd-udev-settle.service
> After=sys-subsystem-net-devices-lan.device
> After=sys-subsystem-net-devices-wan.device
> Wants=sys-subsystem-net-devices-lan.device
> Wants=sys-subsystem-net-devices-wan.device
> Before=crond.service timers.target
> PartOf=network-online.target
> 
> [Service]
> Type=oneshot
> RemainAfterExit=yes
> SuccessExitStatus=80
> ExecStart=/usr/sbin/ipset -file /etc/sysconfig/ipset restore
> ExecStart=/usr/sbin/iptables-restore /etc/sysconfig/iptables
> ExecStart=/usr/sbin/ip addr add 192.168.196.12/255.255.255.0 broadcast
> 192.168.196.255 dev lan
> ExecStart=/usr/sbin/ip link set dev lan up
> ExecStart=/usr/sbin/ip route add default via 192.168.196.2
> 
> [Install]
> WantedBy=network-online.target
> WantedBy=multi-user.target


More information about the systemd-devel mailing list