Advertisement
Guest User

Untitled

a guest
Jan 18th, 2020
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.72 KB | None | 0 0
  1. #!/bin/bash
  2. PATH=/sbin:/usr/sbin:/bin:/usr/bin
  3.  
  4. #local
  5. port_from="8088"
  6. #ip_from="localhost"
  7. #remoto
  8. port_to="80"
  9. ip_to="149.154.167.99"
  10.  
  11. sleep_time=5
  12.  
  13.  
  14. crea_tunel () {
  15. echo "creando tunel desde: $ip_from:$port_from hacia $ip_to:$port_to"
  16. #socat -u TCP:$ip_to:$port_to TCP:$ip_from:$port_from &
  17. socat TCP-LISTEN:$port_from,fork TCP:$ip_to:$port_to
  18. }
  19.  
  20. echo "iniciando script:"
  21.  
  22. crea_tunel
  23.  
  24.  
  25. while true; do
  26.     echo "chequeando si el tunel esta up"
  27.     check=sudo netstat -putan | grep ":$port_from    ES"
  28.  
  29.     if [ ${#check} -ge 10 ]
  30.     then
  31.         result="connected"
  32.     else
  33.         sudo killall socat -s KILL
  34.         result="not connected"
  35.         crea_tunel
  36.  
  37.     fi
  38.  
  39.  
  40. sleep $sleep_time
  41.  
  42. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement