[root@kunpeng82 devuser]# ovs-tcpdump -i patch-ovs-2 Traceback (most recent call last): File "/bin/ovs-tcpdump", line 27, in <module> import netifaces ImportError: No module named netifaces [root@kunpeng82 devuser]# pip install netifaces bash: pip: command not found [root@kunpeng82 devuser]# pip3 install netifaces WARNING: Running pip install with root privileges is generally not a good idea. Try `pip3 install --user` instead. Collecting netifaces
yum -y install python3-netifaces
ovs-vsctl add-br br1 ovs-vsctl add-br br2 ovs-vsctl add-port br1 tap1 -- set Interface tap1 type=internal ovs-vsctl add-port br2 tap2 -- set Interface tap2 type=internal ip netns add ns1 ip netns add ns2 ip link set tap1 netns ns1 ip link set tap2 netns ns2 ip netns exec ns1 ip addr add 1.1.1.1/24 dev tap1 ip netns exec ns1 ip link set tap1 up ip netns exec ns1 ip link set lo up ip netns exec ns2 ip addr add 1.1.1.2/24 dev tap2 ip netns exec ns2 ip link set tap2 up ip netns exec ns2 ip link set lo up ovs-vsctl add-port br1 patch-ovs-1 -- set Interface patch-ovs-1 type=patch options:peer=patch-ovs-2 ovs-vsctl add-port br2 patch-ovs-2 -- set Interface patch-ovs-2 type=patch options:peer=patch-ovs-1
[root@bogon ~]# vi tcpdump_patch.sh 1 #modprobe dummy 2 ip link add name snooper0 type dummy 3 ip link set dev snooper0 up 4 ovs-vsctl add-port br1 snooper0 5 ovs-vsctl -- set Bridge br1 mirrors=@m 6 -- --id=@snooper0 get Port snooper0 7 -- --id=@patch-ovs-1 get Port patch-ovs-1 8 -- --id=@m create Mirror name=mymirror select-dst-port=@patch-ovs-1 9 select-src-port=@patch-ovs-1 output-port=@snooper0 select_all=1 10 # capture 11 #tcpdump -i snooper0 12 # clear 13 #ovs-vsctl clear Bridge br-int mirrors 14 #ip link delete dev snooper0 15 #ovs-vsctl list port snooper0 16 #ovs-vsctl list Mirror
flow没有改变
[root@bogon ~]# ovs-ofctl dump-flows br2 cookie=0x0, duration=54910.301s, table=0, n_packets=765, n_bytes=69086, priority=0 actions=NORMAL [root@bogon ~]# ovs-ofctl dump-flows br1 cookie=0x0, duration=54915.845s, table=0, n_packets=767, n_bytes=69262, priority=0 actions=NORMAL [root@bogon ~]#
删除所有镜像,添加一条flow
ovs-ofctl add-flow br1 "in_port=1,dl_type=0x0800,nw_proto=1,table=0, priority=4, actions=output:9,normal"
再添加mirror
5 ovs-vsctl -- set Bridge br1 mirrors=@m 6 -- --id=@snooper0 get Port snooper0 7 -- --id=@patch-ovs-1 get Port patch-ovs-1 8 -- --id=@m create Mirror name=mymirror select-dst-port=@patch-ovs-1 9 select-src-port=@patch-ovs-1 output-port=@snooper0 select_all=1
ovs-ofctl del-flows br1 tcp,in_port=tap1
参考:https://wiki.openstack.org/wiki/OpsGuide/Network_Troubleshooting