knockd issue

This forum is for discussion about general software issues.

knockd issue

Postby quark » Mon Nov 29, 2021 12:29 pm

I installed knockd on a Pi2 and there seems to be an issue with the knockd service. On boot it starts and I can see it loaded but it doesn't react to any knock.
The service file is in /usr/lib/systemd/system/knockd.service
I added ExecStartPre=/bin/sleep 5 right before the ExecStart line and that seems to fix it. It waits around 5 seconds before starting. Might be a timing issue, but it works like this.
I'm making this thread mostly for anyone else having this issue.
quark
 
Posts: 59
Joined: Thu Nov 25, 2021 8:26 am

Re: knockd issue

Postby pteromys » Sun Dec 05, 2021 4:32 am

Thanks for posting this solution! I'm wondering if there's something about the libpcap listeners getting disconnected if the interface gets destroyed and re-created. I haven't really taken the time to test out my hypothesis—just enough to have come up with this alternative so that we have some defense in depth:

For ifplugd/netctl users, you can add a service restart command to /etc/netctl/eth0, e.g. mine says:

$this->bbcode_second_pass_code('', 'Description='A basic dhcp ethernet connection'
Interface=eth0
Connection=ethernet
IP=dhcp
ExecUpPost='systemctl restart knockd@eth0.service; /usr/bin/ntpd -gq || true'

## for DHCPv6
#IP6=dhcp
## for IPv6 autoconfiguration
#IP6=stateless
')
pteromys
 
Posts: 1
Joined: Sun Dec 05, 2021 4:25 am

Re: knockd issue

Postby graysky » Sun Dec 05, 2021 10:18 am

Adding a startup delay is likely masking some race condition. It seems that Arch Linux is providing the service, not upstream so the problem could be there.

1. Remove your customization
2. Try this drop in and let me know if it solves the issue:
$this->bbcode_second_pass_code('', '
# systemctl edit knockd

[Unit]
After=
After=network-online.target
Wants=network-online.target
')
graysky
Developer
 
Posts: 1727
Joined: Sun Jun 26, 2011 6:56 am
Location: /run/user/1000

Re: knockd issue

Postby quark » Sun Jan 09, 2022 4:35 pm

Yes this seems to work, waiting for network-online.target.
quark
 
Posts: 59
Joined: Thu Nov 25, 2021 8:26 am


Return to General

Who is online

Users browsing this forum: No registered users and 9 guests