Updating port forwarding code
parent
2a055c638e
commit
4b7a383be0
|
@ -486,13 +486,29 @@ fi
|
|||
if [ "$PORTFW" ] && [ "$NAT" ]; then
|
||||
display_c YELLOW "Adding port forward for:"
|
||||
for i in `grep -v "\#" $PORTFW`; do
|
||||
PORTADD=( ${i//:/ } )
|
||||
$IPTABLES -A PREROUTING -t nat -i ${PORTADD[0]} -p ${PORTADD[4]} -s ${PORTADD[1]} \
|
||||
--dport ${PORTADD[3]} -d ${PORTADD[2]} -j DNAT --to \
|
||||
${PORTADD[5]}:${PORTADD[6]}
|
||||
$IPTABLES -A INPUT -p ${PORTADD[4]} ${M_STATE} ${C_STATE} NEW -s ${PORTADD[1]} \
|
||||
--dport ${PORTADD[3]} -d ${PORTADD[2]} -i ${PORTADD[0]} -j ACCEPT
|
||||
display_c DEFAULT "\t${GREEN}${PORTADD[0]}:${BLUE}${PORTADD[1]}:${PURPLE}${PORTADD[2]}:${PORTADD[3]}:${PORTADD[4]}${AQUA}->${BLUE}${PORTADD[5]}:${PORTADD[6]} "
|
||||
IFS_OLD=${IFS};IFS=\:
|
||||
PORTFWADD=($i)
|
||||
IFS=${IFS_OLD}
|
||||
DSTIF=${PORTFWADD[0]}
|
||||
SRCIP=${PORTFWADD[1]}
|
||||
DSTIP=${PORTFWADD[2]}
|
||||
DSTPORT=${PORTFWADD[3]}
|
||||
DSTPROTO=${PORTFWADD[4]}
|
||||
DSTINTIP=${PORTFWADD[5]}
|
||||
DSTINTPORT=${PORTFWADD[6]}
|
||||
if [ "$DSTIF" ]; then
|
||||
DSTIF="-i ${DSTIF}"
|
||||
fi
|
||||
if [ "$SRCIP" ]; then
|
||||
SRCIP="-s ${SRCIP}"
|
||||
fi
|
||||
//PORTADD=( ${i//:/ } )
|
||||
$IPTABLES -A PREROUTING -t nat ${DSTIF} -p ${DSTPROTO} ${SRCIP} \
|
||||
--dport ${DSTPORT} -d ${DSTIP} -j DNAT --to \
|
||||
${DSTINTIP}:${DSTINTPORT}
|
||||
$IPTABLES -A INPUT -p ${DSTPROTO} ${M_STATE} ${C_STATE} NEW ${DSTIF} ${SRCIP} \
|
||||
--dport ${DSTPORT} -d ${DSTIP} -j ACCEPT
|
||||
display_c DEFAULT "\t${GREEN}${PORTFWADD[0]}:${BLUE}${PORTFWADD[1]}:${PURPLE}${PORTFWADD[2]}:${PORTFWADD[3]}:${PORTFWADD[4]}${AQUA}->${BLUE}${PORTFWADD[5]}:${PORTFWADD[6]} "
|
||||
done
|
||||
reset_color
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue