virtualbox ,centos 的多网卡如何设置

假设
eth0是NAT,另外一块(eth4)是Host-Only.

#首先确认网卡MAC
[root@localhost ~]# ifconfig -a | grep HW
eth0      Link encap:Ethernet  HWaddr 08:00:27:B2:9F:F5
eth4      Link encap:Ethernet  HWaddr 08:00:27:BB:84:F9

[root@localhost ~]# vi /etc/udev/rules.d/70-persistent-net.rules
# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:B2:9F:F5", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:BB:84:F9", ATTR{type}=="1", KERNEL=="eth*", NAME="eth4"

[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
BOOTPROTO="dhcp"
HWADDR="08:00:27:B2:9F:F5"
IPV6INIT="yes"
NM_CONTROLLED="yes"
ONBOOT="yes"
TYPE="Ethernet"
UUID="56f45b3e-1d42-4cf8-a78e-4a041835f3a1"

[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth4
DEVICE="eth4"
BOOTPROTO=static
IPADDR=192.168.56.102
GATEWAY=192.168.56.1(如果双网卡,前一个是NAT方式,此处不能设置网关,否则会导致NAT无法访问外网)
NETMASK=255.255.255.0
HWADDR="08:00:27:BB:84:F9"
NM_CONTROLLED="yes"
ONBOOT="yes"
TYPE="Ethernet"
UUID="56f45b3e-1d42-4cf8-a78e-4a041835f3a1"

posted on 2018-06-25 21:28  wudymand  阅读(209)  评论(0编辑  收藏  举报

导航