I have two virtual machines both running on a Linux host (Fedora 16). I set both adapters as attached to NAT. When I boot them up they both have their default gateway set to They also both have the same IP address ( They are both on the same adapter (adapter 1). I don't know why they are getting assigned the same IP address, and shouldn't the default gateway be since the subnet address is and the netmask is Is there something I am missing, has this happened to anyone before? How do I get the VirtualBox DHCP working properly?

  • 2
    That is not necessary true, it is possible to create a "true" virtual NAT network in which the multiple VM have to be assigned different IP address based on it's virtualized MAC address, and the VM can see each other behind the NAT network, basically virtually an entire subnet behind the NAT interface. Depends on your choice in the network adapter configuration, if "NAT" is chosen, the NAT is a one on one host/vm relationship, if "NAT network" is chosen, then it's a host/subnet relationship in which each VM on the virtualized network will have to have different IP addresses.
    – user98773
    Jan 10, 2015 at 16:30
  • I answered a similar question here
    – Mian Ahmad
    Sep 17, 2019 at 20:53

11 Answers 11


VirtualBox DHCP is working properly.

There is nothing wrong with having all of your machines getting the same address in NAT configuration. All VMs are isolated from each other so there is no risk of conflict. They are also not on the same adapter. Each VM has its own virtualized hardware including NICs.

The default gateway also need not to be Although it is a common practice to have it at the lower IP address, it can be any IP in the subnet range.

Also, there is no "real" dhcp service, everything is hardcoded in the VirtualBox code, although if you are not happy with the default IP addresses you can fine tune the NAT engine.

  • Hi @jlliagre, is this really expected behavior? As I understand, if all VMs were assigned the same IP address, they will not able to use this network interface to communicate, right? If so, you are stating that for a bunch of VMs, if each of them only have a single NAT adapter, by default they are not able to communicate. Feb 26, 2019 at 21:54
  • 1
    @OgrishMan Yes, this is the expected behavior. That's one of the main rationale of NAT. It allows many machines to use the same local IP address. They cannot directly communicate, just like my laptop having as IP address cannot communicate with your device, which might use the very same IP address. The main reason why they cannot communicate is that they are on different LANs anyway. Machines only using NAT interfaces can communicate together only through an external third party gateway, or using reverse port mapping at the host level.
    – jlliagre
    Feb 26, 2019 at 22:08
  • Thank you for the explanation! I think I'm clear now. Feb 26, 2019 at 22:10

In VirtualBox control panel go to File -> Preferences -> Network

Select NAT Networks tab, create a new "NatNetwork" by clicking + button at side and press OK.

Now select each VM go to Settings -> Network

In Attached to: option choose NAT Network and select "NatNetwork" and press OK.

Restart all the VMs.

Now VMs have different network address.

  • 4
    I'm finding I still get the same IP addresses using this approach! May 16, 2019 at 0:46
  • 2
    Did exactly these steps and got same ip address .
    – Mehdi
    Jan 27, 2020 at 20:16
  • 4
    You also need to have different mac addr on the machines. Settings -> Network -> Advanced, refresh the MAC addr until you have different ones for the vms May 10, 2020 at 14:06
  • I cloned my VM and it cloned my MAC and had to change it, thanks for pointing this out @AlexandruPirvu!
    – ossys
    Jun 20, 2021 at 2:13
  • If this answer doesn't solve it, the problem is probably systemd (as always): See unix.stackexchange.com/a/419322
    – Henning
    Nov 26, 2021 at 18:08

Your virtual machines will get the same IP address from any DHCP service as long as they have the same Ethernet MAC address (a hardware address, unique like a fingerprint, set by the hardware manufacturer of your network device).

Since you are running virtual machines, they have virtual hardware and therefore they "fake" the MAC address. You have to make sure no two machines have the same Ethernet hardware address.

You can set the Ethernet MAC address of your virtual machine in VirtualBox in the hardware network section (it looks like this: 3c:08:51:05:24:8a)

You can check it in your running VM:

sudo ifconfig

    ether 3c:08:51:05:24:8a 
    media: autoselect (none)
    status: inactive
  • 2
    The NAT dhcp server embedded with VirtualBox isn't a real one. In particular it doesn't care about MAC addresses. In any case, multiple VM might have the same MAC address, that doesn't matter as the virtual networks are fully isolated.
    – jlliagre
    Jan 27, 2012 at 23:00

I encountered the same problem on KVM. The two virtual machines are having the same ip address, and one of them can't access the external network.

The problem lies in the DHCP services. Basically there are two solutions for that:

  1. Configure the ip address with dhcp explictily, which is to run dhclient enp1s0 in your virtual machines (enp1s0 is the interface). Then you find the ip addresses are changed and configured correctly.

  2. The 2nd solution is to assign fixed ip addresses for the virtual machines as below:

  • Go to /etc/netplan (for Ubuntu)
  • Edit the .yaml file in the directory (there should be only one file there and you may want to backup it first)
  • Give it a fixed ip address (in this case I set it to The whole file is like this
  version: 2
  renderer: networkd
      dhcp4: no
      addresses: []
        addresses: [,]
  • netplan apply to active the setting.
  • Then you can ifconfig to see the ip changes.

Hope this solves your problem.


open network setting for each vm, click on advanced > click the refresh button beside the mac addr. Get a different one on both and you are all set


They will get their default gateway from the dhcp server - so it will be whatever is set up in there. You will need to look at the dhcp server to see what it is delivering (generally just set it in the server config to be whatever you want it to be)

With regard to the two adapters having the same address, this is most likely down to the configuration you have set in Virtualbox. If they are clones then you may need to explicitly give one a new MAC address.

Check the network configurations for each and see if they think they are the same.

If different, you could temporarily set a fixed IP for each one at the dhcp server (assigned by MAC address)

Have a look at this section from the VirtualBox manual for more information.

  • 1
    The link you posted doesn't apply to NAT.
    – jlliagre
    Jan 27, 2012 at 23:01

I had the same issue. Assigned Adapter2 to the 2nd guest OS. Unique Mac and Ip address assigned for the guests.

enter image description here


Two settings need to be changed.

1) In VM box side - Console VMware client software change the network settings (ie) add a new nat on network settings. 2) In VM machine side - Refresh the Mac address for each VM.


Faced same problem and case for me is because I have same MAC address for both machine. when adding the nat network into the VM, you can use the refresh button to get an new MAC address. once I set my machine into different MAC address. they are automatically assgined to different IP NAT network setting


This is a late answer for any future person who get this question!

  1. The VM must be powered off

  2. In VirtualBox

    • Select the Machine (i.e. 'Windows 7')
    • MAC Address
    • Refresh
  3. Boot the selected machine

  4. In "Adapter properties", change IP Address to static, for example (change to adapt to your needs):

    IP =
    Netmask =
    Default Gateway =
    DNS =

Now I have for 'Windows 7', and for other machine ( i.e. 'Win10').

For linux guests follow specific "How to set static IP address" for that network device.


Just like @jlliagre said, VirtualBox's networking mode 'NAT' is different from 'Network Address Translation Service' mode.

In Oracle VM VirtualBox this router is placed between each virtual machine and the host. This separation maximizes security since by default virtual machines cannot talk to each other.

ref: Network Address Translation (NAT)

In other words:

[VM1] <-> (NAT1) <-> [Host] <-> (NAT2) <-> [VM2]

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .