Because VirtualBox assigns 10.0.2.0 network by default to its NAT network (refer to the documentation):
The virtual machine receives its network address and configuration on the private network from a DHCP server integrated into VirtualBox. The IP address thus assigned to the virtual machine is usually on a completely different network than the host. As more than one card of a virtual machine can be set up to use NAT, the first card is connected to the private network 10.0.2.0, the second card to the network 10.0.3.0 and so on. If you need to change the guest-assigned IP range for some reason, please refer to Section 9.11, “Fine-tuning the VirtualBox NAT engine”.
Also, 10.0.2.2
in your case is the interface of your host machine (another interface in addition to 192.168.1.x
).
This is how NAT (Network Address Translation) works. VirtualBox translates the address 10.0.0.x
of your machine and sends the packets as originating from the host machine, i.e. 192.168.1.x
. And it uses the same default gateway as your host machine 192.168.1.1
. It does the reverse translation for packets coming back to the VM.
But you will not be able to ping the guest machine using its address from 10.0.2.0
network. It's behind VirtualBox NAT router.
You can configure NAT Network, or use a Bridged Adapter. But in this question you asked why they had different default gateways.
If you would use bridge-mode, it might be able to ping. – Tech-IO – 2016-12-11T09:59:43.763