mirror of https://github.com/hak5/openwrt.git
parent
1979082212
commit
20216aa44d
|
@ -188,10 +188,7 @@ fw_rule() {
|
||||||
[ -z "$target" ] && target=DROP
|
[ -z "$target" ] && target=DROP
|
||||||
[ -n "$src" ] && ZONE=zone_$src || ZONE=INPUT
|
[ -n "$src" ] && ZONE=zone_$src || ZONE=INPUT
|
||||||
[ -n "$dest" ] && TARGET=zone_${dest}_$target || TARGET=$target
|
[ -n "$dest" ] && TARGET=zone_${dest}_$target || TARGET=$target
|
||||||
[ -n "$dest_port" -a -z "$proto" ] && { \
|
add_rule() {
|
||||||
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; }
|
|
||||||
$IPTABLES -I $ZONE 1 \
|
$IPTABLES -I $ZONE 1 \
|
||||||
${proto:+-p $proto} \
|
${proto:+-p $proto} \
|
||||||
${src_ip:+-s $src_ip} \
|
${src_ip:+-s $src_ip} \
|
||||||
|
@ -200,6 +197,15 @@ fw_rule() {
|
||||||
${dest_ip:+-d $dest_ip} \
|
${dest_ip:+-d $dest_ip} \
|
||||||
${dest_port:+--dport $dest_port} \
|
${dest_port:+--dport $dest_port} \
|
||||||
-j $TARGET
|
-j $TARGET
|
||||||
|
}
|
||||||
|
[ "$proto" == "tcpudp" -o -z "$proto" ] && {
|
||||||
|
proto=tcp
|
||||||
|
add_rule
|
||||||
|
proto=udp
|
||||||
|
add_rule
|
||||||
|
return
|
||||||
|
}
|
||||||
|
add_rule
|
||||||
}
|
}
|
||||||
|
|
||||||
fw_forwarding() {
|
fw_forwarding() {
|
||||||
|
@ -221,7 +227,7 @@ fw_redirect() {
|
||||||
local src_dport
|
local src_dport
|
||||||
local src_mac
|
local src_mac
|
||||||
local dest_ip
|
local dest_ip
|
||||||
local dest_port
|
local dest_port dest_port2
|
||||||
local proto
|
local proto
|
||||||
|
|
||||||
config_get src $1 src
|
config_get src $1 src
|
||||||
|
@ -234,10 +240,6 @@ fw_redirect() {
|
||||||
config_get proto $1 proto
|
config_get proto $1 proto
|
||||||
[ -z "$src" -o -z "$dest_ip" ] && { \
|
[ -z "$src" -o -z "$dest_ip" ] && { \
|
||||||
echo "redirect needs src and dest_ip"; return ; }
|
echo "redirect needs src and dest_ip"; return ; }
|
||||||
[ -n "$dest_port" -a -z "$proto" ] && { \
|
|
||||||
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_first=${src_port%-*}
|
||||||
src_port_last=${src_port#*-}
|
src_port_last=${src_port#*-}
|
||||||
|
@ -249,6 +251,13 @@ fw_redirect() {
|
||||||
[ "$src_dport_first" -ne "$src_dport_last" ] && { \
|
[ "$src_dport_first" -ne "$src_dport_last" ] && { \
|
||||||
src_dport="$src_dport_first:$src_dport_last"; }
|
src_dport="$src_dport_first:$src_dport_last"; }
|
||||||
|
|
||||||
|
destport2=destport
|
||||||
|
dest_port_first=${dest_port2%-*}
|
||||||
|
dest_port_last=${dest_port2#*-}
|
||||||
|
[ "$dest_port_first" -ne "$dest_port_last" ] && { \
|
||||||
|
dest_port2="$dest_port_first:$dest_port_last"; }
|
||||||
|
|
||||||
|
add_rule() {
|
||||||
$IPTABLES -A zone_${src}_prerouting -t nat \
|
$IPTABLES -A zone_${src}_prerouting -t nat \
|
||||||
${proto:+-p $proto} \
|
${proto:+-p $proto} \
|
||||||
${src_ip:+-s $src_ip} \
|
${src_ip:+-s $src_ip} \
|
||||||
|
@ -257,19 +266,23 @@ fw_redirect() {
|
||||||
${src_mac:+-m mac --mac-source $src_mac} \
|
${src_mac:+-m mac --mac-source $src_mac} \
|
||||||
-j DNAT --to-destination $dest_ip${dest_port:+:$dest_port}
|
-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 \
|
$IPTABLES -I zone_${src}_forward 1 \
|
||||||
${proto:+-p $proto} \
|
${proto:+-p $proto} \
|
||||||
-d $dest_ip \
|
-d $dest_ip \
|
||||||
${src_ip:+-s $src_ip} \
|
${src_ip:+-s $src_ip} \
|
||||||
${src_port:+--sport $src_port} \
|
${src_port:+--sport $src_port} \
|
||||||
${dest_port:+--dport $dest_port} \
|
${dest_port2:+--dport $dest_port2} \
|
||||||
${src_mac:+-m mac --mac-source $src_mac} \
|
${src_mac:+-m mac --mac-source $src_mac} \
|
||||||
-j ACCEPT
|
-j ACCEPT
|
||||||
|
}
|
||||||
|
[ "$proto" == "tcpudp" -o -z "$proto" ] && {
|
||||||
|
proto=tcp
|
||||||
|
add_rule
|
||||||
|
proto=udp
|
||||||
|
add_rule
|
||||||
|
return
|
||||||
|
}
|
||||||
|
add_rule
|
||||||
}
|
}
|
||||||
|
|
||||||
fw_include() {
|
fw_include() {
|
||||||
|
|
Loading…
Reference in New Issue