Openstack 环境下网桥的常用命令总结

1、查看openstack宿主机网桥的状态

[root@os-node4 ~]#  brctl show

bridge name     bridge id               STP enabled     interfaces

qbr170f5a83-ea          8000.b6d0d18a10b9       no              qvb170f5a83-ea    

qbr213d7e09-89          8000.56637908c1ef       no              qvb213d7e09-89

                                                        tap213d7e09-89

qbr27c7d0d9-15          8000.f20e94b9e22d       no              qvb27c7d0d9-15

                                                        tap27c7d0d9-15

qbr2e95affe-96          8000.c692a3b93cc6       no              qvb2e95affe-96

                                                        tap2e95affe-96

qbr47b323f3-25          8000.e6d487daac36       no              qvb47b323f3-25

                                                        tap47b323f3-25

qbr4d1cac0b-c9          8000.1e38a6c923d8       no              qvb4d1cac0b-c9

                                                        tap4d1cac0b-c9

qbr6c73b202-47          8000.e2aa77f6d3e2       no              qvb6c73b202-47

                                                        tap6c73b202-47

qbrdc88d6d9-cf          8000.9e3fcf9c182f       no              qvbdc88d6d9-cf

                                                        tapdc88d6d9-cf

qbre0a1fbb6-3e          8000.aef4ce53299b       no              qvbe0a1fbb6-3e

                                                        tape0a1fbb6-3e

qbrefdb04bf-fe          8000.ba0421fce999       no              qvbefdb04bf-fe

                                                        tapefdb04bf-fe

virbr0          8000.5254000756a2       yes             virbr0-nic


2、查看第二个网桥的生成树状态

[root@os-node4 ~]# brctl showstp qbr213d7e09-89

qbr213d7e09-89

 bridge id              8000.56637908c1ef

 designated root        8000.56637908c1ef

 root port                 0                    path cost                  0

 max age                  19.99                 bridge max age            19.99

 hello time                1.99                 bridge hello time          1.99

 forward delay             0.00                 bridge forward delay       0.00

 ageing time             299.95

 hello timer               1.74                 tcn timer                  0.00

 topology change timer     0.00                 gc timer                   0.74

 hash elasticity           4                    hash max                 512

 mc last member count      2                    mc init query count        2

 mc router                 1                    mc snooping                1

 mc last member timer      0.99                 mc membership timer      259.96

 mc querier timer        254.96                 mc query interval        124.98

 mc response interval      9.99                 mc init query interval    31.24

 flags



qvb213d7e09-89 (0)

 port id                0000                    state                forwarding

 designated root        8000.56637908c1ef       path cost                  2

 designated bridge      8000.56637908c1ef       message age timer          0.00

 designated port        8001                    forward delay timer        0.00

 designated cost           0                    hold timer                 0.73

 mc router                 1

 flags


tap213d7e09-89 (0)

 port id                0000                    state                forwarding

 designated root        8000.56637908c1ef       path cost                100

 designated bridge      8000.56637908c1ef       message age timer          0.00

 designated port        8002                    forward delay timer        0.00

 designated cost           0                    hold timer                 0.73

 mc router                 1

 flags



3、删除上面网桥中的第一个网桥的接口

[root@os-node4 ~]# brctl delif qbr170f5a83-ea  qvb170f5a83-ea 


4、开启上面网桥列表中第一个网桥的STP功能

[root@os-node4 ~]# brctl  stp qbr170f5a83-ea on


[root@os-node4 ~]# brctl show

bridge name     bridge id               STP enabled     interfaces

qbr170f5a83-ea          8000.000000000000       yes

qbr213d7e09-89          8000.56637908c1ef       no              qvb213d7e09-89

                                                        tap213d7e09-89

qbr27c7d0d9-15          8000.f20e94b9e22d       no              qvb27c7d0d9-15

                                                        tap27c7d0d9-15

qbr2e95affe-96          8000.c692a3b93cc6       no              qvb2e95affe-96

                                                        tap2e95affe-96

qbr47b323f3-25          8000.e6d487daac36       no              qvb47b323f3-25

                                                        tap47b323f3-25

qbr4d1cac0b-c9          8000.1e38a6c923d8       no              qvb4d1cac0b-c9

                                                        tap4d1cac0b-c9

qbr6c73b202-47          8000.e2aa77f6d3e2       no              qvb6c73b202-47

                                                        tap6c73b202-47

qbrdc88d6d9-cf          8000.9e3fcf9c182f       no              qvbdc88d6d9-cf

                                                        tapdc88d6d9-cf

qbre0a1fbb6-3e          8000.aef4ce53299b       no              qvbe0a1fbb6-3e

                                                        tape0a1fbb6-3e

qbrefdb04bf-fe          8000.ba0421fce999       no              qvbefdb04bf-fe

                                                        tapefdb04bf-fe

virbr0          8000.5254000756a2       yes             virbr0-nic


5、给第一个网桥添加接口

[root@os-node4 ~]#  brctl addif qbr170f5a83-ea  qvb170f5a83-ea 

[root@os-node4 ~]#  brctl show

bridge name     bridge id               STP enabled     interfaces

qbr170f5a83-ea          8000.b6d0d18a10b9       yes             qvb170f5a83-ea

qbr213d7e09-89          8000.56637908c1ef       no              qvb213d7e09-89

                                                        tap213d7e09-89

qbr27c7d0d9-15          8000.f20e94b9e22d       no              qvb27c7d0d9-15

                                                        tap27c7d0d9-15

qbr2e95affe-96          8000.c692a3b93cc6       no              qvb2e95affe-96

                                                        tap2e95affe-96

qbr47b323f3-25          8000.e6d487daac36       no              qvb47b323f3-25

                                                        tap47b323f3-25

qbr4d1cac0b-c9          8000.1e38a6c923d8       no              qvb4d1cac0b-c9

                                                        tap4d1cac0b-c9

qbr6c73b202-47          8000.e2aa77f6d3e2       no              qvb6c73b202-47

                                                        tap6c73b202-47

qbrdc88d6d9-cf          8000.9e3fcf9c182f       no              qvbdc88d6d9-cf

                                                        tapdc88d6d9-cf

qbre0a1fbb6-3e          8000.aef4ce53299b       no              qvbe0a1fbb6-3e

                                                        tape0a1fbb6-3e

qbrefdb04bf-fe          8000.ba0421fce999       no              qvbefdb04bf-fe

                                                        tapefdb04bf-fe

virbr0          8000.5254000756a2       yes             virbr0-nic


6、查看一个宿主机的所有的网桥

[root@os-node3 ~]# ovs-vsctl show

8b89e998-f71e-4780-8b03-fb8e81d52721

    Bridge br-int

        Port "em2"

            Interface "em2"

        Port "qvoc34f62b9-fc"

            tag: 2

            Interface "qvoc34f62b9-fc"

        Port "qvod5ef101b-86"

            tag: 3

            Interface "qvod5ef101b-86"

        Port "qvo1e01d0e9-78"

            tag: 4

            Interface "qvo1e01d0e9-78"

        Port "qvo02b77c7e-22"

            tag: 1

            Interface "qvo02b77c7e-22"

        Port "qvo2902811d-43"

            tag: 2

            Interface "qvo2902811d-43"

        Port phy-br-int

            Interface phy-br-int

        Port "qvo6cb14821-3d"

            tag: 4

            Interface "qvo6cb14821-3d"

        Port "qvo97475d0b-46"

            tag: 2

            Interface "qvo97475d0b-46"

        Port br-int

            Interface br-int

                type: internal

        Port "qvoe32c7470-fc"

            tag: 3

            Interface "qvoe32c7470-fc"

        Port "qvofe0221b9-6f"

            tag: 2

            Interface "qvofe0221b9-6f"

        Port int-br-int

            Interface int-br-int

    ovs_version: "1.11.0"

[root@os-node3 ~]# 

7、查看网桥的详细信息

[root@os-node3 ~]# ovs-vsctl list bridge

_uuid               : b7dfb641-b883-4c20-9af4-8477e2495ae9

controller          : []

datapath_id         : "000074867ad90521"

datapath_type       : ""

external_ids        : {}

fail_mode           : []

flood_vlans         : []

flow_tables         : {}

ipfix               : []

mirrors             : []

name                : br-int

netflow             : []

other_config        : {}

ports               : [1216f3ae-e21f-42f0-aded-6bb56c4744e0, a3a1ebf3-18ca-42ae-bb33-e505677ab33a, c15d232a-43ab-4795-99d0-24221d0de464, cb34e1e3-7751-47ae-91c5-b67c47f7b8ac, d7bc53e9-19c7-484f-b2bf-bc13f000e4b6, d8cd3968-b2d4-4434-a212-87497312d5db, fd91910f-3bac-4af0-b6f7-fe8299bdd7c9]

protocols           : []

sflow               : []

status              : {}

stp_enable          : false


8、获取bridge 的_uuid字段值 

[root@os-node3 ~]# ovs-vsctl get bridge  br-int _uuid 

b7dfb641-b883-4c20-9af4-8477e2495ae9

9、查看虚拟桥交换机的状态

[root@os-node3 ~]# ovs-ofctl show br-int

OFPT_FEATURES_REPLY (xid=0x2): dpid:000074867ad90521

n_tables:254, n_buffers:256

capabilities: FLOW_STATS TABLE_STATS PORT_STATS QUEUE_STATS ARP_MATCH_IP

actions: OUTPUT SET_VLAN_VID SET_VLAN_PCP STRIP_VLAN SET_DL_SRC SET_DL_DST SET_NW_SRC SET_NW_DST SET_NW_TOS SET_TP_SRC SET_TP_DST ENQUEUE

 1(em2): addr:74:86:7a:d9:05:21

     config:     0

     state:      0

     current:    1GB-FD COPPER AUTO_NEG

     advertised: 10MB-HD 10MB-FD 100MB-HD 100MB-FD 1GB-HD 1GB-FD COPPER AUTO_NEG AUTO_PAUSE

     supported:  10MB-HD 10MB-FD 100MB-HD 100MB-FD 1GB-HD 1GB-FD COPPER AUTO_NEG

     speed: 1000 Mbps now, 1000 Mbps max

 2(int-br-int): addr:f6:3e:af:5d:57:f3

     config:     0

     state:      0

     current:    10GB-FD COPPER

     speed: 10000 Mbps now, 0 Mbps max

 3(phy-br-int): addr:32:91:30:54:e0:be

     config:     0

     state:      0

     current:    10GB-FD COPPER

     speed: 10000 Mbps now, 0 Mbps max

 4(qvo02b77c7e-22): addr:1e:6b:4e:b8:df:ce

     config:     0

     state:      0

     current:    10GB-FD COPPER

     speed: 10000 Mbps now, 0 Mbps max

 5(qvo97475d0b-46): addr:5e:ec:e3:3c:2f:3d

     config:     0

     state:      0

     current:    10GB-FD COPPER

     speed: 10000 Mbps now, 0 Mbps max

 6(qvoe32c7470-fc): addr:ee:52:96:92:e2:76

     config:     0

     state:      0

     current:    10GB-FD COPPER

     speed: 10000 Mbps now, 0 Mbps max

 7(qvo1e01d0e9-78): addr:12:78:bb:d3:6e:30

     config:     0

     state:      0

     current:    10GB-FD COPPER

     speed: 10000 Mbps now, 0 Mbps max

 8(qvod5ef101b-86): addr:76:2d:ad:00:6b:89

     config:     0

     state:      0

     current:    10GB-FD COPPER

     speed: 10000 Mbps now, 0 Mbps max

 9(qvo6cb14821-3d): addr:2a:6e:03:80:f0:32

     config:     0

     state:      0

     current:    10GB-FD COPPER

     speed: 10000 Mbps now, 0 Mbps max

 LOCAL(br-int): addr:74:86:7a:d9:05:21

     config:     0

     state:      0

     speed: 0 Mbps now, 0 Mbps max

OFPT_GET_CONFIG_REPLY (xid=0x4): frags=normal miss_send_len=0

[root@os-node3 ~]# 

10、查看宿主机网桥上每个端口的流量

[root@os-node3 ~]# ovs-ofctl dump-ports br-int

OFPST_PORT reply (xid=0x2): 10 ports

  port  9: rx pkts=77678, bytes=6036958, drop=0, errs=0, frame=0, over=0, crc=0

           tx pkts=646326, bytes=97148978, drop=0, errs=0, coll=0

  port  3: rx pkts=1239146, bytes=132329406, drop=0, errs=0, frame=0, over=0, crc=0

           tx pkts=2011443, bytes=272043752, drop=0, errs=0, coll=0

  port  1: rx pkts=1232835, bytes=191927097, drop=0, errs=0, frame=0, over=0, crc=0

           tx pkts=1231895, bytes=131357187, drop=0, errs=0, coll=0

  port  8: rx pkts=87, bytes=7737, drop=0, errs=0, frame=0, over=0, crc=0

           tx pkts=85686, bytes=5269344, drop=0, errs=0, coll=0

  port  4: rx pkts=2815, bytes=537436, drop=0, errs=0, frame=0, over=0, crc=0

           tx pkts=55110, bytes=3839034, drop=0, errs=0, coll=0

  port  7: rx pkts=80158, bytes=6215297, drop=0, errs=0, frame=0, over=0, crc=0

           tx pkts=674577, bytes=99366404, drop=0, errs=0, coll=0

  port  5: rx pkts=10823, bytes=1104304, drop=0, errs=0, frame=0, over=0, crc=0

           tx pkts=68747, bytes=13200367, drop=0, errs=0, coll=0

  port  6: rx pkts=269669, bytes=33688679, drop=0, errs=0, frame=0, over=0, crc=0

           tx pkts=336718, bytes=34219531, drop=0, errs=0, coll=0

  port  2: rx pkts=2011451, bytes=271938300, drop=0, errs=0, frame=0, over=0, crc=0

           tx pkts=1239138, bytes=132333438, drop=0, errs=0, coll=0

  port LOCAL: rx pkts=8, bytes=648, drop=0, errs=0, frame=0, over=0, crc=0

           tx pkts=1588615, bytes=168513355, drop=0, errs=0, coll=0

[root@os-node3 ~]# 

12、查看网桥上所有端口的流规则

[root@os-node3 ~]# ovs-ofctl dump-flows br-int

NXST_FLOW reply (xid=0x4):

 cookie=0x0, duration=67434.457s, table=0, n_packets=10852, n_bytes=1122429, idle_age=24, hard_age=65534, priority=4,in_port=3,dl_vlan=2 actions=mod_vlan_vid:212,NORMAL

 cookie=0x0, duration=67434.271s, table=0, n_packets=68836, n_bytes=13223088, idle_age=3, hard_age=65534, priority=3,in_port=2,dl_vlan=212 actions=mod_vlan_vid:2,NORMAL

 cookie=0x0, duration=67374.473s, table=0, n_packets=270060, n_bytes=33757331, idle_age=0, hard_age=65534, priority=4,in_port=3,dl_vlan=3 actions=mod_vlan_vid:213,NORMAL

 cookie=0x0, duration=67300.219s, table=0, n_packets=754301, n_bytes=136290538, idle_age=0, hard_age=65534, priority=3,in_port=2,dl_vlan=211 actions=mod_vlan_vid:4,NORMAL

 cookie=0x0, duration=67374.319s, table=0, n_packets=337302, n_bytes=34288158, idle_age=0, hard_age=65534, priority=3,in_port=2,dl_vlan=213 actions=mod_vlan_vid:3,NORMAL

 cookie=0x0, duration=67300.37s, table=0, n_packets=158129, n_bytes=12331007, idle_age=0, hard_age=65534, priority=4,in_port=3,dl_vlan=4 actions=mod_vlan_vid:211,NORMAL

 cookie=0x0, duration=67570.342s, table=0, n_packets=55154, n_bytes=3851812, idle_age=1, hard_age=65534, priority=3,in_port=2,dl_vlan=210 actions=mod_vlan_vid:1,NORMAL

 cookie=0x0, duration=67570.519s, table=0, n_packets=2811, n_bytes=548748, idle_age=21, hard_age=65534, priority=4,in_port=3,dl_vlan=1 actions=mod_vlan_vid:210,NORMAL

 cookie=0x0, duration=67649.798s, table=0, n_packets=799292, n_bytes=84873459, idle_age=0, hard_age=65534, priority=2,in_port=3 actions=drop

 cookie=0x0, duration=67649.955s, table=0, n_packets=799340, n_bytes=84876647, idle_age=0, hard_age=65534, priority=2,in_port=2 actions=drop

 cookie=0x0, duration=67651.318s, table=0, n_packets=1676899, n_bytes=240043622, idle_age=0, hard_age=65534, priority=1 actions=NORMAL

13、设置网络接口em2的带宽为1000±100kbps

ovs-vsctl set interface em2 ingress_policing_rate=1000 

ovs-vsctl set interface em2 ingress_policing_burst=100 

注:  ingress_policing_rate:最大发送速率(单位均为kbps)  ingress_policing_burst:超过ingress_policing_rate的最大浮动值 

14、去除一个端口VLAN tag

去除从3号端口发来的所有VLAN数据包中的tag,然后转发

ovs-ofctl add-flow br0 idle_timeout=0,in_port=3,actions=strip_vlan,normal


15、给网桥添加一个端口

ovs-vsctl add-port br-int em2    把端口em2加入网桥br-int   


16、给一个网桥的端口添加vlan

ovs-vsctl add-port br-int eth1 tag=2   给br-int桥的 eth1端口添加一个vlan2   

你可能感兴趣的:(openstack,网桥,brctl,ovs-vsctl)