测试环境: centos 6

 首先,安装软件包:bridge-utils (yum install bridge-utils)

  1. [root@centos network-scripts]# cat ifcfg-br0 
  2. DEVICE="br0" 
  3. BOOTPROTO="static" 
  4. NM_CONTROLLED="no" 
  5. ONBOOT="yes" 
  6. TYPE="Bridge" 
  7. IPADDR=192.168.6.219 
  8. NETMASK=255.255.255.0 
  9. GATEWAY=192.168.6.1 
  10. [root@centos network-scripts]# cat ifcfg-eth0 
  11. DEVICE="eth0" 
  12. BOOTPROTO="static" 
  13. NM_CONTROLLED="no" 
  14. ONBOOT="yes" 
  15. TYPE="Ethernet" 
  16. BRIDGE="br0" 
  17. [root@centos network-scripts]# cat ifcfg-eth1 
  18. DEVICE="eth1" 
  19. BOOTPROTO="static" 
  20. NM_CONTROLLED="no" 
  21. ONBOOT="yes" 
  22. TYPE="Ethernet" 
  23. BRIDGE="br0" 
  24. [root@centos network-scripts]# uname -a 
  25. Linux centos 2.6.32-279.19.1.el6.i686 #1 SMP Wed Dec 19 04:30:58 UTC 2012 i686 i686 i386 GNU/Linux 
  26. [root@centos network-scripts]# 


测试环境:Ubuntu 1204
首先安装bridge-utils (apt-get install bridge-uitls)

  1. auto br0 
  2. iface br0 inet static 
  3.         address 192.168.6.218 
  4.         netmask 255.255.255.0 
  5.         bridge_ports eth0 eth1 
  6.         bridge_stp on 
  7.         bridge_maxwait 0 
  8.         gateway 192.168.6.1 
  9.         dns-nameservers 202.106.0.20 

 

  1. root@ubuntu:/etc/network# brctl show br0 
  2. bridge name     bridge id               STP enabled     interfaces 
  3. br0             8000.000c29de7d91       yes             eth0 
  4.                                                         eth1