diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2010-09-28 10:42:56 +0000 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2010-09-28 10:42:56 +0000 |
commit | 6a335579b8e63886c2beed4aee72ab2f335a7d2e (patch) | |
tree | 01abaef74996070e6b60c987b51d9a12da73dbff /package/firewall/files/lib/core_redirect.sh | |
parent | 2fdc8aea047bcc7ca142e2fc960263647e79eda1 (diff) | |
download | upstream-6a335579b8e63886c2beed4aee72ab2f335a7d2e.tar.gz upstream-6a335579b8e63886c2beed4aee72ab2f335a7d2e.tar.bz2 upstream-6a335579b8e63886c2beed4aee72ab2f335a7d2e.zip |
fireall: - support negations for src_ip, dest_ip, src_dip options in rules and redirects - add NOTRACK target to rule sections, allows to define fine grained notrack rules
SVN-Revision: 23141
Diffstat (limited to 'package/firewall/files/lib/core_redirect.sh')
-rw-r--r-- | package/firewall/files/lib/core_redirect.sh | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/package/firewall/files/lib/core_redirect.sh b/package/firewall/files/lib/core_redirect.sh index 3a37bb7ee6..9654e7177c 100644 --- a/package/firewall/files/lib/core_redirect.sh +++ b/package/firewall/files/lib/core_redirect.sh @@ -41,7 +41,7 @@ fw_load_redirect() { nataddr="$redirect_dest_ip" fw_get_port_range natports "$redirect_dest_port" "-" - srcdaddr="${redirect_src_dip:+$redirect_src_dip/$redirect_src_dip_prefixlen}" + fw_get_negation srcdaddr '-d' "${redirect_src_dip:+$redirect_src_dip/$redirect_src_dip_prefixlen}" fw_get_port_range srcdports "$redirect_src_dport" ":" list_contains FW_CONNTRACK_ZONES $redirect_src || \ @@ -60,7 +60,7 @@ fw_load_redirect() { nataddr="$redirect_src_dip" fw_get_port_range natports "$redirect_src_dport" "-" - srcdaddr="${redirect_dest_ip:+$redirect_dest_ip/$redirect_dest_ip_prefixlen}" + fw_get_negation srcdaddr '-d' "${redirect_dest_ip:+$redirect_dest_ip/$redirect_dest_ip_prefixlen}" fw_get_port_range srcdports "$redirect_dest_port" ":" list_contains FW_CONNTRACK_ZONES $redirect_dest || \ @@ -74,21 +74,24 @@ fw_load_redirect() { local mode fw_get_family_mode mode ${redirect_family:-x} ${redirect_src:-$redirect_dest} I - local srcaddr="${redirect_src_ip:+$redirect_src_ip/$redirect_src_ip_prefixlen}" + local srcaddr + fw_get_negation srcaddr '-s' "${redirect_src_ip:+$redirect_src_ip/$redirect_src_ip_prefixlen}" + local srcports fw_get_port_range srcports "$redirect_src_port" ":" - local destaddr="${redirect_dest_ip:+$redirect_dest_ip/$redirect_dest_ip_prefixlen}" + local destaddr + fw_get_negation destaddr '-d' "${redirect_dest_ip:+$redirect_dest_ip/$redirect_dest_ip_prefixlen}" + local destports fw_get_port_range destports "${redirect_dest_port:-$redirect_src_dport}" ":" [ "$redirect_proto" == "tcpudp" ] && redirect_proto="tcp udp" for redirect_proto in $redirect_proto; do fw add $mode n $natchain $redirect_target ^ { $redirect_src_ip $redirect_dest_ip } { \ + $srcaddr $srcdaddr \ ${redirect_proto:+-p $redirect_proto} \ - ${srcaddr:+-s $srcaddr} \ ${srcports:+--sport $srcports} \ - ${srcdaddr:+-d $srcdaddr} \ ${srcdports:+--dport $srcdports} \ ${redirect_src_mac:+-m mac --mac-source $redirect_src_mac} \ $natopt $nataddr${natports:+:$natports} \ @@ -96,10 +99,9 @@ fw_load_redirect() { [ -n "$destaddr" ] && \ fw add $mode f ${fwdchain:-forward} ACCEPT ^ { $redirect_src_ip $redirect_dest_ip } { \ + $srcaddr $destaddr \ ${redirect_proto:+-p $redirect_proto} \ - ${srcaddr:+-s $srcaddr} \ ${srcports:+--sport $srcports} \ - ${destaddr:+-d $destaddr} \ ${destports:+--dport $destports} \ ${redirect_src_mac:+-m mac --mac-source $redirect_src_mac} \ } |