Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a Ubuntu 10.04 running Oracle VirtualBox 3.2.6 with a Windows XP guest. I use a VPN that I would like to be accessed by the guest VM, on a ifconfig it shows as:

tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
          inet addr:5.192.10.99  P-t-P:5.192.10.99  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1362  Metric:1
          RX packets:14151 errors:0 dropped:0 overruns:0 frame:0
          TX packets:19860 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:500 
          RX bytes:4415271 (4.4 MB)  TX bytes:17949982 (17.9 MB)

Using NAT or Bridge adapters on the VM only gives me the non-vpn adapter. How can I map the tun0 adapter to VirtualBox?

share|improve this question
    
What is it about the NAT adapter that isn't working? Does the host not route the VM traffic through the VPN when using a NAT adapter? Is the VPN setup as the default route on the host? –  Goyuix Aug 6 '10 at 15:10
    
I was unable to access VPN addresses from the guest. The trick bellow worked. –  Mashimom Aug 7 '10 at 0:07
add comment

2 Answers

You can probably do it, but I would recommend against it.

The way to go about this is to have the VM establish it's own VPN connection to the target server/network.

Now, if you really want to do this, you would need to create another bridge on the host, then create the tunnel interface as a static interface (i.e. not created by the VPN when it starts up) and add it to the bridge. Only then does this tunnel become available to the virtual machine. VirtualBox can then be instructed to virtualize this interface, which makes it available to the VM.
The part I am unsure of is whether or not a tunnel can be created outside of the VPN client and then be made available to the client for usage. You might have to look to tap devices instead of tun devices.
This can get rather complicated and will result in a situation where your VM client may not have any networking if the VPN isn't up (unless you also virtualize the other bridge). As said, I would recommend against it.

share|improve this answer
add comment

Setting /etc/sysctl.conf:

net.ipv4.ip_forward=1

Then running:

sudo sysctl -p

(Should not be necessary but) I rebooted after that and found it working.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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