知识屋:更实用的电脑技术知识网站
所在位置:首页 > 操作系统 > linux

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

发布时间:2014-09-05 13:26:42作者:知识屋

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=staticIPADDR=192.168.1.17PREFIX=24GATEWAY=192.168.1.1DNS1=202.106.46.151
DNS2=202.106.0.20DELAY=0 
注意:最好切换到root帐户操作,否则保存时可能会提示:E45: 'readonly' option is set (add ! to override)

4、编辑ifcfg-eth0

# vi ifcfg-eth0 DEVICE="eth0"NM_CONTROLLED="yes"ONBOOT=yesTYPE=EthernetBRIDGE="br0"BOOTPROTO=noneIPADDR=192.168.1.17PREFIX=24GATEWAY=192.168.1.1DEFROUTE=yesIPV4_FAILURE_FATAL=yesIPV6INIT=noNAME="System eth0"UUID=5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03DNS1=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:97", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"# PCI device 0x1022:0x2000 (pcnet32)SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:50:bd:17", 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

正常了。

(免责声明:文章内容如涉及作品内容、版权和其它问题,请及时与我们联系,我们将在第一时间删除内容,文章内容仅供参考)
收藏
  • 人气文章
  • 最新文章
  • 下载排行榜
  • 热门排行榜