The knock is built on the logging you learned in Phase 1. One firewall rule logs any packet with the knock’s odd flags going to the knock ports. The watcher reads that log, and opens the door when the sequence is right.
1. Log the knock packets
Insert this as rule 5, before the drop-log rule. --tcp-flags ALL FIN,PSH,URG matches packets with exactly those three flags set and no others, a combination no real connection ever uses.
2. Start the watcher
3. Start a capture of the knock packets
4. Knock from client-a
The knock command sends one packet per port and prints each one.
5. Read what the watcher saw
6. Scan again, from both clients
Do this within 60 seconds of the knock, while the door is open.
7. Sign in from client-a
Knock again first if the 60 seconds have passed. Then sign in (password LabOnly-2026) and stay signed in for the next step’s test, or type exit.
8. Stop the capture
You’ll use it in step 5.
You should see
The watcher’s log:
10.10.10.11: knock 1 of 4 (port 4747)
10.10.10.11: knock 2 of 4 (port 3043)
10.10.10.11: knock 3 of 4 (port 3043)
10.10.10.11: knock 4 of 4 (port 9034)
10.10.10.11: DOOR OPEN to ports 22,3389 for 60s
- client-a’s scan:
22/tcp openand3389/tcp open. - client-b’s scan, at the same moment: both still
filtered. - About a minute later, in the watcher’s log:
10.10.10.11: door closed (sessions already open stay up).
To see the door itself, list fw’s rules during the 60 seconds: rule 3 is ACCEPT ... 10.10.10.11 ... multiport dports 22,3389 ... /* knock door */.
What it means
The knock opened the door for one address only. The outsider, scanning at the same moment, still sees nothing. That’s the strength of the design: the services are invisible until the right pattern arrives, and only to whoever sent it.