Prerequisites
Before starting, ensure:- OpenVPN is installed on both machines
- Network connectivity exists between the machines
- Firewall allows traffic on port 1194/UDP (or your chosen port)
Network setup
For these examples, we’ll use:- bob.example.com: First peer with tunnel endpoint 10.4.0.1
- alice.example.com: Second peer with tunnel endpoint 10.4.0.2
Tunnel endpoints are private IP addresses that only have meaning within the VPN context. Choose addresses from private ranges (10.x.x.x or 192.168.x.x) that don’t conflict with your existing networks.
Firewall configuration
If firewalls exist between machines, configure them to forward OpenVPN traffic:- Default port: 1194/UDP
- Direction: Bidirectional
--ping 15 to commands to maintain the connection:
Simple tunnel without security
Start the tunnel on bob
--verb 9 option produces verbose output similar to tcpdump for debugging.Secure tunnel with self-signed certificates
This approach uses self-signed certificates with fingerprint verification for authentication.Exchange fingerprints securely
Transfer the certificate fingerprints between machines using a secure method like
scp or ssh.Full PKI with certificate authority
For production environments, use a complete PKI infrastructure with a certificate authority.Prepare certificates
Generate separate certificate/key pairs for both bob and alice, signed by a certificate authority. You’ll need:
ca.crt- Certificate authority certificateclient.crtandclient.key- Client certificate and keyserver.crtandserver.key- Server certificate and keydh2048.pem- Diffie-Hellman parameters
The
--reneg-sec 60 option is set for demonstration purposes. For production use, omit this option to use OpenVPN’s default one-hour renegotiation interval.Next steps
- Site-to-site VPN - Connect entire networks
- Multi-client setup - Support multiple simultaneous clients
- Advanced configurations - Explore advanced options