1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2024-10-01 11:04:10 +03:00

[package] firwall: fix nat reflection for zones covering multiple networks

git-svn-id: svn://svn.openwrt.org/openwrt/trunk@22442 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
jow 2010-07-31 13:25:56 +00:00
parent da83ad5b95
commit 4fbc2d59b9

View File

@ -1,5 +1,4 @@
#!/bin/sh
# Setup NAT reflection rules
. /etc/functions.sh
@ -16,6 +15,26 @@ if [ "$ACTION" = "ifup" ] && [ "$INTERFACE" = "wan" ]; then
iptables -t nat -A postrouting_rule -j nat_reflection_out
}
find_networks() {
find_networks_cb() {
local cfg="$1"
local zone="$2"
local name
config_get name "$cfg" name
[ "$name" = "$zone" ] && {
local network
config_get network "$cfg" network
echo ${network:-$zone}
return 1
}
}
config_foreach find_networks_cb zone "$1"
}
setup_fwd() {
local cfg="$1"
@ -26,8 +45,10 @@ if [ "$ACTION" = "ifup" ] && [ "$INTERFACE" = "wan" ]; then
local dest
config_get dest "$cfg" dest "lan"
local lanip=$(uci -P/var/state get network.$dest.ipaddr)
local lanmk=$(uci -P/var/state get network.$dest.netmask)
local net
for net in $(find_networks "$dest"); do
local lanip=$(uci -P/var/state get network.$net.ipaddr)
local lanmk=$(uci -P/var/state get network.$net.netmask)
local proto
config_get proto "$cfg" proto
@ -70,6 +91,7 @@ if [ "$ACTION" = "ifup" ] && [ "$INTERFACE" = "wan" ]; then
;;
esac
done
done
}
}