Thursday, August 8, 2019

How to let websites and IPs bypass the VPN using static routing


There are several reasons for letting certain IPs or websites bypass the VPN connection, so they are used with your real IP and connection instead.

For example:
  • if a certain website is blocking access to foreign IPs, so you can only access it with your real IP
  • if websites and services forbid the use of VPN, so your account won't get restricted or suspended
  • if you cannot access a local machine in your network while the VPN is connected (e.g. server, other computer or network device of any kind)

Manual setup via route.exe

On windows, to create static routing rules to let IPs bypass the VPN, you need to use the integrated tool "route.exe" of Windows.
You can find it in the folder C:\Windows\System32 - but it's executable from any place.
To use it, open a command prompt. Run "cmd.exe" or navigate to "All Programs/Accessories/Command Prompt" in the start menu.
Run "route" to get the instructions for how to use this tool. How to use it for our purpose (IPs bypassing the VPN) is quickly explained:
  • First you need to find your gateway IP address. This is usually the IP of your router/DSL-Modem, so the device your computer gets the internet from.
    If you're not sure which IP that is, please run "route print". 
  • You'll see that certain IPs are using a gateway address that belongs into your local network. In this case, 192.168.88.2 is our gateway IP address, the IP of the router
  • Keep that gateway IP address in mind. Now we need to get the IP of the website you want to bypass the VPN. For testing, we can use http://ipaddress.com
  • As you might know, this website shows your current IP and location. When disconnected from the VPN, go there and you'll see your real IP and location.
  • To get the IP of that website, you can simply ping it by running "ping ipadress.com". It returns the IP address, which is: 80.237.246.185
    Alternatively use websites like http://www.hcidata.info/host2ip.htm for this purpose
  • Now we create a routing rule for this website, by running "route add 80.237.246.185 192.168.88.2" (syntax: route add destinationIP gatewayIP)
  • When that is done, connect to the VPN and visit http://ipaddress.com again. You'll notice that it still shows your real IP and location, instead the VPN IP and location.
    That means the routing rule is working and the website is bypassing the VPN.

Note: This rules are only temporary, that means they disappear upon next reboot.
To make them permanent, use the switch "-p", so e.g. "route -p add 80.237.246.185 192.168.88.2"