OpenVPN Setup Guide with Split Tunneling on Ubuntu
Prerequisites
- Ubuntu 20.04 or later
- Root or sudo access
- OpenVPN server configuration files
Step 1: Install OpenVPN
Step 2: Place Configuration Files
Copy your OpenVPN configuration files (e.g.,.ovpn) to the /etc/openvpn/client/ directory:
Step 3: Configure Split Tunneling
Edit the OpenVPN client configuration file to enable split tunneling. Open the file:Modify the following settings:
- Prevent default gateway override:
- Route only specific traffic through VPN (e.g., a corporate network
10.0.0.0/24): - Ensure correct DNS resolution (Optional):
Step 4: Start OpenVPN Client
Run OpenVPN using the configuration file:Step 5: Verify VPN Connection
Check your IP to confirm split tunneling is working:Step 6: Enable OpenVPN on Boot (Optional)
Create a systemd service file:Step 7: Disconnect OpenVPN
To disconnect, run:Troubleshooting
- Check OpenVPN logs for errors:
- Restart OpenVPN service:
- Verify routing rules:
