Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

This question already has an answer here:

My host is a freshly installed Ubuntu 2013.04, wireless network access worked out-of-the-box so I don't have any strange network configuration.

In VirtualBox 4.2.10, with default (NAT) settings, I installed CentOS 6.4 minimal.
Immediately after install, the first thing I did was ping 173.194.38.98 (google) and I a told connect: Network is unreachable.

I tried running /etc/init.d/network start as root, no joy.
I downloaded a VM image and tried it: exact same problem.

When I installed Ubuntu and Windows VMs, they are able to access the Internet without any problem.
What's wrong with this one?

On the VM:

enter image description here

On the host (values never change, except byte counts):

eth0      Link encap:Ethernet  HWaddr f0:de:f1:c0:ad:b3  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:20 Memory:f3900000-f3920000 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:32272 errors:0 dropped:0 overruns:0 frame:0
          TX packets:32272 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:4263162 (4.2 MB)  TX bytes:4263162 (4.2 MB)

wlan0     Link encap:Ethernet  HWaddr 60:d8:19:c9:42:59  
          inet addr:192.168.0.67  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::62d8:19ff:fec9:4259/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1221151 errors:0 dropped:0 overruns:0 frame:0
          TX packets:845193 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1438957835 (1.4 GB)  TX bytes:133904229 (133.9 MB)

Note: Similar to this question but switching from NAT to Bridge is not a solution I find acceptable.

share|improve this question

marked as duplicate by slm, Anthon, jasonwryan, Hauke Laging, Mat Jun 14 '13 at 4:44

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
Have you looked at your host network adapter, does it change when the VM comes online? Is it wireless by any chance (had troubles with that myself)? –  Anthon Jun 13 '13 at 10:29
    
@Anthon: I restart while watching, and the result of ifcongig -a never change except byte counts. Yes, I am on wireless. –  Nicolas Raoul Jun 13 '13 at 11:21
    
I thought it was the wireless that could be a problem (I never got that to work when I tried, but that is only with bridged mode). –  Anthon Jun 13 '13 at 12:53

2 Answers 2

up vote 2 down vote accepted

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|improve this answer

Issues with udev

See my answer to this question: Is VMWare causing my Linux host to lose network connectivity?. In general when your network shows up with eth1 instead of eth0 bells should be going off (at least in CentOS 6.x). It usually means that the ethernet NIC is under the control of NetworkMangaer or udev is messing up the detection of your NIC as eth0.

I usually start by looking at the rules.d directory of udev:

# /etc/udev/rules.d/70-persistent-net.rules
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.

# net device () (custom name provided by external tool)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="54:52:00:ff:ff:dd", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

You want to make sure that only one entry exists in this file. If there are multiple, then you'll need to manually clean up this file, so that there is only a single entry and that it's pointing to eth0.

Issues with NetworkManager

The other thing you'll need to take a look at is how is NetworkManager setup. Again check out this other Unix & Linux quesiton: CentOS no network interface after installation in VirtualBox. I provided an answer on that question as well which shows you the steps for manually setting up a wired network using NetworkManager.

Incidentally, NetworkManager is now the default setup for networking when doing installations of CentOS 6.x!

share|improve this answer

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