]> git.ipfire.org Git - ipfire-2.x.git/blobdiff - src/initscripts/init.d/firewall
firewall: fix faulty masquerading packets
[ipfire-2.x.git] / src / initscripts / init.d / firewall
index f77bc02032bc37f36427ea2aab74ad4e92099be9..0d80e7cd6d9e4d5cc4c0e8d64b601a10345b9e42 100644 (file)
@@ -277,10 +277,16 @@ iptables_init() {
        /usr/sbin/firewall-policy
 
        # Install firewall rules for the red interface.
-       iptables_red
+       iptables_red_up
+
+       # If red has not been brought up yet, we will
+       # add the blocking rules for MASQUERADE
+       if [ ! -e "/var/ipfire/red/active" ]; then
+               iptables_red_down
+       fi
 }
 
-iptables_red() {
+iptables_red_up() {
        iptables -F REDINPUT
        iptables -F REDFORWARD
        iptables -t nat -F REDNAT
@@ -358,6 +364,18 @@ iptables_red() {
        /usr/local/bin/firewallctrl
 }
 
+iptables_red_down() {
+       # Prohibit packets to reach the masquerading rule
+       # while the wan interface is down - this is required to
+       # circumvent udp related NAT issues
+       # http://forum.ipfire.org/index.php?topic=11127.0
+       iptables -F REDFORWARD
+       iptables -A REDFORWARD -o $IFACE -j DROP
+
+       # Reload all rules.
+       /usr/local/bin/firewallctrl
+}
+
 # See how we were called.
 case "$1" in
   start)
@@ -388,9 +406,9 @@ case "$1" in
                /etc/sysconfig/firewall.local start
        fi
        ;;
-  reload)
+  reload|up)
        boot_mesg "Reloading firewall"
-       iptables_red
+       iptables_red_up
        evaluate_retval
 
        # run local firewall configuration, if present
@@ -398,6 +416,11 @@ case "$1" in
                /etc/sysconfig/firewall.local reload
        fi
        ;;
+  down)
+       boot_mesg "Disabling firewall access to RED"
+       iptables_red_down
+       evaluate_retval
+       ;;
   restart)
        # run local firewall configuration, if present
        if [ -x /etc/sysconfig/firewall.local ]; then