6

I have a fresh virtual box Ubuntu Server 16.04 32-bit guest installation on a Linux Mint 18 Cinnamon 64-bit host. I want to have the guest system to appear to the local network like a physical machine. Therefore, I need bridged network mode for the guest---host-only and/or NAT won't do. The host system is connected via ethernet cable and guest additions are installed on the virtual machine.

The odd thing is, during installation, the guest system is perfectly able to download additional packages. Once logged in, however, I can neither ping computers in the local network nor external servers like google.com.

For google.com, it says "ping: host unknown", for the local router (192.168.178.1), it says "connect: Network is unreachable".

Upon closer examination, I found out that the virtual machine has not received an IPv4 address from the DHCP server of my router. However, my router displays that an address has been assigned (the fourth entry).

I tried setting a static IPv4. Then, the according address shows up on ipconfig. But still, the guest cannot ping anything. Also, actually I want the virtual machine to receive its IPv4 address from the local DHCP server anyways.

In /etc/network/interfaces, the network interface from ipconfig is initialized as follows: allow-hotplug enp0s17 iface enp0s17 inet dhcp

Things I tried:

  • setting the guest to a static IPv4
  • disabling IPv6
  • deleting /etc/udev/rules.d/70-persistent-net.rules
  • sudo ip link set enp0s17 up
  • dhclient enp0s17

None of these worked. Can anyone help me to solve this problem?

6 Answers 6

4

The first answer to this seems a little over-complex to me. The following should work. Open the guest machine and do the following:

You might want to disable it right from the boot. For this purpose, open:

/etc/default/grub

with your favorite text editor with root access:

i.e.

gksu gedit /etc/default/grub

or if you prefer to work with command line only:

sudo nano /etc/default/grub

In this file, find this line:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"

and change it to:

GRUB_CMDLINE_LINUX_DEFAULT="ipv6.disable=1 quiet splash"

Save the file and update GRUB by running:

sudo update-grub

If you tried the sysctl method:

See the following question/highest voted answer, because you can set ip6 values to 0 and if you do not init sysctl as part of boot it would ignore it anyway (read the default ip6 value after you set everything to 1 to disable if the system reports 0 you need to get sysctl running):

How to disable IPv6 in Ubuntu 14.04?

I like my method because it disables ip6 at boot, so nothing tries to go the ip6 route during boot (some may even get errors with it enabled at boot and disabled inside the OS itself). It's also only a small adjustment to one line in one file making things really easy, and you are not forced to sacrifice line speed as you would be doing if using less than the 100 MHz Full Duplex or 1000 MHz Full Duplex (if you have Gig it is the latter if 100 Meg router or switch it will be the former).

3

In the Settings for the VirtualBox VM, go to Network and then drop down the Advanced settings in the right-hand pane and check the "Adapter Type." The default appears to be "Intel PRO/1000 MT Desktop (82540EM)." With that adapter type, I had the exact same problem, so I tried changing the Adapter Type to "Intel PRO/1000 MT Server (82545EM)" and then updating the /etc/network/interfaces file (if you change the adapter type before you install Ubuntu Server it should create the interfaces file with the correct info) and it now works fine. The version of VBox I'm using is 5.1.28 r117968 (Qt5.6.2) on a Windows 10 host and using Bridged networking.

4
  • 1
    After updating virtual box and the drivers of my network card (intel i211) I had the same problem with my guest (only ipv6, no ipv4). Before the updates everything worked nicely. Problem got solved after switching the Adapter Type to "82543GC" and rebooting the guest. Commented Jul 5, 2020 at 8:55
  • Switching to the Server network adapter actually worked for me! Strange strange.
    – xjcl
    Commented Jul 30, 2020 at 6:23
  • looks like I made the mistake of installing my VM with no network adapter connected, so my /etc/network/interfaces file was completely empty even after adding a network device to the VM later. Commented Jun 10, 2021 at 17:28
  • Only changing the adapter type worked for me in Bridged mode, although one strange thing is that when I was running my slax linux directly through ISO not installed on disk Intel PRO/1000 MT Desktop (82540EM) also woked fine, only when I install OS on disk my bridged adpater gets no IP. And If I have 2 guest Slax Linux OS one running via ISO and other through VDI disk then If i start ISO guest machine first it gets IP and post that if I start VM which runs OS through virtual disk image that also gets IP, If I only run VM which runs OS through VDI and not ISO then I get no IP on bridged int
    – mSatyam
    Commented Oct 26, 2021 at 19:04
1

The problem is different, but the solution is the same.

Start with 10Mbps, half duplex and work upwards to 10Mbps FD, 100Mbps HD, ... until the problem starts. Then go down one notch and leave it at that speed.

First, install ethtool (if already installed you will just get a warning that the latest version is already installed)

sudo apt-get install ethtool

Now:

  1. Type the following command (and test them one by one)

    sudo ethtool --change eth0 speed xxx duplex yyy autoneg off

    where xxx = 10, 100 or 1000 and yyy = half or full.

    So start with 10 half, 10 full, 100 half, ...

  2. Do an ifconfig to check whether you got an IP address.

  3. Go back to 1 until it stops working and use the previous values that still worked to:

  4. To make the change permanent, execute the following command:

    sudo nano /etc/network/interfaces

    and type at the pre-up section:

    pre-up /usr/sbin/ethtool --change eth0 speed xxx duplex yyy autoneg off

Note the full entry posted by OP:

auto eth0
iface eth0 inet dhcp
    pre-up ifconfig $IFACE up
    pre-up ethtool -s $IFACE speed 100 duplex full autoneg off
1

I had the similar problem. /etc/network/interfaces had the ips etc. but wouldn't take it. I had to uninstall netplan and install ifupdown via apt install ifupdown. Once it had this installed the ips were being recognised from the /etc/network/interfaces file.

Hope this helps others who have this problem.

0

I had this problem twice. Once, it happened when my internet modem/router did not have internet connectivity (LOS LED blinking). After the connectivity was restored, it got solved. I don't know what is the relation since DHCP server is inbuilt in the modem and has no relation with internet..but there it is.

Second, it happened, whenvirtualbox was asking for update and I did not update. So, after updation I started getting address in bridged mode

0

In my case, the solution was even more simple. I was using an hub to reach Internet. So the name of the adapter was not something like Realtek PCIe GBE Family Controller but the name of the hub connector. I got back IPV4 as soon as I plugged back the connector on the PC.

Hope it's help :)

You must log in to answer this question.

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