Configure two NICs for bridging in CentOS

Source: Internet
Author: User

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

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.