How To Create And Use NAT Network In VirtualBox

Create a NAT Network using VBoxManage utility

Open a command prompt (cmd or terminal if you are on Linux/Mac)

## Check existing NAT Networks
$ VBoxManage list natnetworks

## Create a NAT Network
$ VBoxManage natnetwork add --netname NATNetwork101 --network "" --enable

## Check the NAT Network
$ VBoxManage list natnetworks
NetworkName:    NATNetwork101
IPv6 Enabled:   No
IPv6 Prefix:    fd17:625c:f037:2::/64
DHCP Enabled:   Yes     
Enabled:        Yes     
loopback mappings (ipv4)     

## Enable or Disable DHCP for the network (on or off)
$ VBoxManage natnetwork modify --netname NATNetwork101 --dhcp on

## Start the NAT service
$ VBoxManage natnetwork start --netname NATNetwork101

## Enable Port Forwarding to connect to the VMs
## Forward localhost port 1022 to (eg: SSH)
$ VBoxManage natnetwork modify --netname NATNetwork101 \
  --port-forward-4 "ssh:tcp:[]:1022:[]:22"

## If you need to remove the NAT Network
$ VBoxManage natnetwork remove --netname NATNetwork101

Use NAT Network for Virtual Machines

Once you have created NAT Network, assign the same for the VM Network.

Also you can use VBoxManage utility for the same if you are a command line hero.

## Assign NAT Network to a VM
$ VBoxManage modifyvm UbuntuVM --nic1 NATNetwork101

How To Create And Use NAT Network In VirtualBox

Leave a Comment