Configure two NICs for bridging in CentOS
What is a bridge?
A bridge connects two LANs at the data link layer and forwards Frames Based on the MAC address. It can be seen as a low-layer router.
Bridge Classification
1. The hardware Bridge is a physical ymgl. You can purchase cisco or Huawei devices.
2. The Software Component Bridge is controlled by the operating system, and the main control is completed by the operating system. Currently, the two major operating systems that can perfectly complete the bridge function, linuxunix
1. Check whether the bridge configuration tool is installed in the system.
[Root @ example ~] # Rpm-qa | grep bridge
Bridge-utils-1.2-10.el6.x86_64
2. Create a logical bridge Interface
[Root @ example ~] # Brctl addbr macbr0
3. Add the ethX device to the bridge.
[Root @ example ~] # Brctl addif macbr0 eth1
[Root @ example ~] # Brctl addif macbr0 eth2
4. Set the ethX device to the hybrid mode.
[Root @ example ~] # Ifconfig eth1 0.0.0.0
[Root @ example ~] # Ifconfig eth2 0.0.0.0
[Root @ example ~] # Ifconfig macbr0
Macbr0 Link encap: Ethernet HWaddr 00: 0C: 29: EB: 59: A4
Broadcast multicast mtu: 1500 Metric: 1
RX packets: 0 errors: 0 dropped: 0 overruns: 0 frame: 0
TX packets: 0 errors: 0 dropped: 0 overruns: 0 carrier: 0
Collisions: 0 txqueuelen: 0
RX bytes: 0 (0.0 B) TX bytes: 0 (0.0 B)
5. Set the IP address of the bridge macbr0.
[Root @ example ~] # Ifconfig macbr0 172.16.1.1/24
Create permanent bridge configuration
1. Create a bridge configuration file
[Root @ example ~] # Vi/etc/sysconfig/network-scripts/ifcfg-macbr0
DEVICE = macbr0
TYPE = Bridge
BOOTPROTO = static
IPADDR = 172.16.100.1
NETMASK = 255.255.255.0
ONBOOT = yes
2. Add the NIC to the bridge
[Root @ example ~] # Vi/etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE = eth1
TYPE = Ethernet
ONBOOT = yes
BOOTPROTO = static
IPADDR = 0.0.0.0
BRIDGE = macbr0
[Root @ example ~] # Vi/etc/sysconfig/network-scripts/ifcfg-eth2
DEVICE = eth2
TYPE = Ethernet
ONBOOT = yes
BOOTPROTO = static
IPADDR = 0.0.0.0
BRIDGE = macbr0