revert bad firewall patch
[openwrt/svn-archive/archive.git] / openwrt / package / base-files / default / etc / init.d / S45firewall
index 8350ccbfefa1f5dd6c0b41f988a7a4f71a8707c0..8789fbab60e08fc5ba1cfe7c8dec9c4e649c0e7e 100755 (executable)
@@ -1,13 +1,17 @@
 #!/bin/sh
 
 ## Please make changes in /etc/firewall.user
+${FAILSAFE:+exit}
 
 . /etc/functions.sh
+. /etc/network.overrides
+[ "$FAILSAFE" != "true" -a -e /etc/config/network ] && . /etc/config/network
+
 WAN=$(nvram get wan_ifname)
 LAN=$(nvram get lan_ifname)
 
 ## CLEAR TABLES
-for T in filter nat mangle; do
+for T in filter nat; do
   iptables -t $T -F
   iptables -t $T -X
 done
@@ -34,7 +38,7 @@ iptables -t nat -N postrouting_rule
   iptables -A INPUT -j input_rule
 
   # allow
-  iptables -A INPUT -i \! $WAN -j ACCEPT       # allow from lan/wifi interfaces 
+  iptables -A INPUT ${WAN:+-i \! $WAN} -j ACCEPT       # allow from lan/wifi interfaces 
   iptables -A INPUT -p icmp    -j ACCEPT       # allow ICMP
   iptables -A INPUT -p gre     -j ACCEPT       # allow GRE
 
@@ -78,7 +82,6 @@ iptables -t nat -N postrouting_rule
 
   # allow
   iptables -A FORWARD -i br0 -o br0 -j ACCEPT
-  iptables -A FORWARD -i $LAN -o $WAN -j ACCEPT
 
   # reject (what to do with anything not allowed earlier)
   # uses the default -P DROP
@@ -86,7 +89,7 @@ iptables -t nat -N postrouting_rule
 ### MASQ
   iptables -t nat -A PREROUTING -j prerouting_rule
   iptables -t nat -A POSTROUTING -j postrouting_rule
-  iptables -t nat -A POSTROUTING -o $WAN -j MASQUERADE
+  [ -z "$WAN" ] || iptables -t nat -A POSTROUTING -o $WAN -j MASQUERADE
 
 ## USER RULES
 [ -f /etc/firewall.user ] && . /etc/firewall.user