Understanding Linux Network Interface Naming
Modern Linux distributions have evolved from traditional "ethX" naming conventions (like eth0, eth1) to more descriptive interface names. This change improves consistency but can cause confusion when adding new adapters or cloning virtual machines.
Common Network Card Configuration Scenarios
1. Renaming Network Cards in CentOS 7
To change from predictive names (eno16777736) to classic eth0 naming:
1. Edit the network configuration file:
vim /etc/sysconfig/network-scripts/ifcfg-eno16777736
(Modify NAME and DEVICE to "eth0")
2. Rename the configuration file:
mv /etc/sysconfig/network-scripts/ifcfg-eno16777736 ifcfg-eth0
3. Disable predictable naming:
Edit /etc/default/grub and add:
GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0"
4. Update GRUB configuration:
grub2-mkconfig -o /boot/grub2/grub.cfg
5. Reboot the system:
init 6π Learn more about Linux network configuration
2. Fixing Cloned Virtual Machine Network Cards
When cloning VMs, MAC address changes may cause interface renaming (e.g., eth0βeth2):
1. Edit the configuration:
vim /etc/sysconfig/network-scripts/ifcfg-eth2
2. Change DEVICE=eth2 to DEVICE=eth0
3. Update MAC address if needed
4. Restart network service:
systemctl restart network3. Adding New Network Adapters in Linux VMs
If new adapters don't appear with eth1/eth2 configuration:
- Newer Linux versions use different naming schemes (check with
ip addr) - Configuration files may need manual creation in
/etc/sysconfig/network-scripts/
Advanced Network Configuration
Modifying Network Settings
Edit /etc/sysconfig/network-scripts/ifcfg-eth0 with these key parameters:
TYPE=Ethernet
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.1.11
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=8.8.8.8Reload configurations with:
/etc/init.d/network reloadWorking with Multiple IP Addresses
Add secondary IP addresses to eth0:
ifconfig eth0:1 192.168.0.2 netmask 255.255.255.0Managing Network Interface Names
To reset naming conventions:
- Edit
/etc/udev/rules.d/70-persistent-net.rules - Remove unwanted entries or rename interfaces
- Reboot to apply changes
π Troubleshoot Linux network issues
FAQ Section
Q1: Why does my wireless card show as eth0 instead of wlan0?
A: This occurs when udev rules incorrectly identify the interface. Edit the persistent-net rules file to correct the naming.
Q2: How can I change my CentOS 7 interface back to eth0 naming?
A: Disable predictable naming by adding "net.ifnames=0 biosdevname=0" to GRUB parameters and regenerate the configuration.
Q3: What are virbr0 and virbr0-nic interfaces?
A: These are virtual bridge interfaces created by virtualization software (like KVM). They're separate from physical Ethernet interfaces.
Q4: How do I set network card speed/duplex mode?
A: Use mii-tool or ethtool commands. For example:
mii-tool -F 100baseTx-FD eth0Q5: Why does my cloned VM show different interface names?
A: MAC address changes trigger udev's persistent naming rules. Either update the MAC in configurations or clean the udev rules file.
Remember to always back up configuration files before making changes. For complex network setups, consider using tools like NetworkManager or systemd-networkd for more flexible management.