aboutsummaryrefslogtreecommitdiffstats
path: root/package
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2012-01-08 15:29:24 +0000
committerJo-Philipp Wich <jow@openwrt.org>2012-01-08 15:29:24 +0000
commit457062fb537f1aae92b81b0483fbe3db821b2291 (patch)
treec1e47af31649e18e05b988aeaddb3ae3581172ad /package
parent63b45c1a5d8d59c5f4a6c26542fa51d1b89a7fd0 (diff)
downloadupstream-457062fb537f1aae92b81b0483fbe3db821b2291.tar.gz
upstream-457062fb537f1aae92b81b0483fbe3db821b2291.tar.bz2
upstream-457062fb537f1aae92b81b0483fbe3db821b2291.zip
[package] firewall: add support for "local" port forwards which target an internal address on the router itself
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@29687 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package')
-rw-r--r--package/firewall/Makefile4
-rw-r--r--package/firewall/files/lib/core_redirect.sh15
2 files changed, 15 insertions, 4 deletions
diff --git a/package/firewall/Makefile b/package/firewall/Makefile
index 3c5e10fe9d..746cca4882 100644
--- a/package/firewall/Makefile
+++ b/package/firewall/Makefile
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2008-2011 OpenWrt.org
+# Copyright (C) 2008-2012 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=firewall
PKG_VERSION:=2
-PKG_RELEASE:=43
+PKG_RELEASE:=44
include $(INCLUDE_DIR)/package.mk
diff --git a/package/firewall/files/lib/core_redirect.sh b/package/firewall/files/lib/core_redirect.sh
index a3e70d40d7..fe396c1c12 100644
--- a/package/firewall/files/lib/core_redirect.sh
+++ b/package/firewall/files/lib/core_redirect.sh
@@ -34,7 +34,17 @@ fw_load_redirect() {
return 0
}
- fwdchain="zone_${redirect_src}${redirect_dest_ip:+_forward}"
+ fwdopt=""
+ fwdchain=""
+
+ # Check whether only ports are given or whether the given dest ip is local,
+ # in this case match only DNATed traffic and allow it on input, not forward
+ if [ -z "$redirect_dest_ip" ] || /sbin/ifconfig | grep -qE "addr:${redirect_dest_ip//./\\.}\b"; then
+ fwdopt="-m conntrack --ctstate DNAT"
+ fwdchain="zone_${redirect_src}"
+ else
+ fwdchain="zone_${redirect_src}_forward"
+ fi
natopt="--to-destination"
natchain="zone_${redirect_src}_prerouting"
@@ -106,10 +116,11 @@ fw_load_redirect() {
fw add $mode f ${fwdchain:-forward} ACCEPT + \
{ $redirect_src_ip $redirect_dest_ip } { \
- $srcaddr ${destaddr:--m conntrack --ctstate DNAT} \
+ $srcaddr $destaddr \
$pr \
$srcports $destports \
${sm:+-m mac $sm} \
+ $fwdopt \
$redirect_extra \
}
done