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

Network services fail on startup



I am having intermittent problems on startup in which network services do not start properly, generally with messages suggesting the network interface they need is not available. If I stop and start them after, they will run.  I suspect this is a result of the interaction of systemd, ifupdown, and a pre-up script that takes a while to execute.  But if I look at things now it seems the dependencies in place should suffice.  Of course, this is after I restarted it, and so perhaps the dependency is added dynamically, too late to do any good.

I think what I need is for network-online.target not to be ready until after the interfaces ifup controls are up, but I'm not sure how to do it.  Also not sure it's the problem, particularly since some information indicates it already has such a dependency.

Details:

My main interface is controlled by /etc/network/interfaces that includes
allow-hotplug /enp*
iface enp5s0 inet static
   # etc

The interface has a pre-up script that has over 1,000 iptables add lines for blacklists, and I suspect this is slowing things down enough to cause trouble.  I was not having problems when the script was shorter.

This is a problem other have encountered:
https://unix.stackexchange.com/questions/209832/debian-systemd-network-online-target-not-working
https://unix.stackexchange.com/questions/257888/systemd-wait-for-network-interface-to-be-up-before-running-service

Various solutions are suggested, with a leading one being a dependency on network-online.target.  But all my network services already have that dependency.  For example, 
# systemctl cat tftpd-hpa
# /run/systemd/generator.late/tftpd-hpa.service
# Automatically generated by systemd-sysv-generator

[Unit]
Documentation=man:systemd-sysv-generator(8)
SourcePath=/etc/init.d/tftpd-hpa
Description=LSB: HPA's tftp server
Before=multi-user.target
Before=multi-user.target
Before=multi-user.target
Before=graphical.target
After=remote-fs.target
After=network-online.target
Wants=network-online.target

tftpd-hpa is the service that fails most consistently.

# systemctl list-dependencies tftpd-hpa
Mon 13 Jul 2020 02:42:22 PM PDT
tftpd-hpa.service
● ├─system.slice
● ├─network-online.target
● │ ├─networking.service
● │ └─NetworkManager-wait-online.service
● └─sysinit.target
etc.
Notably absent from network-online.target's dependencies is anything related to ifup.
However, ifup@enp5s0.service appears as an After dependency of network-online.target when viewed another way:
# systemctl show network-online.target
Id=network-online.target
Names=network-online.target
Wants=NetworkManager-wait-online.service networking.service
WantedBy=tftpd-hpa.service nmbd.service hddtemp.service docker.service mythtv-backend.service exim4.service hylafax.service smbd.service inetd.service isc-dhcp-server.service
Conflicts=shutdown.target
Before=hylafax.service isc-dhcp-server.service smbd.service exim4.service apt-daily.service rc-local.service apt-daily-upgrade.service mythtv-backend.service apcupsd.service tftpd-hpa.service docker.service inetd.service hddtemp.service shutdown.target nmbd.service
After=ifup@enp5s0.service network.target networking.service NetworkManager-wait-online.service
Documentation=man:systemd.special(7) https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget
Any suggestions?
Ideally I would not be tied to the interface name, so that if I plug the network cable into another port things will still work.

Thanks.
Ross Boylan


Reply to: