If you've experienced losing your Remote Desktop Protocol (RDP) connection when connecting to a VPN from your Windows VPS, this guide will help you prevent that issue by adding a static route to your server.
Step 1: Check Your Public IP Address
First, check your public IP address by visiting this site and finding it under the "Your IP Address" line.
Step 2: Open Command Prompt and Print the Route
Open Command Prompt as an Administrator and run the following command to print the current routing table:
route print
You should see a similar output as shown below:
Step 3: Identify the VirtuozzoVirtIO Ethernet Adapter ID
Locate the line corresponding to the VirtuozzoVirtIO Ethernet Adapter
. In this example, the adapter ID is 5. You will need this ID for the next step.
Step 4: Add a Static Route for RDP
To maintain your RDP connection while connected to the VPN, add a static route that directs traffic to your public IP. Use the following command:
route ADD 9.9.9.9 MASK 255.255.255.255 169.254.0.1 if 5
Explanation of the Command:
- 9.9.9.9: Replace this with the IP address you use to connect to RDP (your server's public IP).
- 255.255.255.255: This is the netmask (leave it unchanged).
- 169.254.0.1: The link-local interface IP (leave it unchanged).
- 5: The
VirtuozzoVirtIO Ethernet Adapter
ID identified in the previous step.
Step 5: Make the Route Permanent
To ensure the route persists after a reboot, add the -p
argument to the command:
route -p ADD 9.9.9.9 MASK 255.255.255.255 169.254.0.1 if 5
Important Note: This solution is suitable if you have a static IP address. If your IP address is dynamic, this method will not work.
By following these steps, you can prevent losing your RDP connection when accessing your VPN from your Windows VPS.