summaryrefslogtreecommitdiff
path: root/port_forward
diff options
context:
space:
mode:
authorVasudev Kamath <vasudev@copyninja.info>2016-07-17 15:42:41 +0530
committerVasudev Kamath <vasudev@copyninja.info>2016-07-17 15:42:41 +0530
commit7c9e4e9daa00391c65c8ce9517109f445fb208da (patch)
tree392d8100c94eb39c3b9835695fd0ddf62a003b1d /port_forward
parentd106e9ac560ee3b7f32256cf3a8e4a619f60f3fe (diff)
parentb8f42ab1f6dc17bbb352bcc3a12020d47429df00 (diff)
Merge branch 'master' of github.com:copyninja/bin
Diffstat (limited to 'port_forward')
-rwxr-xr-xport_forward8
1 files changed, 5 insertions, 3 deletions
diff --git a/port_forward b/port_forward
index 4a3c9d1..4842b3c 100755
--- a/port_forward
+++ b/port_forward
@@ -35,8 +35,10 @@ setup_portforwarding () {
iptables -A FORWARD -p "$protocol" -d ${DESTINATION%%\:*} --dport $PORT -j ACCEPT
# Returning packet should have gateway IP
- iptables -t nat -A POSTROUTING -s ${DESTINATION%%\:*} -o \
- $IN_INTERFACE -j SNAT --to ${IN_IP%%\/*}
+ for ip in ${IN_IP} ; do
+ iptables -t nat -A POSTROUTING -s ${DESTINATION%%\:*} -o \
+ $IN_INTERFACE -j SNAT --to ${ip%%\/*}
+ done
}
@@ -82,7 +84,7 @@ DESTINATION="$4"
# Get the incoming interface IP. This is used for SNAT.
IN_IP=$(ip addr show $IN_INTERFACE|\
- perl -nE '/inet\s(.*)\sbrd/ and print $1')
+ perl -nE '/inet\s(.*)\sscope/ and say $1' | tr '\n' ' ')
if [ -n "$CLEAR_RULES" ]; then