Sshd dependency network-online.target

Hello, default sshd.service look like

[Unit]
Description=OpenSSH server daemon
Documentation=man:sshd(8) man:sshd_config(5)
After=network.target sshd-keygen.target
Wants=sshd-keygen.target

[Service]
Type=notify
EnvironmentFile=-/etc/sysconfig/sshd
ExecStart=/usr/sbin/sshd -D $OPTIONS
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
RestartSec=42s

[Install]
WantedBy=multi-user.target

if we use ListenAddress “some_dhcp_address” in /etc/ssh/sshd_config. So when the system starts we will receive an error, and the service will not start immediately.

-- Boot 4db12486707b4cac9c2e95295573a721 --
Feb 27 14:23:05 somehostname systemd[1]: Starting OpenSSH server daemon...
Feb 27 14:23:05somehostname sshd[873]: error: Bind to port 22 on 10.10.110.3 failed: Cannot assign requested address.
Feb 27 14:23:05 somehostname systemd[1]: sshd.service: Main process exited, code=exited, status=255/EXCEPTION
Feb 27 14:23:05 somehostname sshd[873]: fatal: Cannot bind any address.
Feb 27 14:23:05 somehostname systemd[1]: sshd.service: Failed with result 'exit-code'.
Feb 27 14:23:05 somehostname systemd[1]: Failed to start OpenSSH server daemon.
Feb 27 14:23:47 somehostname systemd[1]: sshd.service: Scheduled restart job, restart counter is at 1.

In this case, the service started after 42 seconds. This happens because network.target does not mean that the interface is ready and working and sshd process cannot use an address that has not yet been assigned.

Why not use the following option:

[Unit]
After=network-online.target sshd-keygen.target
Wants=network-online.target sshd-keygen.target