4 WAN
=$
(nvram get wan_ifname
)
5 LAN
=$
(nvram get lan_ifname
)
8 for T
in filter nat mangle
; do
13 iptables
-N input_rule
14 iptables
-N output_rule
15 iptables
-N forwarding_rule
17 iptables
-t nat
-N prerouting_rule
18 iptables
-t nat
-N postrouting_rule
20 ### Allow SSH from WAN
21 # iptables -t nat -A prerouting_rule -i $WAN -p tcp --dport 22 -j ACCEPT
22 # iptables -A input_rule -i $WAN -p tcp --dport 22 -j ACCEPT
25 # iptables -t nat -A prerouting_rule -i $WAN -p tcp --dport 22 -j DNAT --to 192.168.1.2
26 # iptables -A forwarding_rule -i $WAN -p tcp --dport 22 -d 192.168.1.2 -j ACCEPT
28 ### DMZ (should be placed after port forwarding / accept rules)
29 # iptables -t nat -A prerouting_rule -i $WAN -j DNAT --to 192.168.1.2
30 # iptables -A forwarding_rule -i $WAN -d 192.168.1.2 -j ACCEPT
33 ### (connections with the router as destination)
36 iptables
-P INPUT DROP
37 iptables
-A INPUT
-m state
--state INVALID
-j DROP
38 iptables
-A INPUT
-m state
--state RELATED
,ESTABLISHED
-j ACCEPT
39 iptables
-A INPUT
-p tcp
--syn --tcp-option \
! 2 -j DROP
42 iptables
-A INPUT
-i \
! $WAN -j ACCEPT
# allow from lan/wifi interfaces
43 iptables
-A INPUT
-p icmp
-j ACCEPT
# allow ICMP
44 iptables
-A INPUT
-p gre
-j ACCEPT
# allow GRE
46 # insert accept rule or to jump to new accept-check table here
48 iptables
-A INPUT
-j input_rule
50 # reject (what to do with anything not allowed earlier)
51 iptables
-A INPUT
-p tcp
-j REJECT
--reject-with tcp-reset
52 iptables
-A INPUT
-j REJECT
--reject-with icmp-port-unreachable
55 ### (connections with the router as source)
58 iptables
-P OUTPUT DROP
59 iptables
-A OUTPUT
-m state
--state INVALID
-j DROP
60 iptables
-A OUTPUT
-m state
--state RELATED
,ESTABLISHED
-j ACCEPT
63 iptables
-A OUTPUT
-j ACCEPT
#allow everything out
65 # insert accept rule or to jump to new accept-check table here
67 iptables
-A OUTPUT
-j output_rule
69 # reject (what to do with anything not allowed earlier)
70 iptables
-A OUTPUT
-p tcp
-j REJECT
--reject-with tcp-reset
71 iptables
-A OUTPUT
-j REJECT
--reject-with icmp-port-unreachable
74 ### (connections routed through the router)
77 iptables
-P FORWARD DROP
78 iptables
-A FORWARD
-m state
--state INVALID
-j DROP
79 iptables
-A FORWARD
-m state
--state RELATED
,ESTABLISHED
-j ACCEPT
80 iptables
-A FORWARD
-p tcp
--tcp-flags SYN
,RST SYN
-j TCPMSS
--clamp-mss-to-pmtu
83 iptables
-A FORWARD
-i br0
-o br0
-j ACCEPT
84 iptables
-A FORWARD
-i $LAN -o $WAN -j ACCEPT
86 # insert accept rule or to jump to new accept-check table here
88 iptables
-A FORWARD
-j forwarding_rule
90 # reject (what to do with anything not allowed earlier)
91 # uses the default -P DROP
94 iptables
-t nat
-A PREROUTING
-j prerouting_rule
95 iptables
-t nat
-A POSTROUTING
-j postrouting_rule
96 iptables
-t nat
-A POSTROUTING
-o $WAN -j MASQUERADE
This page took 0.054973 seconds and 5 git commands to generate.