When setting up a fresh CentOS minimal installation in VirtualBox, many users encounter a puzzling situation where the eth0 network interface is completely missing. Running ifconfig -a
only shows the loopback interface (lo), leaving you without network connectivity in any mode (bridged, NAT, or host-only).
First, let's examine the problematic ifcfg-eth0 file:
DEVICE="eth0"
HWADDR="08:00:27:FE:D5:10"
NM_CONTROLLED="yes"
ONBOOT="no"
This configuration reveals two immediate issues:
- Network interface is set to not start at boot (ONBOOT="no")
- NetworkManager control is enabled (which might conflict with minimal installations)
In newer CentOS versions, the traditional eth0 naming scheme has been replaced with predictable network interface names. You might actually have an interface named like enp0s3
instead. Check with:
ip link show
ls /sys/class/net
Here's how to get your networking working properly:
# 1. First, check for existing interfaces
ip addr
# 2. If no ethernet interface exists, reload the kernel module
sudo modprobe -r e1000 && sudo modprobe e1000
# 3. Create or modify the interface configuration
sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0
Use this configuration:
TYPE="Ethernet"
BOOTPROTO="dhcp"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
NAME="eth0"
DEVICE="eth0"
ONBOOT="yes"
If your system uses the new naming convention:
# Find your actual interface name (e.g., enp0s3)
dmesg | grep -i eth
# Then create corresponding config file
sudo vi /etc/sysconfig/network-scripts/ifcfg-enp0s3
After making changes, restart networking:
sudo systemctl restart network
# Or for NetworkManager systems:
sudo systemctl restart NetworkManager
Check if your interface is now available:
ip addr show eth0 # or your actual interface name
ping google.com -c 3
Ensure your VM settings are correct:
- In VirtualBox settings, verify the network adapter is enabled
- For bridged networking, select the correct host interface
- Try different adapter types (e.g., Intel PRO/1000 MT Desktop)
If issues persist:
# Check kernel messages
dmesg | grep -i eth
# Verify driver loading
lsmod | grep e1000
# Test network manager status
nmcli device status
Remember that CentOS minimal installs often require additional packages for full networking functionality. You might need to install them from the installation media if basic networking isn't working.
When setting up a fresh CentOS minimal installation in VirtualBox, many users encounter a puzzling situation where the eth0 network interface is completely missing. Running ifconfig -a
only shows the loopback interface (lo), leaving you without network connectivity.
The typical /etc/sysconfig/network-scripts/ifcfg-eth0
file in this scenario looks like:
DEVICE="eth0"
HWADDR="08:00:27:FE:D5:10"
NM_CONTROLLED="yes"
ONBOOT="no"
This issue primarily occurs because:
- Modern CentOS versions use predictable network interface names
- The NetworkManager service might be interfering
- The interface configuration file has ONBOOT="no"
- VirtualBox network adapter settings might be misconfigured
Here's how to properly configure networking:
Step 1: Identify the actual interface name
ip link show
# or
ls /sys/class/net
Step 2: Create or modify the interface file
Edit/create the appropriate ifcfg file (e.g., /etc/sysconfig/network-scripts/ifcfg-enp0s3
):
TYPE="Ethernet"
BOOTPROTO="dhcp"
DEFROUTE="yes"
NAME="enp0s3"
DEVICE="enp0s3"
ONBOOT="yes"
Step 3: Disable predictable network names (optional)
If you prefer the traditional eth0 naming:
# Edit grub configuration
sudo vi /etc/default/grub
# Add to GRUB_CMDLINE_LINUX:
net.ifnames=0 biosdevname=0
# Update grub
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
Step 4: Restart networking
sudo systemctl restart network
Ensure your VM settings in VirtualBox:
- Network adapter is enabled
- Attached to: Bridged Adapter or NAT
- Promiscuous Mode: Allow All
- Cable Connected is checked
Useful commands for debugging:
# Check kernel messages
dmesg | grep -i eth
# Check network manager status
systemctl status NetworkManager
# Test interface activation
ifup enp0s3
For systems using NetworkManager:
nmcli connection show
nmcli connection add type ethernet ifname enp0s3 con-name enp0s3
nmcli connection up enp0s3