Data Centers

How to create multiple NAT Networks in VirtualBox

For an easy way to work with NAT networks and virtual machines, check out how to use VirtualBox's NAT Networks.

Image: Jack Wallen

If you've ever tried to work with Network Address Translation (NAT) within VirtualBox, you know it isn't easy. Recent iterations of the tool include a new feature called NAT Networks that allows you to create custom NAT Networks, which are easily applied to your virtual machines. This is necessary because you might want or need to be able to assign different virtual machines to different NAT address schemes so they'll appear on different portions of your network. In pre-5.x versions of VirtualBox, this wasn't possible.

Now you can create different NAT Networks, which can be assigned to your virtual machines; this allows you to attach virtual machines to a specific NAT Network so they can see one another and not be seen on your primary company network.

Let's walk through the process of creating a NAT Network and assigning it to a virtual machine.

SEE: Virtualization Policy (Tech Pro Research)

Creating a new NAT Network

To create the NAT Network, open VirtualBox and click File | Preferences. In the Preferences window, click Network and then click the NAT Networks tab. In this new window (Figure A), click the + button to create a new NAT Network.

Figure A

Figure A
Image: Jack Wallen
The VirtualBox Network settings window

Once the NAT Network is created, select it and click the edit button (the screwdriver icon). In this window (Figure B), edit the new network according to your needs, including giving the network a unique name that helps you know which network it is to be used as. Click OK. The network is now available to VirtualBox.

Figure B

Figure B
Image: Jack Wallen
Configuring the new NAT Network to meet your needs.

Assigning your new NAT Network to a virtual machine

Now it's time to assign the network to your virtual machine. To do this, the virtual machine must be powered down/shut off (not paused or in a saved state).

Select the virtual machine in the virtual machine listing and click the Settings button. In the VM Settings window, click Network and select the Adapter 1 tab. From the Attached To drop-down, select NAT Network and then, from the Name drop-down, select the newly created NAT Network, and click OK (Figure C). Your virtual machine will be associated with that NAT Network. Add other virtual machines to that same VirtualBox NAT Network, and the VMs will be able to see one another without having any effect on your main network.

Figure C

Figure C
Image: Jack Wallen
Selecting the correct NAT Network for the virtual machine.

A great tool for testing

VirtualBox NAT Networks is a great way to easily test servers. By using nothing but virtual machines, you could recreate your network for use as a test bed for rolling out new servers and services, or even running a test security audit.

Give NAT Networks a try on VirtualBox, and see if it doesn't make your data center easier to test or expand.

Also see

About Jack Wallen

Jack Wallen is an award-winning writer for TechRepublic and Linux.com. He’s an avid promoter of open source and the voice of The Android Expert. For more news about Jack Wallen, visit his website jackwallen.com.

Editor's Picks

Free Newsletters, In your Inbox