Virtualbox: How to setup NAT with DHCP

Hi folks, in this article I will demonstrate how easy it is to setup a NAT (Network Address Translation) on virtualbox. I use this very often to isolate resources from my virtual servers and my physical network while still having access to the internet from my virtual servers. Another great thing about this setup on virtualbox is the possibility to have native DHCP for your NAT configuration, allowing you to perform a broader range of tests.

Let’s get it started! Open up your virtualbox and go to File -> Preferences and on the newly opened window, select Network and click on the add icon as illustrated in the image below:

nat1

The new network will be added to the list, double click on it and edit the network name, IP range, mask and enable the DHCP. Here is an example of how to setup a NAT that will work with IPs ranging from 172.16.2.2 to 172.16.2.254, where 172.16.2.1 will be its default gateway:

nat2

Now you can go to any of your VMs and change their NIC to NAT and select the entry nat_net1.

nat3

That’s it, simple and easy. Hope this helps.

About Bruno Carvalho

Gimme coffee!
This entry was posted in Virtualization and tagged , , , , , , , , , . Bookmark the permalink.

1 Response to Virtualbox: How to setup NAT with DHCP

  1. Pingback: Port forward to NAT networks from different hosts on Virtualbox | SAP, Databases and other IT stuff

Leave a comment