VirtualBox with Centos 7 minimal install, cannot connect to network

13,500

Solution 1

You have likely not configured your network in Virtualbox correctly.

Please refer to section 6.2: https://www.virtualbox.org/manual/ch06.html

By default, Virtualbox puts adapters in NAT mode. This works for connecting the virtual machine to the internet, but not much else. This is because Virtualbox creates an additional NAT on your machine, and puts the VMs behind it.

In my view, the desirable mode is "Bridged Networking", where the VM acts like a separate device on your network, bridging directly to your network adapter. Then it will be on the same subnet as any other machine on your network.

There are other use cases for the other networking modes, but I find that 99% of the time, bridged mode is what I want for the VM.

Solution 2

To get Centos to run on Virtual Box, in /etc/sysconfig/network-scripts/ifcfg-eth0:

DEVICE=eth0  
BOOTPROTO=dhcp  
ONBOOT=yes

You might need to reboot.

Share:
13,500

Related videos on Youtube

Neilos
Author by

Neilos

Updated on September 18, 2022

Comments

  • Neilos
    Neilos almost 2 years

    I just installed Centos 7 on a VM I'm running from VirtualBox on a windows machine.

    I installed the latest minimal release. I then went about setting up a static IP. When I try to access the machine I cannot, I cannot ping out from the machine either.

    I'm not sure if it is a CentOS problem or a VirtualBox problem.

    Here is the output of ip addr:

    ip addr

    Here is the output of nmcli d:

    nmcli d

    I should also mention that really I have no idea what I am doing.

    • Neilos
      Neilos about 9 years
      @mashup thanks for the link. Yes this is what I needed to do.
  • Neilos
    Neilos about 9 years
    Well... that was fairly painless... I can now ping my other machines and ssh into it from the network, superb. Thanks.
  • Levi_OP
    Levi_OP about 9 years
    @Neilos My pleasure. When I first ran into that problem...ohhhh...four or so years ago, it took me months of tearing my hair out before I finally figured it out. I'm happy to pass on the knowledge to others :)
  • Neilos
    Neilos about 9 years
    At work we use VSphere and it is all managed for us, this is the first time I've set it up myself! You've saved my hair tonight, I hope yours grew back! ;)