-
Notifications
You must be signed in to change notification settings - Fork 0
/
nftables.conf
46 lines (34 loc) · 1.15 KB
/
nftables.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/sbin/nft -f
flush ruleset
table inet filter {
chain input {
type filter hook input priority filter; policy drop;
iif lo accept comment "Accept traffic from loopback interface"
ct state established,related accept comment "Allow inbound & related packets for established connections"
jump portknock
counter drop
}
set portknock_stage1 {
type ipv4_addr;
flags timeout;
size 65536;
}
set portknock_stage2 {
type ipv4_addr;
flags timeout;
size 65536;
}
set portknock_allow {
type ipv4_addr;
flags timeout;
size 65536;
}
chain portknock {
ip saddr @portknock_allow tcp dport 22 counter accept comment "Accept TCP to SSH for correctly knocked IPs"
udp dport 7000 counter add @portknock_stage1 { ip saddr timeout 1s } comment "Portknock, stage 1"
ip saddr != @portknock_stage1 counter return comment "Portknock stage 2 not allowed"
udp dport 8000 counter add @portknock_stage2 { ip saddr timeout 1s } comment "Portknock, stage 2"
ip saddr != @portknock_stage2 counter return comment "Portknock stage 3 not allowed"
udp dport 9000 counter add @portknock_allow { ip saddr timeout 60s } comment "Portknock, stage 3"
}
}