I have Ubuntu 12.10 on which I installed virtual box on which I setup Centos 6.4 i386. On Ubuntu I have: 3.5.0-17-generic kernel running.

On virtual box I install Centos 6.4 and everything works fine, however when I boot into VM machine, there is only on loopback interface. Nothing else. I tried to manually add ifcfg-eth0 file but nothing happens. On VM settings I have added NAT and HostOnly interfaces but whenever I boot into Centos there is just lo interface. What should I do?

10 Answers 10

You need to enable networking during installation. You can do it post install as well. This is a change in the CentOS installation in the 6.x versions which throws a lot of people off, including myself.

Starting with CentOS 6.x you can either opt to have NetworkManager manage your network setups or still do it the old fashion way and set them up manually using /etc/sysconfig/network-scripts/ifcfg-eth0 types of files. Given this is a VM I'd recommend using NetworkManager.

To invoke the connection editor tool do the following:

$ nm-connection-editor

You'll be presented with a GUI like this:

                         ss of conn. editor

From this GUI you'll need to edit the eth0 setup like so:

                         ss of nm #1

                         ss of nm #2

                         ss of nm #3

Without a GUI

If you're attempting to do this on a headless server you can edit the following files and reboot to get your eth0 networking device to come up enabled and acquire an IP address from a DHCP server. Change these 2 options in the file, /etc/sysconfig/network-scripts/ifcfg-eth0:

ONBOOT="yes"
NM_CONTROLLED="no"

