How to make systemd network-online.target wait for multiple networks?

Solution 1:

Systemd automatically assumes that the network is online as long as the target ( I guess it depends on eiter network.service or NetworkManager.service on RHEL) report that it started. We got a problem with dnsmasq reporting that it started, but actually it needed just a little bit more time before serving NFS mounts . As a workaround you can:

  1. Create a service that will be executed after your network service and before your postfix
  2. Set a delay in your network service (maybe a PostExec stanza)
  3. Create a "prestart delay" via "ExecStartPre=" entry in your postfix service

Here is an example of the network.service on CentOS7:

# /run/systemd/generator.late/network.service
# Automatically generated by systemd-sysv-generator
[Unit]
Documentation=man:systemd-sysv-generator(8)
SourcePath=/etc/rc.d/init.d/network
Description=LSB: Bring up/down networking
Before=multi-user.target
Before=multi-user.target
Before=multi-user.target
Before=graphical.target
Before=network-online.target
Before=network.target
Before=vxpbx_exchanged.service

For 2) you can create something like this:

#cat /etc/systemd/system/network.service.d/01-delay.conf
[Service]
ExecStartPost=/bin/sleep 5

For 3) you can create something like:

#cat /etc/systemd/system/postfix.service.d/01-delay.conf
[Service]
ExecStartPre=/bin/sleep 5

Of course, those are just workarounds and this needs to be addressed via a bug.