Binding a domain to VPN - Windows



Not all sites are redirected via the VPN site.  If we want a specific site pass thru the VPN connection, we'll need to bind the site's IP address to use the VPN's virtual network adapter.

Assuming we want to route bitbucket.org to pass thru the VPN, here are the steps:

Get IP address of target site. bitbucket.org returns 18.205.93.2.



Go to https://www.arin.net/whois_tou.html. Search for 18.205.93.2. 

Which gives us the following result. 
Go to https://www.ipaddressguide.com/cidr and enter the CIDR in the box.
This should result to this.

On to using the route tool.  What we have are:
bitbucket.org's IP address = 18.205.93.2
CIDR = 18.205.93.0/25
Subnet mask = 255.255.255.128

Take not of the CIDR IP and the Subnet mask here.  In this case, it was 18.205.93.0 and 255.255.255.128.

Identify the VPN virtual network.  This can easily be identified from the Status column.  Take note of the Name.

Open command prompt as an Administrator and enter "route print". Take note of the Interface number located at the left.


Take note of the interface number.  In this case, it is 26.

We need to identify the assigned IP address from the VPN.  To do that, we'll need to use ipconfig /all.  The Description should match the VPN's Interface description listed above.


Take note of the IPv4 address assigned by the VPN

Finally, we're going to use the route tool to bind the bitbucket.org domain to pass thru the VPN.
Enter the following:

route add 18.205.93.0 mask 255.255.255.128 172.168.10.10 IF 26

where:
18.205.93.0 is the CIDR IP
255.255.255.128 is the Subnet mask
172.168.10.10 is the assigned IP address from the VPN
26 is the Interface number


But the VPN gives random IP addresses...

Well, what we need to do is bind the interface itself regardless of what IP address it contains.  To do that:

route add -p 18.205.93.0 mask 255.255.255.128 0.0.0.0 IF 22

We set the gateway to 0.0.0.0 and made the connection persistent with the -p parameter.

Deleting persistent entries

Just use the delete option.

route delete 18.205.93.0 172.168.10.10



Something not clear?  Drop a comment below and I'll try to answer them.





Popular Posts