How to use Custom Network Interface on Windows

If you have some official application hosted on some private server and can be only accessed from office network, you will not be able to install VPN on your machine, because it will by default pass all the traffic through it’s own network interface. Here I will describe how to setup network traffic to use specific network interface. It will be fore Windows though Linux would be more easy because the core steps are same.

Let’s say you want to access a privately accessible application from your office network and the URL is https://erp.phpfarmer.com

In summary the main goal is to have that specific trafic through your default internal network interface not by the VPN one. You can do it in three main steps like finding the IP of you target website URL then put it on hostfile and add a new entry on route table.

Open powershell (Administrator)

nslookup erp.phpfarmer.com #find the ipaddress i.e: 10.30.20.140

After finding the IP address now update your hostfile with that IP

10.30.20.140 erp.phpfarmer.com 

Open powershell (Administrator)

ipconfig
# look for Ethernet adapter Ethernet: (internal private network)
# Default Gateway . . . . . . . . . : 10.16.0.1
route print #see the list of network interfaces for 0.0.0.0 at IPv4 Route Table from active routes list
# Network Destination       Netmask         Gateway       Interface         Metric
#  0.0.0.0                  0.0.0.0         10.16.0.1     10.16.129.225     4250
route ADD 10.30.20.140 MASK 255.255.255.255 10.16.0.1

Step 1: nslookup erp.phpfarmer.com

First step is to find the associated IP address of that domain or application URL, it should not be any normal public IP address because it’s privately accessible via your network and it has some custom IP range. i.e 10 . 30 . * . * we can get it different ways as showing below.

Assume our VPN is turned ON checking the private ip address of this domain and it’s returning me something like public information as bellow.

Server:  57.172.252.162.in-addr.arpa
Address:  162.252.172.57
Name:    erp.phpfarmer.com 

Assume our VPN is turned OFF checking the private ip address of this domain and it’s returning me something like public information as bellow.

Server:  one.one.one.one
Address:  1.1.1.1
Name:    erp.phpfarmer.com 

Assume our VPN is turned ON but we nslookup it from another machine of that same network.

Server:  muc-1-fw.phpfarmer.com
Address:  10.16.0.1

Name:    erp.phpfarmer.com
Address: 10.30.0.8 

If you normally visit the app erp.phpfarmer.com on a browser keeping your VPN OFF you can find the Remote Address: 10.30.0.8:**** on request header by browser developer console which you can open by pressing Ctrl + Shift + I together.

So now, you are sure that your private ip address of that application server is 10.30.0.8

Step 2: Update hosts file

10.30.0.8 erp.phpfarmer.com 

Step 3: find the default gateway and interface

ipconfig
# look for Ethernet adapter Ethernet: (internal private network)
# Default Gateway . . . . . . . . . : 10.16.0.1

Another way to find it is by route print, basically the first line of result where all the network request goes through a common gateway which was configured like 10.16.*.* where the second line with 0.0.0.0 is appearing because your VPN is now ON

route print #see the list of network interfaces for 0.0.0.0 at IPv4 Route Table from active routes list
# Network Destination       Netmask         Gateway       Interface         Metric
#  0.0.0.0                  0.0.0.0         10.16.0.1     10.16.128.225     4250
#  0.0.0.0                  0.0.0.0         On-link       10.6.6.99         26

Step 4: add the private ip to the route table

Here you will need to add that private IP address to the route table to use that specific default gateway of local route interface, so that we can say, all the traffic can go through VPN created network interface but only this IP request should through local network.

route ADD 10.30.0.8 MASK 255.255.255.255 10.16.0.1
tracert 10.30.0.8 #You can check now how it goes 

Now!!! If everything is fine you should be able to access with/out VPN that site!!!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: