Contents

VirtualBox: Failed Binding NAT sockets to a specific interface

Contents

Testing environment:
There are 2 connections in the host. One wired directly to internet, and another is wireless go through WebSense, which is blocking websites including YouTube.  Inside a VirtualBox Client with a NAT NIC, by default YouTube is blocked. 

By default, VirtualBox's NAT engine will route TCP/IP packets through the default interface assigned by the host's TCP/IP stack. (The technical reason for this is that the NAT engine uses sockets for communication.) If, for some reason, you want to change this behavior, you can tell the NAT engine to bind to a particular IP address instead. Use the following command:
VBoxManage modifyvm "VM name" --natbindip1 "10.45.0.2"
After this, all outgoing traffic will be sent through the interface with the IP address 10.45.0.2. Please make sure that this interface is up and running prior to this assignment.

 With my client up and running:
C:\>Vboxmanage modifyvm "S08.64.Download Altiris" --natbindip1 "192.168.2.11"
VBoxManage.exe: error: The machine 'S08.64.Download Altiris' is already locked for a session (or being unlocked)
VBoxManage.exe: error: Details: code VBOX_E_INVALID_OBJECT_STATE (0x80bb0007), component Machine, interface IMachine, callee IUnknown
VBoxManage.exe: error: Context: "LockMachine(a->session, LockType_Write)" at line 419 of file VBoxManageModifyVM.cpp
Shutdown my client, the command works fine.
C:\ >Vboxmanage modifyvm "S08.64.Download Altiris" --natbindip1 "192.168.2.11"

Boot my client, the YouTube is still blocked.  Don’t know what’s wrong. I end up using Bridged Adapter as a work around.