Dear Maintainer,
I was trying to configure a service that needs networking to be completely
configured when it starts, with addresses and the default route. To achieve
that, I made it depend on network-online.target, and enabled
ifupdown-wait-online.service. However, after the reboot, the service was
still started before dhclient assigned the IP address to the interface.
To debug this issue, I have modified /lib/ifupdown/wait-online.sh, added a
"set -x" at the top and "/sbin/ifquery --state" at the very bottom. Result:
(This is with the "auto" workaround applied, but still shows the underlying
issue that "ifquery" considers an interface with an incomplete DHCP
transaction to be up)
Nov 01 09:14:06 wait-online.sh[234]: + WAIT_ONLINE_METHOD=ifup
Nov 01 09:14:06 wait-online.sh[234]: + WAIT_ONLINE_IFACE=
Nov 01 09:14:06 wait-online.sh[234]: + WAIT_ONLINE_ADDRESS=
Nov 01 09:14:06 wait-online.sh[234]: + WAIT_ONLINE_TIMEOUT=300
Nov 01 09:14:06 wait-online.sh[234]: + [ -f /etc/default/networking ]
Nov 01 09:14:06 wait-online.sh[234]: + . /etc/default/networking
Nov 01 09:14:06 wait-online.sh[234]: + up=false
Nov 01 09:14:06 wait-online.sh[234]: + [ -z ]
Nov 01 09:14:06 wait-online.sh[234]: + /sbin/ifquery -X lo --list
Nov 01 09:14:06 wait-online.sh[234]: + auto_list=enp0s3
Nov 01 09:14:06 wait-online.sh[234]: + /sbin/ifquery -X lo --allow=hotplug --list
Nov 01 09:14:06 wait-online.sh[234]: + hotplug_list=
Nov 01 09:14:06 wait-online.sh[234]: + [ -n enp0s3 ]
Nov 01 09:14:06 wait-online.sh[234]: + seq 1 300
Nov 01 09:14:06 systemd[1]: Started Create Static Device Nodes in /dev.
Nov 01 09:14:06 wait-online.sh[234]: + up=true
Nov 01 09:14:06 wait-online.sh[234]: + /sbin/ifquery --state enp0s3
Nov 01 09:14:06 wait-online.sh[234]: + up=false
Nov 01 09:14:06 wait-online.sh[234]: + break
Nov 01 09:14:06 wait-online.sh[234]: + [ false = true ]
Nov 01 09:14:06 wait-online.sh[234]: + sleep 1
.....
Nov 01 09:14:06 systemd[1]: Started Helper to synchronize boot up for ifupdown.
Nov 01 09:14:06 systemd[1]: Starting Raise network interfaces...
.....
Nov 01 09:14:06 dhclient[405]: Internet Systems Consortium DHCP Client 4.4.1
Nov 01 09:14:06 ifup[382]: Internet Systems Consortium DHCP Client 4.4.1
Nov 01 09:14:06 dhclient[405]: Copyright 2004-2018 Internet Systems Consortium.
Nov 01 09:14:06 ifup[382]: Copyright 2004-2018 Internet Systems Consortium.
Nov 01 09:14:06 dhclient[405]: All rights reserved.
Nov 01 09:14:06 ifup[382]: All rights reserved.
Nov 01 09:14:06 dhclient[405]: For info, please visit https://www.isc.org/software/dhcp/
Nov 01 09:14:06 ifup[382]: For info, please visit https://www.isc.org/software/dhcp/
Nov 01 09:14:06 dhclient[405]:
Nov 01 09:14:06 dhclient[405]: Listening on LPF/enp0s3/52:54:00:4a:f5:1f
Nov 01 09:14:06 ifup[382]: Listening on LPF/enp0s3/52:54:00:4a:f5:1f
Nov 01 09:14:06 ifup[382]: Sending on LPF/enp0s3/52:54:00:4a:f5:1f
Nov 01 09:14:06 ifup[382]: Sending on Socket/fallback
Nov 01 09:14:06 ifup[382]: DHCPDISCOVER on enp0s3 to 255.255.255.255 port 67 interval 7
Nov 01 09:14:06 dhclient[405]: Sending on LPF/enp0s3/52:54:00:4a:f5:1f
Nov 01 09:14:06 dhclient[405]: Sending on Socket/fallback
Nov 01 09:14:06 dhclient[405]: DHCPDISCOVER on enp0s3 to 255.255.255.255 port 67 interval 7
Nov 01 09:14:07 wait-online.sh[234]: + up=true
Nov 01 09:14:07 wait-online.sh[234]: + /sbin/ifquery --state enp0s3
Nov 01 09:14:07 wait-online.sh[234]: + [ true = true ]
Nov 01 09:14:07 wait-online.sh[234]: + break
Nov 01 09:14:07 wait-online.sh[234]: + [ true = true ]
Nov 01 09:14:07 wait-online.sh[234]: + /sbin/ifquery --state
Nov 01 09:14:07 wait-online.sh[234]: enp0s3=enp0s3
Nov 01 09:14:07 wait-online.sh[234]: lo=lo
Nov 01 09:14:07 systemd[1]: Started Wait for network to be configured by ifupdown.
^^^^^ see this? At this point ifquery thinks that the interface is up,
vvvvv but it will actually be configured only 2 seconds later!
Nov 01 09:14:09 dhclient[405]: DHCPOFFER of 192.168.0.241 from 192.168.0.1
Nov 01 09:14:09 ifup[382]: DHCPOFFER of 192.168.0.241 from 192.168.0.1
Nov 01 09:14:09 ifup[382]: DHCPREQUEST for 192.168.0.241 on enp0s3 to 255.255.255.255 port 67
Nov 01 09:14:09 dhclient[405]: DHCPREQUEST for 192.168.0.241 on enp0s3 to 255.255.255.255 port 67
Nov 01 09:14:09 dhclient[405]: DHCPACK of 192.168.0.241 from 192.168.0.1
Nov 01 09:14:09 ifup[382]: DHCPACK of 192.168.0.241 from 192.168.0.1
Nov 01 09:14:09 dhclient[405]: bound to 192.168.0.241 -- renewal in 18440 seconds.
Nov 01 09:14:09 ifup[382]: bound to 192.168.0.241 -- renewal in 18440 seconds.
Nov 01 09:14:09 systemd[1]: Started Raise network interfaces.
I have changed "allow-hotplug" to "auto" in /etc/network/interfaces as a
workaround, so that ifup itself waits, as evidenced by the last line in the
log. But then, what's the point of the wait-online.sh script with the default
settings in /etc/default/networking?
It may be relevant that in my network IPv6 with SLAAC also exists, maybe
that's why ifquery sees the interface as up even though the DHCP transaction
is not yet complete.
--- /etc/network/interfaces.d/*:
cat: '/etc/network/interfaces.d/*': No such file or directory
--- up and down scripts installed:
/etc/network/if-down.d:
total 4
-rwxr-xr-x 1 root root 289 Jun 21 14:24 bind9
/etc/network/if-post-down.d:
total 0
/etc/network/if-pre-up.d:
total 0
/etc/network/if-up.d:
total 4
-rwxr-xr-x 1 root root 289 Jun 21 14:24 bind9