Linux brctl (BRIDGE)

Source: Internet
Author: User

There are five hosts. One of the hosts is installed with Linux and the bridge module is installed. There are four physical NICs that connect other hosts in the same network segment. We want it to become a bridge and forward data packets between the other four hosts (IP addresses are 192.168.1.2, 192.168.1.3, 192.168.1.4, and 192.168.1.5 respectively. In addition, to facilitate management, the administrator wants the bridge to have an IP address (192.168.1.1) so that the administrator can telnet to the bridge on the host in the 192.168.1.0/24 network segment and configure it, remote Management.

As mentioned in the previous section, the bridge forwards data packets in the same logical network segment. For the above topology, the logical network segment is 192.168.1.0/24. We have a name for this logical CIDR Block, br0. First, you must configure such a logical CIDR block.

# Brctl addbr br0 (create a logical network segment named br0)

In fact, we can regard the logical network segment 192.168.1.0/24 as a VLAN, while br0 is the name of this VLAN.

After creating a logical CIDR block, we need to allocate specific ports to the CIDR block. In Linux, a port is actually a physical Nic. The names of each physical network adapter are eth0, eth1, eth2, and eth3. We need to associate each NIC with the network segment br0 one by one as a port in br0.

# Brctl addif br0 eth0 (make eth0 a port of br0)
# Brctl addif br0 eth1 (make eth1 a port of br0)
# Brctl addif br0 eth2 (making eth2 a port of br0)
# Brctl addif br0 eth3 (making eth3 a port of br0)

Each physical network card of the bridge acts as a port and runs in the hybrid mode and works at the link layer, so no IP address is needed.

# ifconfig eth0 0.0.0.0 
# ifconfig eth1 0.0.0.0 
# ifconfig eth2 0.0.0.0 
# ifconfig eth3 0.0.0.0

Configure IP Address: 192.168.1.1 for the virtual network card of br0. In this way, the bridge can be remotely managed.

# ifconfig br0 192.168.1.1

After the IP address is configured for br0, the bridge will be able to work. Hosts in the 192.168.1.0/24 CIDR block can all be configured by Telnet to the bridge.

The above configuration is a logical network segment. In fact, the Linux bridge can also be configured into multiple logical network segments (equivalent to dividing multiple VLANs in a switch ).

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.