Added external IP to port forwarding.

master
bbruns 2010-08-26 21:49:16 +00:00
parent dc2d35f95d
commit 5a3e6086b0
4 changed files with 13 additions and 10 deletions

View File

@ -29,8 +29,6 @@ if [ $COMPAT_CONFIG == "1" ]; then
MODPROBE=`which modprobe`
fi
# ANSI color sequences
BLUE="\E[34m"
GREEN="\E[32m"

View File

@ -1,3 +1,8 @@
# Config file version. Don't change this. Will be used some day to
# figure out if we need to alert the user that they need to redo their
# config file.
CONFIG_VERSION=0.9
# This is for testing purposes.
IPTABLES=/bin/true
IP6TABLES=/bin/true

View File

@ -1,3 +1,3 @@
# Format is:
# External interface:External port:internal ip:internal port
#eth0:8080:tcp:192.168.0.100:80
# External interface:External IP:External port:Internal ip:Internal port
#eth0:4.2.2.1:8080:tcp:192.168.0.100:80

View File

@ -333,12 +333,12 @@ if [ $PORTFW ] && [ $NAT ]; then
display_c YELLOW "Adding port forward for: " N
for i in `grep -v "\#" $PORTFW`; do
PORTADD=( ${i//:/ } )
$IPTABLES -A PREROUTING -t nat -i ${PORTADD[0]} -p ${PORTADD[2]} \
--dport ${PORTADD[1]} -j DNAT --to \
${PORTADD[3]}:${PORTADD[4]}
$IPTABLES -A INPUT -p ${PORTADD[2]} -m state --state NEW \
--dport ${PORTADD[1]} -i ${PORTADD[0]} -j ACCEPT
echo -en "${GREEN}${PORTADD[0]}:${PURPLE}${PORTADD[1]}:${PORTADD[2]}${AQUA}->${BLUE}${PORTADD[3]}:${PORTADD[4]} "
$IPTABLES -A PREROUTING -t nat -i ${PORTADD[0]} -p ${PORTADD[3]} \
--dport ${PORTADD[2]} -d {PORTADD[1]} -j DNAT --to \
${PORTADD[4]}:${PORTADD[5]}
$IPTABLES -A INPUT -p ${PORTADD[3]} -m state --state NEW \
--dport ${PORTADD[2]} -i ${PORTADD[0]} -j ACCEPT
echo -en "${GREEN}${PORTADD[0]}:${PURPLE}${PORTADD[1]}:${PORTADD[2]}:${PORTADD[3]}${AQUA}->${BLUE}${PORTADD[4]}:${PORTADD[5]} "
done
reset_color
fi