Bug#947158: systemd: After=network.target is ineffective

Paul Szabo paul.szabo at sydney.edu.au
Sun Dec 22 06:51:50 GMT 2019


Package: systemd
Version: 241-7~deb10u2
Severity: normal
Tags: patch

Lately (since buster?) I observe that "After=network.target" is ineffective,
maybe because dhcpcd runs asynchronously. I seem to get good results by
creating a file

  /etc/network/if-up.d/00waitup

with contents as below.


Cheers, Paul
-- 
Paul Szabo   psz at maths.usyd.edu.au   http://www.maths.usyd.edu.au/u/psz/
School of Mathematics and Statistics   University of Sydney    Australia


Contents of /etc/network/if-up.d/00waitup :

#!/bin/bash -

#V0.1  22 Dec 19  wait for (ensure) interface is up
# Paul Szabo   psz at maths.usyd.edu.au

# Ensure network interface is "up".
# DHCP may take long... and at buster it seems to be done asynchronously,
# so systemd "After=network.target" is ineffective.

# Though neither we, nor any commands we run, should ever fail or
# show anything on STDERR: ensure we do not, otherwise ifup may think
# we failed, and fail the interface. 
exec 2>&1

case "$IFACE" in
  eth* ) echo -E "00waitup: Waiting for $IFACE to be up ...";;
  * ) echo -E "00waitup: No waiting for $IFACE"; exit;;
esac

n=0
while :; do
  LINE="$(ip -o address show $IFACE)"
  if [ -n "$LINE" ] ; then
    echo -E "00waitup: $IFACE is up, 'ip -o address show $IFACE' shows '$LINE'"
    exit
  fi
  (( n = $n+1 ))
  if [ $n -gt 60 ]; then
    echo -E "00waitup: 'ip -o address show $IFACE' failed, seems down, giving up"
    exit
  fi
  echo -n -E "00waitup: Waiting for $IFACE to come up at "; date
  sleep 1
done



More information about the Pkg-systemd-maintainers mailing list