Advertisement
nguyenhappy92

How to install OpenVPN Server

Dec 5th, 2018
1,058
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.05 KB | None | 0 0
  1. yum install epel-release -y
  2. yum update -y
  3. cd /opt/
  4. systemctl stop firewalld
  5. systemctl mask firewalld
  6. systemctl disable firewalld
  7. yum install -y iptables-services
  8. systemctl start iptables
  9. /sbin/sysctl -w net.ipv4.ip_forward=1
  10. Nếu không có thì
  11. vi /etc/sysctl.conf
  12. net.ipv4.ip_forward = 1
  13. /sbin/sysctl -p
  14. vi /usr/lib/sysctl.d/50-default.conf
  15. net.ipv4.ip_forward = 1
  16. curl -O https://raw.githubusercontent.com/Angristan/openvpn-install/master/openvpn-install.sh
  17. chmod +x openvpn-install.sh
  18. ./openvpn-install.sh
  19. Hoặc chạy lệnh sau:
  20. wget https://git.io/vpn -O openvpn-install.sh && bash openvpn-install.sh
  21.  
  22. vi /etc/openvpn/server.conf
  23. Edit theo các dòng dưới sau:
  24. server 10.9.0.0 255.255.255.0
  25. #push "redirect-gateway def1 bypass-dhcp"
  26. push "route 10.9.0.0 255.255.255.0"
  27. push "route 10.30.10.0 255.255.255.0" # IP Range local
  28. systemctl restart openvpn@server.service
  29. systemctl enable openvpn@server.service
  30. vi /etc/sysconfig/iptables
  31.  
  32. *nat
  33. :PREROUTING ACCEPT [2:120]
  34. :POSTROUTING ACCEPT [0:0]
  35. :OUTPUT ACCEPT [0:0]
  36. -A POSTROUTING -s 10.8.0.0/24 -j SNAT --to-source 10.30.10.5
  37. -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE
  38. -A POSTROUTING -s 10.8.0.0/24 -o eth1 -j MASQUERADE
  39. COMMIT
  40. # Completed on Thu Oct 13 09:54:16 2016
  41. # Generated by iptables-save v1.4.7 on Thu Oct 13 09:54:16 2016
  42. *filter
  43. :INPUT ACCEPT [218:30100]
  44. :FORWARD ACCEPT [0:0]
  45. :OUTPUT ACCEPT [578:56142]
  46. -A INPUT -p udp -m udp --dport 1194 -j ACCEPT
  47. -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
  48. -A INPUT -p icmp -j ACCEPT
  49. -A INPUT -i lo -j ACCEPT
  50. -A INPUT -p tcp -m state --state NEW -m tcp --dport 2728 -j ACCEPT
  51. -A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
  52. -A INPUT -p tcp -m state --state NEW -m tcp --dport 8069 -j ACCEPT
  53. -A INPUT -p tcp -m state --state NEW -m tcp --dport 10050 -j ACCEPT
  54. -A FORWARD -s 10.8.0.0/24 -j ACCEPT
  55. -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
  56. COMMIT
  57. systemctl restart openvpn@server.service
  58. systemctl restart iptables
  59. iptables -L
  60. ln -s /opt/openvpn-install.sh /usr/bin/vpn-create-user
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement