Page 1 of 1

Select host's NAT interface

Posted: 13. Jan 2008, 22:32
by cipcirip
Hello,

Is there a way to select the host's interface (IP) on which the NAT will be performed ? I have a linux box with multiple interfaces and I do not want to NAT the HostPort on all interfaces.

I've been looking on the docs and the VirtualBox source code and I have found nothing like that.

Thank you,
G.

-- Later edit:

Well, it seems that VBox will use INADDR_ANY for NAT (source: src/VBox/Devices/Network/slirp/socket.c), function solisten():

addr.sin_addr.s_addr = INADDR_ANY;

Would it be very complicated to add an extra attribute like HostAddress in order to let the user choose the host's local IP for NAT ?

Posted: 14. Jan 2008, 10:02
by frank
This would probably be possible. However, you should consider using a host interface and bind the guest interface to the specific network interface of the host.

Posted: 15. Jan 2008, 20:14
by cipcirip
I'm afraid don't really understand your answer. I am using NAT networking for my guest as I can not use bridged networking. What do you mean by 'bind the guest interface' ? Are there any configuration options for VirtualBox that I'm missing ?

-- later edit:

Well, I have found a solution to my problem. I was looking to forward a TCP port (not UDP). The solution was to use Host Interface Networking (HIF).

-- added a vbox0 network interface to let the guest communicate with the host
-- from the guest, using the ssh port forwarding I have forwarded the remote port on the host to the local port on the guest. The ssh binds only in 127.0.0.1 on the host.
-- using simpleproxy (a simple TCP proxy), I am forwarding the port from a public interface to 127.0.0.1.

Voila.

I will keep this setup until I will find some spare time to patch virtualbox to add a HostAddress parameter for NAT. Maybe an official developer could add this feature on the next release.

Posted: 18. Jan 2008, 14:29
by frank
I did not write anything about bridging. With bridging you ensure that guest and host share the same network. With host interface without bridging you are able to use a dedicated private network for your guest.

Posted: 3. Jul 2008, 02:12
by h1d
Hi, I'm looking to do the same thing, but how is it possible? Does it mean, it's possible if it gets implemented in the future?

In the VBoxManage command, I found there is GuestIP parameter to set, but no HostIP to set to bind the port forwarding on the host interface.

I'm using a Mac as a host OS, so there is nothing but NAT networking available and hope the host IP binding will be possible.