5

I'm running Ubuntu Server in VirtualBox. When I select the internal network option for the network adapter and start up the VM, I only get IPv6 address. I need an IPv4 address as well. My host (running Windows 7) gets has both an IPv4 and IPv6 address listed when I run ipconfig. When I run ifconfig on the guest (running Ubuntu Server), it only lists IPv6. How can I fix this?

3

Try running:

sudo ifup eth0

At the terminal's command line interface as the ubuntu user.

You might also want to check out the networking documentation, which does state that Virtualbox does not manage the 'internal network' option -- so, if you're wanting your virtual machine to talk to your host, you'll need to specify host-only networking, or bridged/NAT mode if you would like your VM to have the same network access as your VM Host.

2

Unlike IPv6, IPv4 does not have auto-configuration built-in; most of the time, DHCP is used. Try running dhclient eth0 or dhcpcd eth0 (depending on which Ubuntu comes with).

1

If your Windows 7 has an IP, does it looks like: 169.254.0.1 ? If yes it's because Windows failed to get an IP with virtual box and used APIPA to get an IP address. (auto-attribution of IP address)

Also, if you want your VM to access your host the correct setup is "Host-only" network and not internal network.

Here's a link to virtualbox doc for these kind of configuration.

0

Make sure you are connecting your VM to right NIC on your Win7 machine. Had this happen when I bridged to the wired nic and then connected laptop via WiFi (different host nic)

0

I know this question is years old at this point, but it's worth revisiting with an up-to-date answer, since none of the other answers addressed the problem that caused this on my machine.

First, to clarify - I was getting this error when trying to connect two virtual machines via an internal network - both were being assigned IPv6 addresses. Your question mentions your host machine getting an IPv6 address - your host should not be part of the network if you're using VirtualBox's internal network option. (Terminology may have changed in the 5 years since question was asked.)

Setting Up DHCP on Host

If you set the network settings of your virtual machine to use an internal network using the VirtualBox GUI and the machine settings, it will use IPv6 addresses by default - and they also won't be able to ping each other if you use ping6. The solution is to do a bit of DHCP server setup on the host machine using the VBoxManage utility.

VBoxManage dhcpserver add \
--netname intnet \
--ip 10.2.0.1 \
--netmask 255.255.0.0 \
--lowerip 10.2.0.1 --upperip 10.2.0.255 \
--enable

This will set the DHCP server to hand out IP addresses in the range 10.2.0.1 to 10.2.0.255. If the DHCP server already exists, you should change add to modify:

VBoxManage dhcpserver modify \
--netname intnet \
--ip 10.3.0.1 \
--netmask 255.255.0.0 \
--lowerip 10.3.0.1 --upperip 10.3.0.255 \
--enable

Finally, you can remove the DHCP server when you're finished using the remove command:

VBoxManage dhcpserver remove --netname intnet

Also see this YouTube video on setting up an internal network using VirtualBox.

Why other solutions didn't work

  • Solution by @IanWilson doesn't work b/c ifup eth0 will tell you eth0 is already up; bringing it down and back up will just re-assign it an IPv6 address (and ping6 still won't be able to reach other virtual machines on the internal network).
  • Solution by @grawity doesn't work b/c dhclient eth0 will either lead to interface getting another IPv6 address, or the interface will lose its IPv6 address altogether.
  • @Steven's answer and @epingle's answer both address a bridged network situation, where the host can communicate with the virtual boxes over the network, and not an internal network setup, where only the virtual boxes are connected to the network.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.