I have a desktop linux (Ubuntu based 12.10, laptop, 1 network card) from which I connect to work vpn via standard pptp, so I can access local network and work network from the machine. On the desktop I have Windows Server 2008 VirtualBox machine with bridged network adapter, so it gets ip from local router. Desktop and virtual see each other without problems. Desktop see vpn subnet ok, but virtual does not of course.

Is there a way to provide access to work network to other machines on local lan (mainly my virtual)?

I tried something like adding route (in virtual) to work subnet to go through my desktop ip, but I don't know how to setup the router service on desktop (and create route to my vpn connection).


You need to follow these steps:

  1. Add route to any LAN host which you want to connect to work network. Firstly, add route to virtual machine. The gateway for work network is your laptop's IP.
  2. Enable forwarding on the laptop. echo 1 > /proc/sys/net/ipv4/ip_forward and uncomment net.ipv4.ip_forward = 1 in /etc/sysctl.conf to make this parameter enabled across reboots.
  3. Since your LAN hosts have no address on VPN, you might want to masquerade their IP with your laptop's VPN IP. iptables -t nat -A POSTROUTING -o tunX -j MASQUERADE, tunX is your virtual tunnel interface.
| improve this answer | |
  • Works! I didn't know forwarding is so easy :) Thanks! – Juraj Misur Mar 16 '13 at 13:40

Easiest would be setup virtual to use NAT. In VirtualBox it is a click away. It should take care of most of the stuff outlined in slimsuperhero's answer. For my money, I'd rather offload the vpn to my ADSL router, setup NAT there and solve it thusly.

| improve this answer | |
  • Works as well! This is probably the easiest way. However for some reason I cannot remember now I wanted my virtual to have lan address, so it's reachable from other lan machines. Thanks anyway! – Juraj Misur Mar 16 '13 at 13:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.