r00igev@@r
Honorary Master
- Joined
- Dec 14, 2009
- Messages
- 15,640
- Reaction score
- 14,157
- Location
- Draadloos Bantha poo doo in 4ways
I moved ssh to another port and have it now access is rejected with a host unreachable on port 22.
I now have this little rule to enable ssh on the new port. I do a ping -l 1001 <system> and my IP can access <systm> for a couple of hours.
/etc/nftables/nftables_knock.nft
I now have this little rule to enable ssh on the new port. I do a ping -l 1001 <system> and my IP can access <systm> for a couple of hours.
/etc/nftables/nftables_knock.nft
Code:
table ip knock {
set exceptions {
type ipv4_addr
flags interval
elements = { 127.0.0.0/8, 192.168.88.0/24, x.y.z.0/24 }
}
set doorbell {
type ipv4_addr
flags dynamic, timeout
timeout 8h
}
chain input {
type filter hook input priority 0; iifname "ens18";
# Accept TCP traffic on port 12345 for IP addresses in the "exceptions" set
ip saddr @exceptions tcp dport 12345 accept
ip length > 1000 ip length < 1100 icmp type { echo-request, echo-reply } add @doorbell { ip saddr }
# Drop TCP traffic on port 12345 only for IP addresses not in the "doorbell" set
ip saddr != @doorbell tcp dport 12345 drop
}
}