Server on VirtualBox does not see the client's ip address

Discussions related to using VirtualBox on Windows hosts.
Post Reply
Dazius
Posts: 3
Joined: 3. Sep 2021, 07:26

Server on VirtualBox does not see the client's ip address

Post by Dazius »

A very incomprehensible situation. There is a game server on CentOS 7 that runs in a virtual machine. If run in VMware, players' ip is displayed correctly, if run in VirtualBox, 10.0.2.2 is displayed instead of players ip. I can't figure out how to fix this in any way. The Nat network with port forwarding is used everywhere.
Maybe anyone have any ideas how you can fix this?
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Server on VirtualBox does not see the client's ip address

Post by mpack »

I don't believe there is such a thing as a "player's IP".

Your entire home network shares one public facing IP, which you can discover using one of those "what's my ip" web services. This is the only IP an online game server will see, no matter which of your home devices you use.

All of the devices (not players) on your home network have their own local IP whose nature will depend on how the device is connected to the local network.

In the case of a VM using NAT network mode, it will use a NAT 10.x.x.x network address to talk to VirtualBox on the host PC which it uses as a gateway. Any devices beyond the host PC will see the host PC IP address.

If the VM used Bridged networking instead then it would be a full participant on the host network and receive an IP address in the same way (and format) as all other devices in the host network. Usually that means that the DHCP service running in your home router gives it a 196.168.xxx.yyy address.

Any server software, i.e. any software that needs to be capable of receiving unsolicited comms, needs to be in a VM that uses Bridged mode.
Dazius
Posts: 3
Joined: 3. Sep 2021, 07:26

Re: Server on VirtualBox does not see the client's ip address

Post by Dazius »

I rent a server with one ip address and I cannot make a bridge.
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Server on VirtualBox does not see the client's ip address

Post by scottgus1 »

Dazius wrote:I cannot make a bridge.
Virtualbox doesn't require you to make the bridge, it makes the 'bridge' itself when you set the VM's network type in the adapter's "Attached To:" dropdown to Bridged. See Virtualbox Networks: In Pictures: Bridged Adapter. Your only being able to see 10.0.2.2 IP addresses for your players likely means your VM is connected via NAT, which is the default and is also explained in the Pictures tutorial. If I remember correctly, 10.0.2.2 is Virtualbox NAT's gateway.

If your server provider allows you to run VMs that can access the LAN that the host server runs on as if the VM is another server on the LAN, then Virtualbox Bridged will let the VM talk to the server's internet connection directly on the server's LAN. Whether this allows you to see the IP address of the players connecting to your server is going to be up to the settings in the server provider's network.

If your server provider will not allow you to have VMs sitting on the LAN with their servers, then you will probably not get Bridged to work. At that point, there would be nothing Virtualbox can provide to enable you to see the IP addresses of your players. You would have to rely on other 3rd-party software to report player IP addresses accessing your rented server.
fth0
Volunteer
Posts: 5677
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: Server on VirtualBox does not see the client's ip address

Post by fth0 »

I think the OP is talking about a port forwarding into the NATted VM, where VirtualBox usually replaces the source IP address of the incoming packets. The solution is described in 9.8.7. Configuring Aliasing of the NAT Engine and 8.8.2.1. NAT Networking Settings.
Dazius
Posts: 3
Joined: 3. Sep 2021, 07:26

Re: Server on VirtualBox does not see the client's ip address

Post by Dazius »

Thanks you, it's works:
VBoxManage modifyvm <VM NAME> --nataliasmode1 proxyonly
fth0
Volunteer
Posts: 5677
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: Server on VirtualBox does not see the client's ip address

Post by fth0 »

You're welcome, and thanks for reporting back! :)
Post Reply