Home > Article > System Tutorial > How to set up the bridge configuration of two network cards on CentOS?
What is a network bridge
The bridge is at the data link layer, connecting two LANs and forwarding frames based on the MAC address. It can be regarded as a low-layer router.
Classification of network bridges
1. The hardware bridge is physical ymgl. You can purchase cisco or Huawei equipment
2. The software bridge is controlled by the operating system. The main control is completed by the operating system. Currently, there are two major operating systems that can perfectly complete the bridge function, linux unix
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 bridge logical 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 promiscuous 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 of bridge macbr0
[root@example ~]# ifconfig macbr0 172.16.1.1/24
Create a 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 network card 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
The above is the detailed content of How to set up the bridge configuration of two network cards on CentOS?. For more information, please follow other related articles on the PHP Chinese website!