When working from home, I need to access the company network using a VPN software which works on Windows only. However, all my tools are in Linux, thus working in Windows (dual-boot) or in a Windows virtual machine is very tedious and inefficient.
The solution is to create a Windows virtual machine. Use it to run the VPN software. Then, my linux OS will connect to the virtual machine and go into the office network via the VPN connection created by the virtual machine. This is how to do it:
- Create a virtual machine with Windows 7 (I’m using Virtual-box).
- Create two network adapters for the virtual machine. The first one uses NAT. The second one uses Host-only Adapter. To configure a Host-only Adapter, you will have to create a Host-only Network in the virtual-box (File > Preferences > Network > Host-only Network).
- Start up Windows 7 virtual machine. Make sure VPN is working fine (can connect to the office network from within the Windows 7 virtual machine).
- Make sure the second adapter can be reached from the host Linux OS. You can simply ping the IP address of the second adapter from the host Linux OS. You will have to disabled the firewall in the Windows 7 virtual machine.
Now is the port forwarding. Click the Windows start button and type
cmd. Right-click on the search result and choose
Run as administrator. In the command prompt, type the following command:
netsh interface portproxy add v4tov4 listenaddress=x.x.x.x listenport=xx connectaddress=x.x.x.x connectport=xx
My Windows 7 virtual machine has its 2nd network adapter configured with the IP address 192.168.56.101. I would like to connect to my office server with IP address 10.1.69.83. The office server is listening at port 22 (SSH). My final command becomes:
netsh interface portproxy add v4tov4 listenaddress=192.168.56.101 listenport=22 connectaddress=10.1.69.83 connectport=22
The listenport=22 can be set to any other number as long as you specify it when connecting from your Linux OS to the Windows virtual machine like the following:
ssh -oPort=<listenport> firstname.lastname@example.org
The effect is like running the following command
ssh -oPort=<connectport> email@example.com
from the Windows 7 virtual machine.
To show all port forwarding configurations:
netsh interface portproxy show all
To clear all port forwarding settings:
netsh interface portproxy reset
If the forwarding does not work, you may want to clear all settings and re-add them.
More info here: http://woshub.com/port-forwarding-in-windows/