vmware 可以添加兩個網卡
一個網卡連接外網:使用NAT
一個網卡用於內網連接,使用主機模式
如何添加兩個網卡
1.
2.
3.
虛擬機內部設置
假定條件:你內部網卡配置是正確的
進入網卡設置文件夾
執行ifconfig -a 可以看到你的網卡
你會看到有除了lo還有eth0和eth1兩個ip
/etc/sysconfig/network-scripts
cp ifcfg-eth0 ifcfg-eth1
//ifcfg-eth1可以設置爲自己喜歡的形式,可以是eth2或者eth3,我這裏改爲eth2
這個主要是爲了配置靜態IP使用
修改你增加的配置:
[root@localhost network-scripts]# vim ifcfg-eth2
DEVICE=eth2
#DEFROUTE=yes
#PEERROUTES=yes
#IPV4_FAILURE_FATAL=no
#HWADDR=00:0C:29:84:35:09
HWADDR=00:0C:29:7C:00:34
//HWADDR是你剛纔設置的MAC
#TYPE=Ethernet
#UUID=fc55680e-fd46-4575-a21b-03928b6b5f9f
ONBOOT=on
#NM_CONTROLLED=yes
BOOTPROTO=static
//IP是靜態,你可以設置一個IP
IPADDR=192.168.21.135
NETMASK=255.255.255.0
NAME=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: activating
Active connection path: /org/freedesktop/NetworkManager/ActiveConnection/20
state: activated
Connection activated
[ OK ]
Bringing up interface eth3: Active connection state: activated
Active connection path: /org/freedesktop/NetworkManager/ActiveConnection/21
[ OK ]
[root@localhost network-scripts]# /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: activating
Active connection path: /org/freedesktop/NetworkManager/ActiveConnection/22
state: activated
Connection activated
[ OK ]
Bringing up interface eth3: Active connection state: activated
Active 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"一一對應就可以了。