A laptop must connect to a VPN to Access a server, however said laptop has the "Use VPN as default Gateway" option disabled. The VPN is currently working, and whenever the VPN is used as a default Gateway the laptop can Access the server correctly, but that option must remain disabled. How can the laptop Access the server's services then?
The public IP of the vpn is 2.138.203.115, the name of the vpn inside the laptop is CIINAE, the internal ip of the server is 10.105.10.103, 255.255.255.0.
When connected to the VPN with the "Use VPN as default Gateway" option disabled, this is what is displayed using the route print command.
Destino de red Máscara de red Puerta de enlace Interfaz Métrica
0.0.0.0 0.0.0.0 192.168.1.1 192.168.1.108 35
2.138.203.115 255.255.255.255 192.168.1.1 192.168.1.108 36
Assistant
To allow your laptop to access the server's services via the VPN without setting the VPN as the default gateway, you can add a static route. This static route directs traffic destined for the server's internal IP through the VPN interface specifically, while all other traffic continues to use your regular local gateway.
Steps to Add a Static Route on Windows:
Identify the VPN Interface Index:
Open Command Prompt with administrative privileges.
Type the following command and press Enter:
code
route print
Locate the "Interface List" section at the top. Find the interface number corresponding to your VPN connection named CIINAE. It might look something like this:
When connected to the VPN, it typically assigns a virtual adapter with its own IP. You can find this by:
code
ipconfig
Look for the CIINAE adapter and note its IPv4 Address (e.g., 10.200.1.5).
Add the Static Route:
In the Command Prompt, enter the following command:
code
route add 10.105.10.103 MASK 255.255.255.255 10.200.1.5 IF 11
Explanation of the command:
10.105.10.103 is the server’s internal IP.
255.255.255.255 is the subnet mask for a single IP address.
10.200.1.5 is the VPN gateway IP (replace with your actual VPN gateway IP).
IF 11 specifies the interface index for the VPN (replace with your actual interface number).
Make the Route Persistent (Optional):
To ensure the route persists after reboot, use the -p flag:
code
route -p add 10.105.10.103 MASK 255.255.255.255 10.200.1.5 IF 11
Verification:
After adding the route, verify it by running:
code
route print
Ensure that there is an entry for 10.105.10.103 pointing to your VPN gateway via the correct interface.
Notes:
Subnet Routing: If you need to access multiple devices within the 10.105.10.0/24 subnet, you can add a route for the entire subnet:
code
route add 10.105.10.0 MASK 255.255.255.0 10.200.1.5 IF 11
Dynamic IP Addresses: If your VPN assigns dynamic IP addresses, consider using a script that runs on VPN connection to automatically add the necessary routes.
Administrative Rights: Ensure you run the Command Prompt as an administrator to execute these commands successfully.
By adding a static route, your laptop will direct traffic intended for the server's internal IP through the VPN without routing all other traffic through the VPN's gateway. This setup maintains your default internet routing while allowing specific access to the server.
(Ensure to replace 2.138.203.115 with the appropriate VPN gateway IP if different.)
Add a static route on the laptop directing traffic to 10.105.10.103 (or its subnet) through the VPN interface (CIINAE), so without using the VPN as the default gateway, the laptop routes server traffic via the VPN. For example, execute a route add command specifying 10.105.10.103 with gateway 2.138.203.115 on the CIINAE interface.