#315753 knockd shuts down when the interface disappears

Package:
knockd
Source:
knockd
Description:
small port-knock daemon
Submitter:
Date:
2021-12-09 20:36:02 UTC
Severity:
important
Tags:
#315753#5
Date:
2005-06-25 15:42:25 UTC
From:
To:
Short brief: my provider changes my IP every 24h. I use knockd listning
on ppp0. After IP change (I suppose it's down ppp0 then up ppp0) knockd
isn't working (ps aux | grep knock returns nothing). It may make ones
machine not accessible (when all ports are blocked and SSH is avaliable
only after knocking).
My knockd settings:
cat /etc/default/knockd
START_KNOCKD=1
KNOCKD_OPTS="-i ppp0"

Sample IP change in knockd.log:
cat /var/log/knockd.log
[2005-06-24 00:52] waiting for child processes...
[2005-06-24 00:52] shutting down

The solution seems to be restarting knockd every time the interface goes
up. I've created a script knockd and located it in /etc/ppp/ip-up.d/:
cat /etc/ppp/ip-up.d/knockd

#!/bin/sh
/etc/init.d/knockd restart

It seems to work OK now.
Haven't tested, but the same may be requied for ethx interfaces
(file knockd in /etc/network/if-up.d that restarts knockd).

#315753#10
Date:
2008-07-31 20:51:19 UTC
From:
To:
Exact same problem and exact same fix as the original reporter.
The package should come with that script.
Thanks.

#315753#17
Date:
2011-04-18 23:02:00 UTC
From:
To:
found 315753 0.5-3
retitle 315753 knockd shuts down when the interface disappears
thanks

The problem can be generalized: knockd shuts down when the interface
disappears, be it ppp0 or eth0 or whatever.

Running knock in the foreground, the following message is printed when
the interface goes down (and nothing else):

    "pcap: The interface went down"

Perhaps this condition could be handled differently, eg: waiting either
for the interface to come back up or /etc/init.d/knock stop is called?


Christian

#315753#26
Date:
2020-01-31 09:41:10 UTC
From:
To:
Gorące pozdrowienia!

Wcześniej ci pisałem, ale szkoda, że moje e-maile nie zostały do ciebie
dostarczone; niemniej jednak przesyłam to jeszcze raz poniżej.

Jestem adwokatem SANI TONY DONALD; oraz jestem prawnikiem i głównym
pełnomocnikiem pracującym w obszarach podlegających jurysdykcji sądu
rodzinnego. Zwracam się o zgodę na przedstawienie cię jako najbliższego
krewnego mojemu zmarłemu klientowi, rodakowi z twojego kraju, któremu
pomogłem w dokonaniu wpłaty o wartości inwestycyjnej (8 720 000,00 USD)
Osiem milionów, siedemset dwadzieścia tysięcy dolarów amerykańskich w
firmie finansowej.

Poinformowałem firmę finansową o jego przekazaniu wraz z rodziną w drodze
do pobliskiego kraju i poinstruowano mnie, aby przedstawić każdego
dostępnego członka jego rodziny lub bliskiego krewnego, aby otrzymać
fundusze.

Moim powodem skontaktowania się z Tobą w tej sprawie jest to, że masz takie
samo nazwisko jak mój zmarły klient. I znowu nie ma zarejestrowanego
spadkobiercy w jego pliku konta w firmie finansowej.

Chcę, aby lewy fundusz został przeniesiony na twoją opiekę jako jego
spadkobierca, zanim zostanie skonfiskowany przez kierownictwo firmy
finansowej.

Proszę o kontakt w celu uzyskania dalszych informacji.

Z poważaniem,
Barr. SANI TONY DONALD. (Esq).

#315753#31
Date:
2021-12-06 13:53:47 UTC
From:
To:
Hi list,

This is still happening in Bullseye: knockd.service shuts down with the
interface citing "pcap: The interface went down" and does not get
restarted when the interface comes up again. A simple systemctl restart
knockd does the trick, but this is not triggered automatically when you
still use the networking.service (ifupdown method).

So I tried a knockd.service.d override that was supposed to bind knockd
to the relevant interface [eth1] with:

[Unit]
BindsTo=ifup@eth1.service
After=ifup@eth1.service

This fails as well with exit status 15 (same exit code) and does not
restart the unit when ifup@eth1.service is triggered successfully again.

I ended up disabling knockd.service and reverting back to an ifupdown
script solution (see attachment.)

I used setcap 'cap_net_admin,cap_net_raw,cap_sys_module=eip' to drop the
knockd binary capabilities to the same level the knockd.service suggested.

Dropping the networking.service in favour of NetworkManager or
systemd-networkd might be a good idea, but I'm not there yet with my
setup, so I could not test how the knockd.service behaves then.

#315753#36
Date:
2021-12-06 08:12:56 UTC
From:
To:
Hi list

This is still happening in Bullseye: knockd shuts down with the
interface citing "pcap: The interface went down"

and does not get restarted when the interface comes up again. A simple
systemctl restart knockd does the trick, but this is

not triggered automatically when you still use the networking.service
(ifup method)

So I tried a knockd.service.d override that should bind knockd to the
relevant interface with:

[Unit]

BindsTo=ifup@eth1.service

This fails as well with exit status 15.



On Tue, 19 Apr 2011 01:02:00 +0200 Christian Kastner <debian@kvr.at> wrote:

 >
 > retitle 315753 knockd shuts down when the interface disappears
 >
 > The problem can be generalized: knockd shuts down when the interface
 > disappears, be it ppp0 or eth0 or whatever.
 >
 > Running knock in the foreground, the following message is printed when
 > the interface goes down (and nothing else):
 >
 > "pcap: The interface went down"
 >
 > Perhaps this condition could be handled differently, eg: waiting either
 > for the interface to come back up or /etc/init.d/knock stop is called?
 >
 >