Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. #!/bin/sh
  2. HOST=REMOTE_PARTY_ADDRESS
  3. HOST_PORT=22
  4. TUN_LOCAL=0 # tun device number here.
  5. TUN_REMOTE=0 # tun device number there
  6. IP_LOCAL=192.168.111.2 # IP Address for tun here
  7. IP_REMOTE=192.168.111.1 # IP Address for tun there.
  8. IP_MASK=30 # Mask of the ips above.
  9. NET_REMOTE=192.168.0.0/16 # Network on the other side of the tunnel
  10. NET_LOCAL=192.168.8.0/24 # Network on this side of the tunnel
  11.  
  12. echo "Starting VPN tunnel ..."
  13. modprobe tun
  14. ssh -w ${TUN_LOCAL}:${TUN_REMOTE} -f ${HOST} -p ${HOST_PORT} "
  15. ip addr add ${IP_REMOTE}/${IP_MASK} dev tun${TUN_REMOTE}
  16. && ip link set tun${TUN_REMOTE} up
  17. && ip route add ${NET_LOCAL} via ${IP_LOCAL}
  18. && true"
  19. sleep 3
  20. ip addr add ${IP_LOCAL}/${IP_MASK} dev tun${TUN_LOCAL}
  21. ip link set tun${TUN_LOCAL} up
  22. ip route add ${NET_REMOTE} via ${IP_REMOTE}
  23. echo "... done."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement