VMware中CentOS 6.9新增网卡无ifcfg-ethx文件问题咨询
Hey there, let's tackle your questions about the missing network config files and NIC bonding in CentOS 6.9 on VMware.
为什么添加新网卡后没有自动生成ifcfg-ethx配置文件?
There are a few common reasons this happens:
- Network服务未自动触发配置生成: CentOS 6's
networkdaemon doesn't automatically createifcfg-*files for newly added network interfaces by default. Unlike newer RHEL/CentOS versions, it requires manual intervention or explicit detection triggers. - udev规则未更新: The
70-persistent-net.rulesfile (located at/etc/udev/rules.d/) maps MAC addresses to interface names. If your new VMware NIC's MAC isn't listed here, the system might not assign it anethxname, or fail to generate a config. You can check this file withcat /etc/udev/rules.d/70-persistent-net.rulesto see if the new NIC's MAC is present. - VMware硬件未被识别: Sometimes hot-adding a NIC in VMware doesn't trigger the OS to detect the new hardware immediately. You might need to reboot the VM, or reload the network module with
modprobe e1000(or the appropriate module for your VM's NIC type, likevmxnet3). - SELinux限制: If SELinux is in enforcing mode, it could block the automatic creation of config files. You can test this temporarily with
setenforce 0, then check if the file appears. If it does, you'll need to restore the SELinux context withrestorecon -R /etc/sysconfig/network-scripts/instead of leaving SELinux disabled.
网卡绑定是否需要手动创建ifcfg-ethx文件?
Absolutely. For NIC bonding (teaming) in CentOS 6.9, you must manually create all required configuration files, including both the bond master interface and the slave NICs. Here's a quick breakdown of the steps:
Create the bond master config file (e.g.,
ifcfg-bond0):vi /etc/sysconfig/network-scripts/ifcfg-bond0Add this content (adjust IP settings to match your network):
DEVICE=bond0 TYPE=Bond BONDING_MASTER=yes IPADDR=192.168.1.100 NETMASK=255.255.255.0 GATEWAY=192.168.1.1 DNS1=8.8.8.8 ONBOOT=yes BOOTPROTO=static BONDING_OPTS="mode=1 miimon=100" # mode=1 is active-backup; adjust as neededCreate config files for each slave NIC:
For each NIC you want to add to the bond (e.g.,eth1andeth2), create theirifcfg-*files:vi /etc/sysconfig/network-scripts/ifcfg-eth1Add this content:
DEVICE=eth1 TYPE=Ethernet ONBOOT=yes BOOTPROTO=none MASTER=bond0 SLAVE=yesRepeat this for your second slave NIC (e.g.,
ifcfg-eth2).Load the bonding module:
Load it immediately with:modprobe bondingTo make it persist across reboots, add a line to
/etc/modules-load.d/bonding.conf(create the file if it doesn't exist):bondingRestart the network service:
service network restart
You can verify the bond is working with cat /proc/net/bonding/bond0, which will show the status of the slave interfaces and bonding mode.
内容的提问来源于stack exchange,提问作者pasha ahmed

