7

I'm using Virtualbox 4.0.10 on a Debian Squeeze box. I have a Windows 7 VM that I use to host a game server. After setting up NAT and port redirection, clients can connect to the VM, but the game server shows it's getting connections from the NAT gateway IP (10.0.2.2). I need that the game server gets connections from the actual public internet client IP's, so I can set up an IP whitelist in the game server.

This Debian machine is directly connected to the internet. What can I do to make this work? Guess it's not VirtualBox problem and can solve that with a virtual network interface or so, but no idea how to do it. Guess it's not Virtualbox probmem and I can make it work with a bridge interface or so.

1
  • When you say that you setup NAT - did you do that on the Debian host or as part of the virtual machine configuration using the VirtualBox commands/GUI? A better diagram or description of your network setup would be very helpful.
    – Goyuix
    Jul 14, 2011 at 2:40

3 Answers 3

5

Set the network adapter into bridged mode.

in VirtualBox go to the Windows 7 settings, select network then you should see that the Adaptor is set to NAT. Change this to Bridged adapter.

2
  • Doesn't work. As I said, this machine is directly connected to the internet, and clients connect from it.
    – Albert
    Jul 13, 2011 at 22:32
  • Is your 'server' really connected directly to the internet or is there a device (modem/router/xyzzy) that does that ? Did you give the W7 machine a public routable IP address ?
    – user9517
    Jul 14, 2011 at 5:57
5

This is possible without bridge mode! For some strange reason, the default NAT mode in VirtualBox rewrites original source.

What you want is to switch NAT to transparent mode with

VBoxManage modifyvm <your-vm name> --nataliasmode1 proxyonly

More info here

2

There may not be a way to change that behavior in VirtualBox.

Any one of the following could resolve your issue:

  1. Easiest and best approach: Just set up your whitelist using iptables on the Debian box instead of managing your whitelist on the VM.
  2. Use a different hypervisor that has more options to configure virtual networking and NAT behavior.
  3. Put the Debian box behind a physical firewall or router, configure your NAT rules there, and bridge the VM to your physical network adapter.
  4. Get a second public IP address from your ISP. Assign that IP address to the virtual machine and bridge it to your physical network adapter.
2
  • Using a different hypervisor wouldn't necessarily matter - the problem is with the choice of network not the choice of virtualization. The real answer is to use bridged mode if possible.
    – Goyuix
    Jul 14, 2011 at 2:38
  • I suspect that he can't use bridged mode on the host because he does not have multiple public IP addresses. But, that's a solvable problem, so I've added it to the list.
    – Skyhawk
    Jul 14, 2011 at 15:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .