Network adapter connected by NAT has same address as host

1

I have created a virtual machine with 2 network adapters, one connected to the host using NAT and the second connected through a host-only adapter.

This set-up works for what I want to do,

  • Give the guest OS access to the internet (NAT interface eth0)
  • Expose a web interface, hosted on the guest, to the host OS. (Host-only adapter eth1)

The problem is that the guest interface which is connected to the internet (eth0), has been assigned the same IP address, through DHCP, as the host OS.

ifconfig for host and guest OS

Does anybody know how to configure virtualbox or the guest os so it gets a unique IP address?

Thanks!

My /etc/config/network file in the guest OS:

config interface 'loopback'
        option ifname 'lo'
        option proto 'static'
        option ipaddr '127.0.0.1'
        option netmask '255.0.0.0'

config interface 'lan'
        option ifname 'eth0'
        option ipaddr '10.0.2.20'
        option netmask '255.255.255.0'
        option proto 'dhcp'

config interface 'lan2'
        option ifname 'eth1'
        option proto 'static'
        option ipaddr '10.88.12.1'
        option netmask '255.0.0.0'


config interface 'wan6'
        option ifname '@wan'
        option proto 'dhcpv6'

config globals 'globals'
        option ula_prefix 'fd62:86eb:0d01::/48'

If I set proto to static for the lan interface, the IP address is set to 10.0.2.20 but I can not connect to the internet.

TomSelleck

Posted 2013-12-12T10:43:17.217

Reputation: 133

You can set a static ip for the guest. What os does it run? – Jake – 2013-12-12T11:01:28.527

Hey, I have updated my question with more details if that helps. – TomSelleck – 2013-12-12T11:39:43.053

Answers

1

From the VirtualBox GUI, File -> Preferences -> Network -> NAT Networks -> Screwdriver -> Network CIDR. You can change the IP range of your NAT network here, choosing something that does not conflict with your host's LAN. Even 10.0.3.0 will do.

Here is a picture of what it should look like:

enter image description here

MariusMatutiae

Posted 2013-12-12T10:43:17.217

Reputation: 41 321

Thanks for the reply, in my VirtualBox Network page, there is no NAT Networks option, only Host-only Networks. – TomSelleck – 2013-12-12T11:51:35.230

Did you follow the list of arrows I wrote? Which version of VirtualBox are you running? – MariusMatutiae – 2013-12-12T11:54:14.610

4.2.18, looks like it was only introduced in 4.3. I will update it now and give it a try. – TomSelleck – 2013-12-12T11:56:25.920

@Tomcelic Please look again at my answer. – MariusMatutiae – 2013-12-12T11:57:50.723

I have followed your steps and my guest OS uses the NAT Network. The NAT Network isn't connected to the internet though – TomSelleck – 2013-12-12T12:10:03.433

Sorry actually, it looks like it is connected to the internet, however I can't ping any addresses. – TomSelleck – 2013-12-12T12:13:18.383

Seems ping isn't supported in guest OS's using this type of adapter.

https://forums.virtualbox.org/viewtopic.php?f=6&t=58041

– TomSelleck – 2013-12-12T12:17:56.997