Advertisement
Guest User

Untitled

a guest
Sep 24th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. # STARTUP
  2. # -----------------------------
  3. # Move to writable directory and create scripts
  4. cd /tmp
  5. ln -s /usr/sbin/openvpn /tmp/myvpn
  6.  
  7. # Config for Site-to-Site Server-Client104
  8. echo "
  9. proto udp
  10. port 2104
  11. dev tun4
  12. tun-mtu 1500
  13. tun-mtu-extra 32
  14. mssfix 1450
  15. secret /tmp/static.key
  16. verb 3
  17. comp-lzo
  18. keepalive 15 60
  19. daemon
  20. " > Server-Client104.conf
  21.  
  22. # Config for Site-to-Site Server-Client106
  23. echo "
  24. proto udp
  25. port 2106
  26. dev tun6
  27. tun-mtu 1500
  28. tun-mtu-extra 32
  29. mssfix 1450
  30. secret /tmp/static.key
  31. verb 3
  32. comp-lzo
  33. keepalive 15 60
  34. daemon
  35. " > Server-Client106.conf
  36.  
  37. # Config for Static Key
  38. echo "
  39. -----BEGIN OpenVPN Static key V1-----
  40. STATIC KEY
  41. -----END OpenVPN Static key V1-----
  42. " > static.key
  43.  
  44. # Create interfaces
  45. /tmp/myvpn --mktun --dev tun4
  46. /tmp/myvpn --mktun --dev tun6
  47. ifconfig tun6 10.0.104.1 netmask 255.255.255.0 promisc up
  48. ifconfig tun6 10.0.106.1 netmask 255.255.255.0 promisc up
  49.  
  50. # Create routes
  51. route add -net 192.168.104.0 netmask 255.255.255.0 gw 10.0.104.2
  52. route add -net 192.168.106.0 netmask 255.255.255.0 gw 10.0.106.2
  53.  
  54. # Initiate the tunnel
  55. sleep 5
  56. /tmp/myvpn --config Server-Client104.conf
  57. /tmp/myvpn --config Server-Client106.conf
  58.  
  59.  
  60. # -----------------------------
  61. # FIREWALL
  62. # -----------------------------
  63.  
  64. Firewall # Open firewal for Clients
  65. iptables -I FORWARD -i tun+ -o br0 -j ACCEPT
  66. iptables -I FORWARD -i br0 -o tun+ -j ACCEPT
  67.  
  68. # Open firewall holes for Client104
  69. iptables -I INPUT 2 -p udp --dport 2104 -j ACCEPT
  70. # iptables -I FORWARD 2 --source 192.168.104.0/24 -j ACCEPT
  71. # iptables -I FORWARD -i br0 -o tun4 -j ACCEPT
  72. # iptables -I FORWARD -i tun4 -o br0 -j ACCEPT
  73.  
  74. # Open firewall holes for Client106
  75. iptables -I INPUT 2 -p udp --dport 2106 -j ACCEPT
  76. iptables -I FORWARD 2 --source 192.168.106.0/24 -j ACCEPT
  77. # iptables -I FORWARD -i br0 -o tun6 -j ACCEPT
  78. # iptables -I FORWARD -i tun6 -o br0 -j ACCEPT
  79.  
  80. # Pingy na routery
  81. iptables -I INPUT 3 -i tun4 -p icmp -j ACCEPT
  82. iptables -I INPUT 3 -i tun6 -p icmp -j ACCEPT
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement