FS#63410 - [stunnel] stunnel service starts before interface is assigned an ip

Attached to Project: Community Packages
Opened by John Doe (hillbicks) - Thursday, 08 August 2019, 21:20 GMT
Last edited by Toolybird (Toolybird) - Friday, 28 April 2023, 06:28 GMT
Task Type Feature Request
Category Packages
Status Closed
Assigned To Lukas Fleischer (lfleischer)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:
using systemd stunnel service, stunnel starts before the network interface gets assigned an ip since [After]=network.target is used instead of network-online.target in the service file

Additional info:
* 5.55-1
* /usr/share/doc/stunnel/examples/stunnel.service
* After=syslog.target network.target > After=syslog.target network-online.target

Steps to reproduce:
systemctl enable stunnel
reboot
stunnel fails since it cannot bind to an ip

Aug 08 19:04:28 login dhcpcd[225]: ens18: adding address fe80::6306:d714:706:2c3c
Aug 08 19:04:28 login dhcpcd[225]: ens18: rebinding lease of 192.168.50.56
Aug 08 19:04:28 login dhcpcd[225]: ens18: probing address 192.168.50.56/24
Aug 08 19:04:28 login dhcpcd[225]: ens18: soliciting an IPv6 router
Aug 08 19:04:32 login dhcpcd[225]: ens18: leased 192.168.50.56 for 7200 seconds
Aug 08 19:04:32 login dhcpcd[225]: ens18: adding route to 192.168.50.0/24
Aug 08 19:04:32 login dhcpcd[225]: ens18: adding default route via 192.168.50.1


Aug 08 19:04:31 login stunnel[232]: [.] Binding service [ssh] to 192.168.50.56:8443: Cannot assign requested address (99)
Aug 08 19:04:31 login stunnel[232]: [!] Binding service [ssh] failed
Aug 08 19:04:31 login stunnel[232]: [ ] Deallocating section defaults
Aug 08 19:04:31 login stunnel[232]: [ ] Unbinding service [ssh]
Aug 08 19:04:31 login stunnel[232]: [ ] Service [ssh] closed
Aug 08 19:04:31 login stunnel[232]: [ ] Deallocating section [ssh]
Aug 08 19:04:31 login systemd[1]: stunnel.service: Control process exited, code=exited, status=1/FAILURE
Aug 08 19:04:31 login systemd[1]: stunnel.service: Failed with result 'exit-code'.
Aug 08 19:04:31 login systemd[1]: Failed to start TLS tunnel for network daemons.

This task depends upon

Closed by  Toolybird (Toolybird)
Friday, 28 April 2023, 06:28 GMT
Reason for closing:  Fixed
Additional comments about closing:  See comments
Comment by John Doe (hillbicks) - Monday, 22 February 2021, 10:29 GMT
Since this is still not solved and google lists this as the first entry when searching for "stunnel Cannot assign requested address systemd", I'm going to post my solution here:

enable systemd services
sudo systemctl enable systemd-networkd.service systemd-networkd-wait-online.service

change [Unit] section of /etc/systemd/system/multi-user.target.wants/stunnel.service
After=syslog.target systemd-networkd-wait-online.service
Wants=systemd-networkd-wait-online.service
Comment by Toolybird (Toolybird) - Friday, 28 April 2023, 06:28 GMT
The .service file comes from upstream and these days it contains "After=network-online.target" which according to [1] should mostly work.

[1] https://systemd.io/NETWORK_ONLINE/

Loading...