Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to configure two network cards to bridge under CentOS

Shulou Source: shulou.com Published: 2022-06-01 17:45:32 09月29日 Update

This article mainly introduces how to configure two network cards bridging under CentOS, which is very detailed and has certain reference value. Friends who are interested must read it!

What is a bridge?

The bridge is at the data link layer, which connects two LAN and forwards frames according to the MAC address, which can be regarded as a low-level router.

Classification of bridges

1. The hardware bridge is a physical ymgl, so you can purchase equipment from cisco or Huawei.

2. The software bridge is controlled by the operating system, and the main control is completed by the operating system. At present, the two major operating systems, linux unix, can complete the bridge function perfectly.

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 interface for the bridge

[root@example ~] # brctl addbr macbr0

3. Add ethX devices to the bridge

[root@example ~] # brctl addif macbr0 eth2

[root@example ~] # brctl addif macbr0 eth3

4. Put the ethX device in hybrid mode

[root@example ~] # ifconfig eth2 0.0.0.0

[root@example ~] # ifconfig eth3 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.0b) TX bytes:0 (0.0b)

5. Set the IP of the bridge macbr0

[root@example ~] # ifconfig macbr0 172.16.1.1 Compact 24

Create a permanent bridge configuration

1. Establish 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-eth2

DEVICE=eth2

TYPE=Ethernet

ONBOOT=yes

BOOTPROTO=static

IPADDR=0.0.0.0

BRIDGE=macbr0

[root@example ~] # vi / etc/sysconfig/network-scripts/ifcfg-eth3

DEVICE=eth3

TYPE=Ethernet

ONBOOT=yes

BOOTPROTO=static

IPADDR=0.0.0.0

BRIDGE=macbr0

The above is all the contents of the article "how to configure two network cards to bridge under CentOS". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Tags: Bridge configuration system two network card operating system device content is composed of article control value interest function address partner tool interface control Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Apple Shulou Tech Info Xiaomi vpn