References

  • 4
    Centos 6.4 "nm-connection-editor not found" ... no GUI running. Headless server. no joy. :( – Mojo Jul 22 '13 at 19:10
  • 1
    "Without a GUI" steps worked perfectly, thank you so much! – Wildcard Jul 29 '16 at 22:38
  • The Without a GUI steps threw me off a bit until I checked out the next few answers. In CentOS min, instead of eth0 it is something else, so please update your answer to ifcfg-XXXX. Also, NM_CONTROLLED was not listed and as the others did not specify it I did not add it so that must be the default. Network is up and running now. If you can also update answer to redirect 'NO GUI' guys, or place it above the GUI answer that would be great, as I suspect n/w would be disabled only on min distros, if it is disabled on normal distros, that is questionable as it would befuddle a lot of noobs. – killjoy Mar 19 '17 at 14:42
  • @killjoy - what CentOS version are you using. What I showed above was how it was in 2013 when I wrote this up. Things may have changed in newer versions. Also the NM_CONTROLLED is how you can explicitly do this. Hence why I showed it. – slm Mar 19 '17 at 14:47
  • @slim - latest 7 version as of the date of the post, in fact some others have different values also. On my work VM, it is '-eno', so yeah I guess it is not a static eth0 as before. – killjoy Mar 20 '17 at 15:50

Run the command:

$ ip a

This will show the the interfaces. Got to /etc/sysconfig/network-scripts open the corresponding ifcfg file and set on boot to yes. Restart the system and you are down.

By default this is set to no in Centos 7

  • Does it matter if you're running in a VM? Because I've done all of this a bunch of times, and it STILL says the network is unreachable, and I can't install the VirtualBox guest additions without the network, because CentOS doesn't include bzip2 for some retarded reason. – MarcusJ Dec 15 '15 at 15:18
  • 1
    To expand on this, you can create a new ifcfg file and name the interface whatever you want with the DEVICE=[name] option so long as you include the HWADDR=[mac address]. – Centimane Feb 16 '17 at 13:30
  • You also need to change this line: NM_CONTROLLED=no – Rob Sedgwick Oct 27 '17 at 16:40
  • what do you do if there's no ifcfg- file that corresponds to the device ip a shows? – marathon Jul 25 at 22:40

When you make a new virtual machine (i.e. a guest OS) with VirtualBox it will, by default, make the NIC an Am79C973. Whilst this NIC may be supported by many OSes, this particular NIC does not seem to be supported by CentOS 7. This means that the only NIC which will show up inside your new CentOS 7 VM will be the loopback NIC. What you need to do is change the NIC to one which is supported like the 82543GC.

First, stop the CentOS VM if you haven't already, and then change the NIC using this command on your VirtualBox host:

vboxmanage modifyvm "testvm" --nictype1 82543GC

Now, start your CentOS VM again and you will notice that it has now has an NIC.

I hope that this helps.

  • I am not using vbox. I am just running centos as a dual-boot but I have the same.problem as op – samayo Dec 20 '16 at 22:49
  • Was having the same problem as OP, this solved it for me.(VirtualBox+CentOS 7) – hoosierEE Feb 7 '17 at 18:34

have a look at the NIC-configurationfiles /etc/sysconfig/networking/devices/ifcfg-ethX and check if the parameter ONBOOT exists. If not – add it.

grep "ONBOOT=yes" /etc/sysconfig/networking/devices/*
/etc/sysconfig/networking/devices/ifcfg-eth0:ONBOOT=yes
/etc/sysconfig/networking/devices/ifcfg-eth1:ONBOOT=yes

Reboot or /etc/init.d/network restart after the change should bring your interface up.

  • A hearty +1 for using grep to find out where they put the config this week! (BTW same issue on Centos6 and the fix still worked) – gbarry Sep 1 '17 at 5:52

In centos 7, the network interface name is enp0s3, to make the networking work, you need to edit the corresponding files by:

sudo vim /etc/sysconfig/network-scripts/ifcfg-emp0s3

And set the ONBOOT to yes

ONBOOT=yes
  • Woa woa woa, that is a gross oversimplification of CentOS 7 interface naming. See: cgit.freedesktop.org/systemd/systemd/tree/src/udev/… for reference. Chances are the interface is more likely a p#p### format interface, but either way it's better to determine the actual name than guess it. – Centimane Feb 16 '17 at 13:27
  • Also, the asker is using CentOS 6.4, so CentOS 7 interface naming is not relevant. The interface naming changed drastically in 7. – Centimane Feb 16 '17 at 13:40
  • 1
    Worked for me. Thanks. I am on free RHEL.To know the name of interface run pifconfig. Yes RHEL did not come with ifconfig. Even in sbin. Ubuntu is better in this regard. – NotAgain Feb 24 '17 at 2:43
  • @Centimane Hey, thanks for letting me know that i oversimplify. But for me it is work, and not sure if it's a bad practice. Would you mind to share the proper way to get the correct interface for centos? So that it would be "Bulletproff" for future Centos Version. – Yana Agun Siswanto Feb 24 '17 at 22:30
  • 1
    The interface names are based on the hardware, so the interface name is based off what type of NIC you're using, and how the hardware is reported to RHEL. Based off your interface name RHEL thinks your NIC is an embeded device, port 0 slot 3. But different hardware will use a different NIC name. – Centimane Feb 25 '17 at 21:32

I think it's probably the network-setting that throws it. I've found mine work best with "Bridged Adapter", as you then use the host's network card directly. It'll also allow the virtual-computer to use DHCP to get it's own internal-IP from your router.

NAT is a bit strange, as you use only one IP-address (the same as the host's?) and instead relay on translation of ports - thus it's not really a separate IP for the virtual-computer. HostOnly I think only allows the virtual-computer to make "local network" with your host - ie. no external Internet. And that pretty much leaves you with just the loop-back device.

Running dhclient –v as root fixed it for me.

I got this solution from this article.

  • It solved my problem, thanks – sinoohe Sep 17 '17 at 8:14

This looks to me like a /etc/udev/rules.d/70-persistent-net.rules issue. Unless this file is deleted, editing ifcfg-ethX won't help because whatever old settings you had will persist. Delete the file, then use "udevadm trigger" to recreate it.

  • I don't see how this relates to a device not being present. – thrig Mar 1 '17 at 15:10

This applies specifically to VMBox where you installed a new clone (mine was CentOS) and don't see an IP address:

  1. Stop the VM. Go to Settings->Network->Advanced. Then reset MAC address by clicking on the blue icon on the right. Note the new MAC Address somewhere.
  2. Start the VM. Go to System->Preferences->Network Connections. Edit the Connection eth0 ->Device MAC address with new MAC address from step#1 adding ":" between two characters. e.g. 08012741798D to 08:01:27:41:79:8D and save
  3. Reboot, then logged in as root: cd /var/lib/NetworkManager
  4. remove or move NetworkManager.state to another folder e.g.: mv NetworkManager.state NetworkManager.state.save
  5. run: service NetworkManager stop
  6. run: service NetworkManager start
  7. To see new IP address run: ifconfig -a

I ran into the same problem; I solved it configuring the network in the virtualBox configuration → network setting page: I selected "Bridged Networking".

http://www.thegeekstuff.com/2012/03/virtualbox-guest-additions/

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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