42 lines
958 B
Bash
42 lines
958 B
Bash
|
#!/bin/bash
|
||
|
|
||
|
host=debian@10.2.1.87
|
||
|
|
||
|
tunnel() {
|
||
|
name=$1
|
||
|
ip=$2
|
||
|
rPort=$3
|
||
|
lPort=$4
|
||
|
|
||
|
echo -n "localhost:$lPort $name "
|
||
|
ssh -nNTL "$lPort:$ip:$rPort" "$host" 2> /dev/null &
|
||
|
|
||
|
until nc -vz 127.0.0.1 $lPort 2> /dev/null
|
||
|
do
|
||
|
echo -n .
|
||
|
sleep 0.3
|
||
|
done
|
||
|
|
||
|
echo "ok"
|
||
|
}
|
||
|
|
||
|
echo ""
|
||
|
|
||
|
tunnel "Trumpf Inverter (http) " 192.168.1.2 80 8001
|
||
|
tunnel "Trumpf DCDC (http) " 192.168.1.3 80 8002
|
||
|
tunnel "Emu Meter (http) " 192.168.1.241 80 8003
|
||
|
tunnel "ADAM (http) " 192.168.1.242 80 8004
|
||
|
tunnel "AMPT (http) " 192.168.1.249 8080 8005
|
||
|
|
||
|
tunnel "Trumpf Inverter (modbus)" 192.168.1.2 502 5001
|
||
|
tunnel "Trumpf DCDC (modbus) " 192.168.1.3 502 5002
|
||
|
tunnel "Emu Meter (modbus) " 192.168.1.241 502 5003
|
||
|
tunnel "ADAM (modbus) " 192.168.1.242 502 5004
|
||
|
tunnel "AMPT (modbus) " 192.168.1.249 502 5005
|
||
|
|
||
|
echo
|
||
|
echo "press any key to close the tunnels ..."
|
||
|
read -r -n 1 -s
|
||
|
kill $(jobs -p)
|
||
|
echo "done"
|