在VirtualBox中为CentOS虚拟机设置多网卡可以通过以下几种方法实现:
ip addr
或 ifconfig
命令查看现有的网卡信息。/etc/sysconfig/network-scripts/ifcfg-ens33
文件(或其他网卡对应的配置文件),设置 BOOTPROTO
为 dhcp
,确保 ONBOOT
为 yes
。systemctl restart network
。ens34
),复制 /etc/sysconfig/network-scripts/ifcfg-ens33
文件,重命名为 ifcfg-ens34
。ifcfg-ens34
文件,设置 DEVICE
为 ens34
,BOOTPROTO
为 static
,IPADDR
为你设定的Host-Only网络IP地址,NETMASK
为子网掩码,GATEWAY
为宿主机的IP地址(不在Host-Only网络中),DNS1
和 DNS2
为DNS服务器地址。ONBOOT
为 yes
,保存文件。systemctl restart network
。sudo systemctl enable NetworkManager --now
sudo nmcli connection add type bond ifname bond0 mode 1
sudo nmcli connection add type bond-slave ifname ens33 master bond0
sudo nmcli connection add type bond-slave ifname ens38 master bond0
sudo systemctl restart network
cat /proc/net/bonding/bond0
或 sudo ip addr
ping
命令测试虚拟机的IP地址,确保宿主机可以访问虚拟机。ping
命令测试宿主机的IP地址,确保虚拟机可以访问宿主机。通过以上步骤,你可以在VirtualBox中成功配置CentOS虚拟机的多网卡环境。根据实际需求,你可能还需要进行其他网络相关的配置,如设置DNS服务器、调整网络优先级等。