VMware下CentOS6.4网卡设置为桥接模式静态IP配置方法详解

1、禁用网络管理器

# chkconfig NetworkManager off
# service  NetworkManager stop

2、创建用以桥接的虚拟网卡

# cd /etc/sysconfig/network-scripts 

# cp ifcfg-eth0 ifcfg-br0

3、编辑 ifcfg-br0

# vi ifcfg-br0 

DEVICE="br0"
TYPE="Bridge"
ONBOOT="yes"
BOOTPROTO=static
IPADDR=192.168.1.17
PREFIX=24
GATEWAY=192.168.1.1
DNS1=202.106.46.151
DNS2=202.106.0.20

DELAY=0 

注意:最好切换到root帐户操作,否则保存时可能会提示:E45: 'readonly' option is set (add ! to override)

4、编辑ifcfg-eth0

# vi ifcfg-eth0 

DEVICE="eth0"
NM_CONTROLLED="yes"
ONBOOT=yes
TYPE=Ethernet
BRIDGE="br0"
BOOTPROTO=none
IPADDR=192.168.1.17
PREFIX=24
GATEWAY=192.168.1.1
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth0"
UUID=5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03
DNS1=202.106.46.151
DNS2=202.106.0.20
HWADDR=00:1E:67:07:EC:30 

IPADDR:和你的电脑同一网段的IP地址
GATEWAY:与你的电脑的默认网关相同

5、重新启动网络

# service network restart

6、可能提示以下错误

Bringing up interface eth0: Device eth0 does not seem to be present,delaying initialization. [FAILED]

加载中...

解决办法:

首先,打开/etc/udev/rules.d/70-persistent-net.rules内容如下面例子所示:

# vi /etc/udev/rules.d/70-persistent-net.rules
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.
# PCI device 0x1022:0x2000 (pcnet32)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:8f:89:9
7", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x1022:0x2000 (pcnet32)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:50:bd:1
7", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

记录下,eth1网卡的mac地址00:0c:29:50:bd:17
接下来,打开/etc/sysconfig/network-scripts/ifcfg-eth0

# vi /etc/sysconfig/network-scripts/ifcfg-eth0

将 DEVICE="eth0" 改成 DEVICE="eth1" ,
将 HWADDR="00:0c:29:8f:89:97" 改成上面的mac地址 HWADDR="00:0c:29:50:bd:17"

最后,重启网络

# service network restart
或者

# /etc/init.d/network restart

正常了。

猜你喜欢

转载自avd.iteye.com/blog/2261409