summaryrefslogtreecommitdiff
path: root/package/firewall/files/uci_firewall.sh
diff options
context:
space:
mode:
authorcyrus <cyrus@3c298f89-4303-0410-b956-a3cf2f4a3e73>2008-08-27 14:04:52 +0000
committercyrus <cyrus@3c298f89-4303-0410-b956-a3cf2f4a3e73>2008-08-27 14:04:52 +0000
commit101992b80b8f18c0022c1d346b23617d400092f1 (patch)
treef84c90c079e4f334ccb2097847755d3ee7a2badf /package/firewall/files/uci_firewall.sh
parent4927575ba56532eef9bf01072f562e7f40f7dd70 (diff)
firewall: Added support for port-ranges as firstPort-lastPort to redirect sections
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@12396 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/firewall/files/uci_firewall.sh')
-rwxr-xr-xpackage/firewall/files/uci_firewall.sh17
1 files changed, 17 insertions, 0 deletions
diff --git a/package/firewall/files/uci_firewall.sh b/package/firewall/files/uci_firewall.sh
index f6e82bcb69..c488c19424 100755
--- a/package/firewall/files/uci_firewall.sh
+++ b/package/firewall/files/uci_firewall.sh
@@ -229,6 +229,17 @@ fw_redirect() {
echo "dport may only be used it proto is defined"; return; }
[ -n "$src_port" -a -z "$proto" ] && { \
echo "sport may only be used it proto is defined"; return; }
+
+ src_port_first=${src_port%-*}
+ src_port_last=${src_port#*-}
+ [ "$src_port_first" -ne "$src_port_last" ] && { \
+ src_port="$src_port_first:$src_port_last"; }
+
+ src_dport_first=${src_dport%-*}
+ src_dport_last=${src_dport#*-}
+ [ "$src_dport_first" -ne "$src_dport_last" ] && { \
+ src_dport="$src_dport_first:$src_dport_last"; }
+
$IPTABLES -A zone_${src}_prerouting -t nat \
${proto:+-p $proto} \
${src_ip:+-s $src_ip} \
@@ -236,6 +247,12 @@ fw_redirect() {
${src_dport:+--dport $src_dport} \
${src_mac:+-m mac --mac-source $src_mac} \
-j DNAT --to-destination $dest_ip${dest_port:+:$dest_port}
+
+ dest_port_first=${dest_port%-*}
+ dest_port_last=${dest_port#*-}
+ [ "$dest_port_first" -ne "$dest_port_last" ] && { \
+ dest_port="$dest_port_first:$dest_port_last"; }
+
$IPTABLES -I zone_${src}_forward 1 \
${proto:+-p $proto} \
-d $dest_ip \