Installing OpenVPN is easy but configuring it, is very challenging and that’s why OpenVPN org provide us with scripts and then we can go ahead and our special changes
If you want to add more users, you have to run the script again
The needed port 1194 is going to be added on iptables automatically, if you are running UFW you won’t see the rule there and even if you create one in UFW it won’t take precedence
touk@ubuntu-server:~$sudoiptables-save# Generated by iptables-save v1.8.7 on Sun Sep 3 15:12:53 2023*filter:INPUTACCEPT [71668:7983516]:FORWARDACCEPT [12272:2751669]:OUTPUTACCEPT [106599:9084589]-AINPUT-pudp-mudp--dport1194-jACCEPT-AFORWARD-mstate--stateRELATED,ESTABLISHED-jACCEPT-AFORWARD-s10.8.0.0/24-jACCEPTCOMMIT# Completed on Sun Sep 3 15:12:53 2023# Generated by iptables-save v1.8.7 on Sun Sep 3 15:12:53 2023*nat:PREROUTINGACCEPT [2110:172636]:INPUTACCEPT [469:63316]:OUTPUTACCEPT [322:28589]:POSTROUTINGACCEPT [232:22084]-APOSTROUTING-oens33-jMASQUERADE-APOSTROUTING-s10.8.0.0/24!-d10.8.0.0/24-jSNAT--to-source192.168.1.5COMMIT
If you want to check for it’s status,
since OpenVPN package comes with the server and client package we will have to specify the service name like this:
sudo systelctl status openvpn-server@server
touk@ubuntu-server:~$sudosystemctlstatusopenvpn-server@server●openvpn-server@server.service-OpenVPNserviceforserverLoaded:loaded (/lib/systemd/system/openvpn-server@.service; enabled; vendorpreset:enabled)Active:active (running) since Sun 2023-09-03 15:09:50 UTC; 5minagoDocs:man:openvpn(8)<https://community.openvpn.net/openvpn/wiki/Openvpn24ManPage><https://community.openvpn.net/openvpn/wiki/HOWTO>MainPID:68439 (openvpn)Status:"Initialization Sequence Completed"Tasks:1 (limit: 4516)Memory:1.8MCPU:21msCGroup:/system.slice/system-openvpn\\x2dserver.slice/openvpn-server@server.service└─68439/usr/sbin/openvpn--status/run/openvpn-server/status-server.log--status-version2--suppress-timestamps--configserve>Sep0315:09:50ubuntu-serveropenvpn[68439]:CouldnotdetermineIPv4/IPv6protocol.UsingAF_INETSep0315:09:50ubuntu-serveropenvpn[68439]:SocketBuffers:R=[212992->212992]S=[212992->212992]Sep0315:09:50ubuntu-serveropenvpn[68439]:UDPv4linklocal (bound): [AF_INET]192.168.1.5:1194Sep0315:09:50ubuntu-serveropenvpn[68439]:UDPv4linkremote: [AF_UNSPEC]Sep0315:09:50ubuntu-serveropenvpn[68439]:GIDsettonogroupSep0315:09:50ubuntu-serveropenvpn[68439]:UIDsettonobodySep0315:09:50ubuntu-serveropenvpn[68439]:MULTI:multi_initcalled,r=256v=256Sep0315:09:50ubuntu-serveropenvpn[68439]:IFCONFIGPOOLIPv4:base=10.8.0.2size=253Sep0315:09:50ubuntu-serveropenvpn[68439]:IFCONFIGPOOLLISTSep0315:09:50ubuntu-serveropenvpn[68439]:InitializationSequenceCompleted
Or you can spot it from the interfaces in your system:
If you want to change anything, you can do that iside the file /etc/openvpn/server/openvpn.conf
ocal192.168.1.5port1194protoudpdevtuncaca.crtcertserver.crtkeyserver.keydhdh.pemauthSHA512tls-crypttc.keytopologysubnetserver10.8.0.0255.255.255.0push"redirect-gateway def1 bypass-dhcp"ifconfig-pool-persistipp.txtpush"dhcp-option DNS 8.8.8.8"push"dhcp-option DNS 8.8.4.4"push"block-outside-dns"keepalive10120cipherAES-256-CBCusernobodygroupnogrouppersist-keypersist-tunverb3crl-verifycrl.pemexplicit-exit-notify
CLIENT SIDE
sudo apt install openvpn
It was already installed, because this package comes within the distro installation
I need to get the server’s certificate on my client machine, because i already generated a client profile when i did my installation
It dropped it inisde /root -_-, because i run it with the sudo command which is necessary
touk@ubuntu-server:~$sudols/root[sudo] password for touk:snaptouk.ovpn
I am going to copy it from a machine to another or you can use SCP
And then client OpenVPN expects it to .conf I will rename it: