zoukankan      html  css  js  c++  java
  • 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”,查看结果删除成功。

  • 相关阅读:
    朴素贝叶斯方法(二分类)[机器学习实战]
    【HIHOCODER 1055】 刷油漆(树上背包)
    【HIHOCODER 1142】 三分·三分求极值
    【HIHOCODER 1420】 Bigint Multiplication
    【HIHOCODER 1403】后缀数组一·重复旋律(后缀数组)
    【HIHOCODER 1589】回文子串的数量(Manacher)
    【HIHOCODER 1599】逃离迷宫4
    【HIHOCODER 1182】欧拉路·三
    【HIHOCODER 1181】欧拉路·二
    【HIHOCODER 1176】 欧拉路·一
  • 原文地址:https://www.cnblogs.com/rohens-hbg/p/5411574.html
Copyright © 2011-2022 走看看