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

  1. 禁用网络管理器
    1. 1 # chkconfig NetworkManager off  
      2 # service  NetworkManager stop  
  2. 创建用以桥接的虚拟网卡
    1. 1 # cd /etc/sysconfig/network-scripts   
      2 # cp ifcfg-eth0 ifcfg-br0  

      注:修改之前做好备份,有问题还可以还原.

  3. 编辑 ifcfg-br0
    1. 1 # 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
    1. 1 # 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. 重新启动网络
    1. 1 # service network restart 
  6. 可能提示以下错误:
    1. 1 Bringing up interface eth0:  Device eth0 does not seem to be present,delaying initialization.                    [FAILED]

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

    2. # 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


      正常了。

posted @ 2016-08-17 14:59  Heartbeat丶  阅读(160)  评论(0)    收藏  举报