3 WAN
=$
(nvram get wan_ifname
)
4 LAN
=$
(nvram get lan_ifname
)
7 for T
in filter nat mangle
; do
12 iptables
-N input_rule
13 iptables
-N output_rule
14 iptables
-N forwarding_rule
16 iptables
-t nat
-N prerouting_rule
17 iptables
-t nat
-N postrouting_rule
19 ### Allow SSH from WAN
20 # iptables -t nat -A prerouting_rule -i $WAN -p tcp --dport 22 -j ACCEPT
21 # iptables -A input_rule -i $WAN -p tcp --dport 22 -j ACCEPT
24 # iptables -t nat -A prerouting_rule -i $WAN -p tcp --dport 22 -j DNAT --to 192.168.1.2
25 # iptables -A forwarding_rule -i $WAN -p tcp --dport 22 -d 192.168.1.2 -j ACCEPT
27 ### DMZ (should be placed after port forwarding / accept rules)
28 # iptables -t nat -A prerouting_rule -i $WAN -j DNAT --to 192.168.1.2
29 # iptables -A forwarding_rule -i $WAN -d 192.168.1.2 -j ACCEPT
32 ### (connections with the router as destination)
35 iptables
-P INPUT DROP
36 iptables
-A INPUT
-m state
--state INVALID
-j DROP
37 iptables
-A INPUT
-m state
--state RELATED
,ESTABLISHED
-j ACCEPT
38 iptables
-A INPUT
-p tcp
--syn --tcp-option \
! 2 -j DROP
41 iptables
-A INPUT
-i \
! $WAN -j ACCEPT
# allow from lan/wifi interfaces
42 iptables
-A INPUT
-p icmp
-j ACCEPT
# allow ICMP
43 iptables
-A INPUT
-p gre
-j ACCEPT
# allow GRE
45 # insert accept rule or to jump to new accept-check table here
47 iptables
-A INPUT
-j input_rule
49 # reject (what to do with anything not allowed earlier)
50 iptables
-A INPUT
-p tcp
-j REJECT
--reject-with tcp-reset
51 iptables
-A INPUT
-j REJECT
--reject-with icmp-port-unreachable
54 ### (connections with the router as source)
57 iptables
-P OUTPUT DROP
58 iptables
-A OUTPUT
-m state
--state INVALID
-j DROP
59 iptables
-A OUTPUT
-m state
--state RELATED
,ESTABLISHED
-j ACCEPT
62 iptables
-A OUTPUT
-j ACCEPT
#allow everything out
64 # insert accept rule or to jump to new accept-check table here
66 iptables
-A OUTPUT
-j output_rule
68 # reject (what to do with anything not allowed earlier)
69 iptables
-A OUTPUT
-p tcp
-j REJECT
--reject-with tcp-reset
70 iptables
-A OUTPUT
-j REJECT
--reject-with icmp-port-unreachable
73 ### (connections routed through the router)
76 iptables
-P FORWARD DROP
77 iptables
-A FORWARD
-m state
--state INVALID
-j DROP
78 iptables
-A FORWARD
-m state
--state RELATED
,ESTABLISHED
-j ACCEPT
79 iptables
-A FORWARD
-p tcp
--tcp-flags SYN
,RST SYN
-j TCPMSS
--clamp-mss-to-pmtu
82 iptables
-A FORWARD
-i br0
-o br0
-j ACCEPT
83 iptables
-A FORWARD
-i $LAN -o $WAN -j ACCEPT
85 # insert accept rule or to jump to new accept-check table here
87 iptables
-A FORWARD
-j forwarding_rule
89 # reject (what to do with anything not allowed earlier)
90 # uses the default -P DROP
93 iptables
-t nat
-A PREROUTING
-j prerouting_rule
94 iptables
-t nat
-A POSTROUTING
-j postrouting_rule
95 iptables
-t nat
-A POSTROUTING
-o $WAN -j MASQUERADE
This page took 0.051803 seconds and 5 git commands to generate.