OVS端口流量统计实操

验证OVS端口流量统计

拓扑结构如下图

拓扑.png

实操

1 创建namespace

root@root12-virtual-machine:~# ip netns add ns1
root@root12-virtual-machine:~# ip netns add ns2

2 创建两组veth

root@root12-virtual-machine:~# ip link add type veth
root@root12-virtual-machine:~# ip link add type veth

默认会创建下面两对点到点的veth

veth0---veth1

veth2---veth3

3 配置veth1/veth3并加入到namespace中

把veth1/veth3划到ns1/ns2中,并配置ip

root@root12-virtual-machine:~# ip link set veth1 netns ns1
root@root12-virtual-machine:~# ip link set veth3 netns ns2
root@root12-virtual-machine:~# ip netns exec ns1 ip addr add 192.168.1.1/24 dev veth1
root@root12-virtual-machine:~# ip netns exec ns2 ip addr add 192.168.1.2/24 dev veth3
root@root12-virtual-machine:~# ip netns exec ns1 ip link set dev veth1 up
root@root12-virtual-machine:~# ip netns exec ns2 ip link set dev veth3 up

4 查看配置信息

root@root12-virtual-machine:~# ip netns exec ns1 ip addr show veth1
7: veth1@if6: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state LOWERLAYERDOWN group default qlen 1000
    link/ether ca:92:89:98:55:00 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 192.168.1.1/24 scope global veth1
       valid_lft forever preferred_lft forever
root@root12-virtual-machine:~# ip netns exec ns2 ip addr show veth3
9: veth3@if8: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state LOWERLAYERDOWN group default qlen 1000
    link/ether ae:48:13:80:bc:db brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 192.168.1.2/24 scope global veth3
       valid_lft forever preferred_lft forever

5 测试

5.1 测试namespace的功能

在ns1中ping ns2 veth3 ip

root@root12-virtual-machine:~# ip netns exec ns1 ping -c1 192.168.1.2
PING 192.168.1.2 (192.168.1.2) 56(84) bytes of data.

--- 192.168.1.2 ping statistics ---
1 packets transmitted, 0 received, 100% packet loss, time 0ms

在把veth1/veth3的点对点设备veth0/veth2划到br-int中,并up端口

root@root12-virtual-machine:~# ovs-vsctl add-port br-int veth0
root@root12-virtual-machine:~# ovs-vsctl add-port br-int veth2
root@root12-virtual-machine:~# ip link set dev veth0 up
root@root12-virtual-machine:~# ip link set dev veth2 up
root@root12-virtual-machine:~# ovs-vsctl show
67462dab-f5c5-4396-928b-f04fce9223d2
    Bridge br-int
        Port "veth2"
            Interface "veth2"
        Port "veth0"
            Interface "veth0"
        Port br-int
            Interface br-int
                type: internal
    ovs_version: "2.9.8"
root@root12-virtual-machine:~#

从ns1上ping ns2

root@root12-virtual-machine:~# ip netns exec ns1 ping -c1 192.168.1.2
PING 192.168.1.2 (192.168.1.2) 56(84) bytes of data.
64 bytes from 192.168.1.2: icmp_seq=1 ttl=64 time=0.257 ms

--- 192.168.1.2 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.257/0.257/0.257/0.000 ms

ovs,namespace,veth的功能符合预期

5.2 验证端口流量

root@root12-virtual-machine:~# ovs-vsctl list interface
_uuid               : b63d4d94-ae76-464f-86a2-6d4eca897e10
admin_state         : up
bfd                 : {}
bfd_status          : {}
cfm_fault           : []
cfm_fault_status    : []
cfm_flap_count      : []
cfm_health          : []
cfm_mpid            : []
cfm_remote_mpids    : []
cfm_remote_opstate  : []
duplex              : full
error               : []
external_ids        : {}
ifindex             : 8
ingress_policing_burst: 0
ingress_policing_rate: 0
lacp_current        : []
link_resets         : 1
link_speed          : 10000000000
link_state          : up
lldp                : {}
mac                 : []
mac_in_use          : "3a:03:c0:11:ec:81"
mtu                 : 1500
mtu_request         : []
name                : "veth2"
ofport              : 2
ofport_request      : []
options             : {}
other_config        : {}
statistics          : {collisions=0, rx_bytes=1650, rx_crc_err=0, rx_dropped=0, rx_errors=0, rx_frame_err=0, rx_over_err=0, rx_packets=23, tx_bytes=5038, tx_dropped=0, tx_errors=0, tx_packets=51}
status              : {driver_name=veth, driver_version="1.0", firmware_version=""}
type                : ""

_uuid               : 2c757810-d5e9-4e26-938e-b3b2aa7e225c
admin_state         : up
bfd                 : {}
bfd_status          : {}
cfm_fault           : []
cfm_fault_status    : []
cfm_flap_count      : []
cfm_health          : []
cfm_mpid            : []
cfm_remote_mpids    : []
cfm_remote_opstate  : []
duplex              : full
error               : []
external_ids        : {}
ifindex             : 6
ingress_policing_burst: 0
ingress_policing_rate: 0
lacp_current        : []
link_resets         : 1
link_speed          : 10000000000
link_state          : up
lldp                : {}
mac                 : []
mac_in_use          : "36:58:3a:84:31:52"
mtu                 : 1500
mtu_request         : []
name                : "veth0"
ofport              : 1
ofport_request      : []
options             : {}
other_config        : {}
statistics          : {collisions=0, rx_bytes=1650, rx_crc_err=0, rx_dropped=0, rx_errors=0, rx_frame_err=0, rx_over_err=0, rx_packets=23, tx_bytes=5624, tx_dropped=0, tx_errors=0, tx_packets=58}
status              : {driver_name=veth, driver_version="1.0", firmware_version=""}
type                : ""

通过控制器rest接口查询结果如下:

veth0.jpg
veth2.jpg
本站文章资源均来源自网络,除非特别声明,否则均不代表站方观点,并仅供查阅,不作为任何参考依据!
如有侵权请及时跟我们联系,本站将及时删除!
如遇版权问题,请查看 本站版权声明
THE END
分享
二维码
海报
OVS端口流量统计实操
在把veth1/veth3的点对点设备veth0/veth2划到br-int中,并up端口
<<上一篇
下一篇>>