brctl 的使用

brctl  作用: 用来进行以太网桥接(bridge)的管理

主要用法如下:

root@hbg:/# brctl --help
BusyBox v1.22.1 (2016-02-24 11:41:04 CST) multi-call binary.

Usage: brctl COMMAND [BRIDGE [INTERFACE]]

Manage ethernet bridges

Commands:
        show                    Show a list of bridges                     // 显示桥接信息
        addbr BRIDGE            Create BRIDGE                         // 增加桥接端口
        delbr BRIDGE            Delete BRIDGE                           // 删除桥接端口
        addif BRIDGE IFACE      Add IFACE to BRIDGE           // 为桥接端口增加绑定接口
        delif BRIDGE IFACE      Delete IFACE from BRIDGE    // 删除桥接端口的绑定接口
        setageing BRIDGE TIME           Set ageing time
        setfd BRIDGE TIME               Set bridge forward delay
        sethello BRIDGE TIME            Set hello time
        setmaxage BRIDGE TIME           Set max message age
        setpathcost BRIDGE COST         Set path cost
        setportprio BRIDGE PRIO         Set port priority
        setbridgeprio BRIDGE PRIO       Set bridge priority
        stp BRIDGE [1/yes/on|0/no/off]  STP on/off          // 是否参与生成树协议

 

用法如下:

 

root@hbg:/# brctl show
bridge name     bridge id               STP enabled     interfaces
br-net          7fff.78c2c0e3004d       yes             eth0
                                                                       wlan0

可以看到,目前的桥接接口名称为br-net, 它绑定了两个端口  eth0 和 wlan0.

 

root@hbg:/# brctl addif br-net eth1
[ 1133.440000] device eth1 entered promiscuous mode
root@hbg:/# brctl show
bridge name     bridge id               STP enabled     interfaces
br-net          7fff.78c2c0e3004d       yes                eth0
                                                                          wlan0
                                                                          eth1

为桥接接口br-net增加绑定接口 eth1, 增加完后查看到已经绑定成功。

 

 

 

root@hbg:/# brctl delif br-net eth1
[ 1248.150000] device eth1 left promiscuous mode
[ 1248.160000] br-net: port 3(eth1) entered disabled state
root@hbg:/# brctl show
bridge name     bridge id               STP enabled     interfaces
br-net          7fff.78c2c0e3004d       yes             eth0
                                                                      wlan0

删除桥接接口 br-net 绑定的端口eth1,删除完成后查看已经删除成功。

 

 

root@hbg:/# brctl addbr br-lan                                           // 增加了桥接接口"br-lan"
root@hbg:/# brctl show
bridge name     bridge id               STP enabled     interfaces
br-net          7fff.78c2c0e3004d       yes             eth0
                                                                      wlan0
br-lan          8000.000000000000       no                                // 新增的桥接接口默认为“未使能”的
root@hbg:/# brctl addif br-lan eth1                                        // 为桥接接口br-lan 绑定端口eth1
[ 1375.780000] device eth1 entered promiscuous mode
root@hbg:/# brctl show
bridge name     bridge id               STP enabled     interfaces
br-net          7fff.78c2c0e3004d       yes             eth0
                                                        wlan0
br-lan          8000.78c2c0e3004e       no              eth1
root@hbg:/# brctl stp br-lan 1                                            // 参与生成树协议
root@hbg:/# brctl show
bridge name     bridge id               STP enabled     interfaces
br-net          7fff.78c2c0e3004d        yes             eth0
                                                                        wlan0
br-lan          8000.78c2c0e3004e       yes             eth1           // 参与生成树协议,接收和发送BPDU(Bridge Protocol Data Units)

 

 

 

root@TVWS:/# brctl delbr br-lan
[ 1635.570000] device eth1 left promiscuous mode
[ 1635.570000] br-lan: port 1(eth1) entered disabled state
root@TVWS:/#
root@TVWS:/# brctl show
bridge name     bridge id               STP enabled     interfaces
br-net          7fff.78c2c0e3004d       yes             eth0
                                                                      wlan0

 直接删除桥接接口“br-lan”,查看结果删除成功。

 

转载于:https://www.cnblogs.com/rohens-hbg/p/5411574.html

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值