Select host's NAT interface

Discussions related to using VirtualBox on Linux hosts.
Post Reply
cipcirip
Posts: 2
Joined: 13. Jan 2008, 22:29

Select host's NAT interface

Post 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 ?
frank
Oracle Corporation
Posts: 3362
Joined: 7. Jun 2007, 09:11
Primary OS: Debian Sid
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Linux, Windows
Location: Dresden, Germany
Contact:

Post 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.
cipcirip
Posts: 2
Joined: 13. Jan 2008, 22:29

Post 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.
frank
Oracle Corporation
Posts: 3362
Joined: 7. Jun 2007, 09:11
Primary OS: Debian Sid
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Linux, Windows
Location: Dresden, Germany
Contact:

Post 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.
h1d
Volunteer
Posts: 170
Joined: 3. Jul 2008, 02:10

Post 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.
Post Reply