Overview
In a site-to-site configuration:- Each location has a VPN gateway running OpenVPN
- The gateways establish a secure tunnel between them
- IP routing forwards traffic between the private networks
- Machines on each network can access resources on the other network
Network topology
For this example: Bob’s network:- Internet-facing interface: bob.example.com
- Private network: 10.0.0.0/24
- VPN tunnel endpoint: 10.4.0.1
- Internet-facing interface: alice.example.com
- Private network: 10.0.1.0/24
- VPN tunnel endpoint: 10.4.0.2
Prerequisites
Establish basic VPN tunnel
First, set up a basic point-to-point VPN connection between bob and alice using one of the methods from the basic setup guide.Verify you can ping across the tunnel:
Enable IP forwarding on both gateways
On Linux:For persistent configuration:
- Debian/Ubuntu
- RHEL/CentOS
Edit Apply changes:
/etc/sysctl.conf and uncomment:Routing configuration
Add route on bob
Configure bob to route traffic destined for alice’s network through the VPN tunnel:This tells bob that to reach the 10.0.1.0/24 network, packets should be sent to alice’s tunnel endpoint (10.4.0.2).
Add route on alice
Configure alice to route traffic destined for bob’s network through the VPN tunnel:This tells alice that to reach the 10.0.0.0/24 network, packets should be sent to bob’s tunnel endpoint (10.4.0.1).
Making routes persistent
For production environments, automate route configuration using OpenVPN’s--up script option.
Complete configuration example
Here’s a complete configuration file for a site-to-site setup:Advanced routing scenarios
Multiple subnets
If bob has multiple subnets (e.g., 10.0.0.0/24 and 10.0.2.0/24), add multiple routes on alice:Using push routes in server mode
While site-to-site VPNs typically use peer-to-peer mode, you can also use server mode with route pushing:Troubleshooting
Ping works but other traffic doesn’t
- Verify IP forwarding is enabled on both gateways
- Check firewall rules on both gateways
- Ensure the TUN/TAP interface is not blocked
No connectivity between networks
- Verify the VPN tunnel is up:
ping 10.4.0.2(from bob) - Check routing tables:
route -norip route - Use
tracerouteto identify where packets are being dropped - Check OpenVPN logs for errors
Asymmetric routing issues
Ensure both sides have routes configured. Traffic must be able to flow in both directions.Next steps
- Multi-client setup - Add multiple clients to your VPN
- Advanced configurations - Explore compression, QoS, and more
- Monitoring and logging - Track VPN health and performance