Changing the default network VirtualBox assigns to VMs attached to NAT
By default, VirtualBox assigns a 10.0.2.0/24 address to a VM attached to NAT. Is it possible to change NAT to a different network?
This is not a duplicate question. I know it is possible to define a separate "NAT network" and assign it, but that is not what I want to do. I want to change the default network for the NAT, but I see no way to do that.
Solution 1:
The Virtualbox manual has a section describing how to adjust the default NAT interface behavior, Fine-tuning the VirtualBox NAT engine. You can alter the IP address range and submask, change the behavior of the DNS resolver, and other things.
The actual changes are made through the VBoxManage
command (in other words, there's no GUI). For example, to change the IP address range for the network, you'd run something like this while the guest isn't running:
VBoxManage modifyvm "VM name" --natnet1 "192.168/16"
Solution 2:
For those finding this later, the manual now includes a section on modifying a Nat network.
You can easily modify an existing VirtualBox Nat Network using the modify subcommand
. For example, if you would like to modify your network so the network address is 192.168.0.0/24.
VBoxManage natnetwork modify --netname vboxnet0 --network "192.168.0.0/24"