Test Ubuntu VPN
Test Ubuntu VPN
1. Update packages:
2. sudo apt update
3. sudo apt install openvpn easy-rsa
4. Copy the OpenVPN example configuration:
5. cp -r /usr/share/easy-rsa /etc/openvpn/
6. cd /etc/openvpn/easy-rsa
7. Initialize the PKI (Public Key Infrastructure):
8. ./easyrsa init-pki
9. Build the Certificate Authority (CA):
10. ./easyrsa build-ca
11. Generate the Server Certificate and Key:
12. ./easyrsa gen-req server nopass
13. ./easyrsa sign-req server server
14. Create Diffie-Hellman parameters:
15. ./easyrsa gen-dh
16. Copy keys to the OpenVPN directory:
17. cp pki/ca.crt pki/issued/server.crt pki/private/server.key
pki/dh.pem /etc/openvpn/
18. Copy the default server configuration file:
19. cp
/usr/share/doc/openvpn/examples/sample-config-files/server.conf
/etc/openvpn/
20. Edit server.conf to configure:
o Set dh /etc/openvpn/dh.pem
o Uncomment push "redirect-gateway def1 bypass-dhcp"
o Uncomment push "dhcp-option DNS 8.8.8.8"
o Uncomment user nobody and group nogroup
21. Enable IP Forwarding:
22. sudo nano /etc/sysctl.conf
net.ipv4.ip_forward = 1
Run:
sudo sysctl -p
1. Install OpenVPN:
2. sudo apt install openvpn
3. Copy the client configuration template:
4. cp /usr/share/doc/openvpn/examples/sample-config-files/client.conf
~/client.conf
5. Edit client.conf to point to the server's IP:
6. remote <VPN_SERVER_IP> 1194
7. Copy the required certificates and keys to /etc/openvpn:
8. sudo cp /path/to/ca.crt /etc/openvpn/
9. sudo cp /path/to/client.crt /etc/openvpn/
10. sudo cp /path/to/client.key /etc/openvpn/
11. Start the VPN client:
12. sudo systemctl start openvpn@client
13. sudo systemctl enable openvpn@client
1. Install OpenVPN Connect or OpenVPN for Android from the Play Store.
2. Export the client .ovpn file from your VPN server and transfer it to your Android
devices.
3. Import the .ovpn file in the OpenVPN app.
4. Connect and verify the VPN status.
1. IP Address Verification:
o Before connecting to the VPN, visit https://whatismyip.com to note the
original IP address.
o Connect to the VPN and revisit the website — your IP should now reflect the
VPN server’s address.
2. Packet Capture Test (Wireshark/tcpdump)
o Run tcpdump on the server:
o sudo tcpdump -i tun0
o This ensures encrypted data is flowing only through the VPN tunnel.
3. DNS Leak Test:
o Visit https://dnsleaktest.com before and after connecting to the VPN.
4. File Transfer Test:
o Transfer a file securely using scp:
o scp /path/to/file username@<VPN_SERVER_IP>:/home/username/
5. Firewall Test:
o Block non-VPN traffic using:
o sudo ufw default deny outgoing
o sudo ufw allow out on tun0