My linux world » srv-vpn

srv-vpn


Prerequiste

I assume that you have a Centos installation.

Installation

You can copy/paste this script and use it to configure automatically your server.

  1. #!/bin/bash
  2.  
  3. echo "install openvpn"
  4. dnf -y install openvpn
  5.  
  6. echo "start service openvpn at boot"
  7. systemctl enable openvpn@server.service
  8.  
  9. echo "add service openvpn (port 1194) to firewall"
  10. firewall-cmd --permanent --add-service openvpn
  11. firewall-cmd --reload
  12.  
  13. echo "configure vpn"
  14. rm -f /etc/openvpn/server.conf
  15. cp /usr/share/doc/openvpn-*/sample/sample-config-files/server.conf /etc/openvpn/
  16.  
  17. sed -i "s/dev tun/dev tap0/g" /etc/openvpn/server.conf
  18. sed -i "s/^\(ca \)/#\1/g" /etc/openvpn/server.conf
  19. sed -i "s/^\(cert \)/#\1/g" /etc/openvpn/server.conf
  20. sed -i "s/^\(key \)/#\1/g" /etc/openvpn/server.conf
  21. sed -i "s/^\(dh \)/#\1/g" /etc/openvpn/server.conf
  22. sed -i "s/^\(server \)/#\1/g" /etc/openvpn/server.conf
  23. sed -i "s/^\(ifconfig-pool-persist \)/#\1/g" /etc/openvpn/server.conf
  24. sed -i "s/^\;\(log\)/\1/g" /etc/openvpn/server.conf
  25. sed -i "s/\(openvpn.log\)/\/var\/log\/\1/g" /etc/openvpn/server.conf
  26.  
  27.  
  28. # echo "SSL Part (disabled)"
  29. # echo "If uncomment:"
  30. # echo " - Remember to sign and commit (when it will be asked)"
  31. # echo " - In /etc/openvpn/server.conf:"
  32. # echo " * update ca, cert, key dh path"
  33. # echo " * uncomment and configure the server-bridge (syntax [VPN server's IP] [subnetmask] [the range of IP for client])"
  34. # echo " * uncomment and configure the 'push \"route\ (...)\" (syntax [network VPN server in] [subnetmask])"
  35. # cp -R /usr/share/openvpn/easy-rsa/2.0 /etc/openvpn/easy-rsa
  36. # cd /etc/openvpn/easy-rsa
  37. # ln -s openssl-1.0.0.cnf openssl.cnf
  38. # source ./vars
  39. # ./clean-all
  40. # ./build-ca
  41. # ./build-key-server server
  42. # ./build-dh
  43. # ./build-key-pass client
  44.  
  45. echo "start service"
  46. systemctl start openvpn@server.service
  47.  

That’s all 🙂


Copyright © 2024 My linux world - by Marc RABAHI
Design by Marc RABAHI and encelades.