From 38c65fd5dcc094082a980e36adb2fbda602526ec Mon Sep 17 00:00:00 2001 From: veypi Date: Mon, 21 Dec 2020 18:54:46 +0800 Subject: [PATCH] update rip --- linux/rip | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/linux/rip b/linux/rip index 184158e..22ccc66 100755 --- a/linux/rip +++ b/linux/rip @@ -1,13 +1,39 @@ #!/bin/bash -chan=pride +chan=$1 chan_pre=$chan'_pre' chan_forward=$chan'_forward' chan_post=$chan'_post' -to=192.168.122.245 -to_port=3389 -from=10.69.115.207 -from_port=19520 +from=$2 +from_port=$3 +to=$4 +to_port=$5 + +if ! [ -e "$1" ]; then + echo "iptable chan not found" >&1 + exit 1 +fi + +if ! [ -e "$2" ]; then + echo "from host not found" >&1 + exit 1 +fi +if ! [ -e "$3" ]; then + echo "from port not found" >&1 + exit 1 +fi + +if ! [ -e "$4" ]; then + echo "destination host not found" >&1 + exit 1 +fi + +if ! [ -e "$5" ]; then + echo "destination port not found" >&1 + exit 1 +fi + +echo "redirect ${from}:${from_port} to ${to}:${to_port}" ## 清空 引用 sudo iptables -t nat -nvL PREROUTING --line-number | awk -F ' ' 'BEGIN{c=0} /'${chan_pre}'/ {printf "%s %s %s\n",c, $1,$4;system("sudo iptables -t nat -D PREROUTING "$1-c);c++}'