Skip to main content

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:

  1. Prevent default gateway override:
  2. Route only specific traffic through VPN (e.g., a corporate network 10.0.0.0/24):
  3. 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:
To ensure only specific traffic is routed via VPN:

Step 6: Enable OpenVPN on Boot (Optional)

Create a systemd service file:
Paste the following:
Enable and start the service:

Step 7: Disconnect OpenVPN

To disconnect, run:

Troubleshooting

  • Check OpenVPN logs for errors:
  • Restart OpenVPN service:
  • Verify routing rules:

Conclusion

You have successfully configured OpenVPN with split tunneling on Ubuntu. Now, only specified traffic will pass through the VPN while the rest uses the local network.