forked from f-izzo/fastgate-toolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
iptables_rules
37 lines (30 loc) · 2.03 KB
/
iptables_rules
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
# Set custom firewall rules
# Test first if rules are already present
iptables -C INPUT -i br0 -p tcp --dport 22 -m conntrack --ctstate NEW -j ACCEPT
if [ $? -eq 1 ]; then
echo "Adding firewall rules for SSH"
iptables -I INPUT 1 -i lo -j ACCEPT
iptables -I INPUT 2 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
iptables -I INPUT 3 -i br0 -p tcp --dport 22 -m conntrack --ctstate NEW -j ACCEPT
fi
## IPv6 firewall rules
# Clear existing rules
ip6tables -F INPUT
ip6tables -F FORWARD
ip6tables -F OUTPUT
ip6tables -A INPUT -m rt --rt-type 0 -j DROP
ip6tables -A FORWARD -m rt --rt-type 0 -j DROP
ip6tables -A OUTPUT -m rt --rt-type 0 -j DROP
# Filter packets to the router
ip6tables -A INPUT -i lo -j ACCEPT
ip6tables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
ip6tables -A INPUT -p icmpv6 -j ACCEPT
ip6tables -A INPUT -m conntrack --ctstate NEW -i br0 -j ACCEPT
# Filter packets to the LAN
ip6tables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
ip6tables -A FORWARD -p icmpv6 -j ACCEPT
ip6tables -A FORWARD -m conntrack --ctstate NEW -i br0 -j ACCEPT
# Set chain policy
ip6tables -P INPUT DROP
ip6tables -P FORWARD DROP
ip6tables -P OUTPUT ACCEPT