-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnft.aweb.sh
executable file
·126 lines (77 loc) · 2.17 KB
/
nft.aweb.sh
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/usr/bin/nft -f
#
# last modified 2017.06.04
#
set -o nounset
set -o errexit
#set -o noclobber
set -o noglob
flush table filter
table filter {
chain input {
type filter hook input priority 0; policy drop;
# established/related connections
ct state {established, related} accept
# invalid connections
ct state invalid drop
meta iif ens3 ip protocol tcp goto my_tcpv4
meta iif ens3 ip protocol udp goto my_udpv4
meta iif ens3 ip protocol icmp goto my_icmpv4
}
chain my_tcpv4 {
# established/related connections
ct state {established, related} accept
# invalid connections
ct state invalid drop
# bad tcp -> avoid network scanning:
tcp flags & (fin|syn) == (fin|syn) drop
tcp flags & (syn|rst) == (syn|rst) drop
tcp flags & (fin|syn|rst|psh|ack|urg) == 0 drop
tcp flags & (fin|syn|rst|psh|ack|urg) == (fin|psh|urg) drop
# loopback interface
iif lo accept
# open tcp ports: sshd, web
iif ens3 tcp dport { 23235, 80, 443 } counter accept
}
chain my_udpv4 {
# established/related connections
ct state {established, related} accept
# invalid connections
ct state invalid drop
# loopback interface
iif lo accept
}
chain my_icmpv4 {
# established/related connections
ct state {established, related} accept
# invalid connections
ct state invalid drop
#ct state {established, related} accept
# loopback interface
iif lo accept
iif ens3 icmp type { echo-request, echo-reply, destination-unreachable } counter accept
iif ens3 limit rate 10/second counter accept
}
chain forward {
type filter hook forward priority 0; policy drop;
# established/related connections
ct state {established, related} accept
# invalid connections
ct state invalid drop
}
chain output {
type filter hook output priority 0; policy accept;
counter
}
}
flush table nat
table nat {
chain prerouting {
type nat hook prerouting priority -150;
iif ens3 tcp dport 22 redirect to 2222
}
chain postrouting {
type nat hook postrouting priority -150;
}
}