Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to configure two network cards to bridge under CentOS

2025-02-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report