vmware 可以添加两个网卡
一个网卡连接外网:使用NAT
一个网卡用于内网连接,使用主机模式
如何添加两个网卡
1.
2.
3.
虚拟机内部设置
假定条件:你内部网卡配置是正确的
进入网卡设置文件夹
执行ifconfig -a 可以看到你的网卡
你会看到有除了lo还有eth0和eth1两个ip
/etc/sysconfig/network-scriptscp ifcfg-eth0 ifcfg-eth1 //ifcfg-eth1可以设置为自己喜欢的形式,可以是eth2或者eth3,我这里改为eth2这个主要是为了配置静态IP使用
修改你增加的配置:
[root@localhost network-scripts]# vim ifcfg-eth2DEVICE=eth2#DEFROUTE=yes#PEERROUTES=yes#IPV4_FAILURE_FATAL=no#HWADDR=00:0C:29:84:35:09HWADDR=00:0C:29:7C:00:34//HWADDR是你刚才设置的MAC#TYPE=Ethernet#UUID=fc55680e-fd46-4575-a21b-03928b6b5f9fONBOOT=on#NM_CONTROLLED=yesBOOTPROTO=static//IP是静态,你可以设置一个IPIPADDR=192.168.21.135NETMASK=255.255.255.0NAME=eth2
重新加载重启
service network restart
或者/etc/init.d/network restart
Shutting down interface eth0: Device state: 3 (disconnected)[ OK ]Shutting down interface eth3: Device state: 3 (disconnected)[ OK ]Shutting down loopback interface:[ OK ]Bringing up loopback interface: [ OK ]Bringing up interface eth0: Active connection state: activatingActive connection path: /org/freedesktop/NetworkManager/ActiveConnection/20state: activatedConnection activated[ OK ]Bringing up interface eth3: Active connection state: activatedActive connection path: /org/freedesktop/NetworkManager/ActiveConnection/21[ OK ][root@localhost network-scripts]# /etc/init.d/network restartShutting down interface eth0: Device state: 3 (disconnected)[ OK ]Shutting down interface eth3: Device state: 3 (disconnected)[ OK ]Shutting down loopback interface:[ OK ]Bringing up loopback interface: [ OK ]Bringing up interface eth0: Active connection state: activatingActive connection path: /org/freedesktop/NetworkManager/ActiveConnection/22state: activatedConnection activated[ OK ]Bringing up interface eth3: Active connection state: activatedActive connection path: /org/freedesktop/NetworkManager/ActiveConnection/23[ OK ]
常见错误
Bringing up interface eth0: Error: No suitable device found: no device found f[FAILED]Bringing up interface eth1: Error: Connection activation failed: The connectio[FAILED]Bringing up interface eth2: Error: No suitable device found: no device found f[FAILED]
问题解决方法
找到网络配置规则
vim /etc/udev/rules.d/70-persistent-70-persistent-cd.rules
# PCI device 0x8086:0x100f (e1000)SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:7c:00:34", ATTR{type}=="1", KERNEL=="eth*", NAME="eth3"# PCI device 0x8086:0x100f (e1000)SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:7c:00:2a", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
确保你配置中的MAC地址和名字与ATTR{address}和NAME="eth0"一一对应就可以了。
如果觉得《vmware虚拟机实现双网卡固定ip》对你有帮助,请点赞、收藏,并留下你的观点哦!