How to fix Remote Desktop disconnecting when using OpenVPN
Using a remote desktop together with a VPN is common but it can often cause unexpected disconnections. If your remote session drops immediately after connecting to a VPN, this guide explains why it happens and how to fix it.
Root Cause
When a VPN connects, it usually modifies your system’s routing table.
What this means:
- All network traffic is redirected into the VPN tunnel
- Your original internet route is replaced
- The remote desktop session (which depends on your original connection path) is interrupted
Why This Happens
Many VPN configurations include a setting that forces all traffic through the VPN.
Example:
redirect-gateway def1
This causes:
- Loss of the original IP route
- Remote desktop connection to drop
Solutions
Option 1:Enable Split Tunneling
This allows only specific traffic to go through the VPN while keeping other connections (like remote desktop) on your normal network.
Step:
- Open your VPN configuration file
- Find:
redirect-gateway def1 - Comment it out:
#redirect-gateway def1 - Reconnect to the VPN
Result:
- Only selected traffic goes through the VPN
- Your remote desktop connection remains stable
Option 2: Add a Static Route
You can manually force your remote desktop traffic to bypass the VPN.
Step:
- Identify the remote server IP before connecting to the VPN:
netstat -rn
or:lsof -i - Add a route:
sudo route add <remote_server_ip> <your_gateway>
Result:
- Remote desktop traffic avoids the VPN
- Connection remains stable even after the VPN connects
Option 3: Use route-nopull
This gives you full control over routing.
Note: This option requires basic networking knowledge.
- Configuration:
route-nopull - Then manually define only the routes you want:
route <route_ip> <route_subnet>
Result:
- Full control over VPN routing
- Only specified traffic uses the VPN
Option 4: Use Multiple Network Interfaces
Requirements:
- Wi-Fi + Ethernet, or
- Multiple IP addresses
Setup:
- Remote desktop → Primary network
- VPN → Secondary network
Result:
- No routing conflicts
- Stable and independent connections
Option 5: Try a Different Remote Desktop Tools
If none of the above options are suitable, consider switching to another remote desktop tool. Some tools handle network changes better than others.
Some better tools:
- TeamViewer
- AnyDesk