话不多说,直接上拓扑:
我这里是用主机h1 (10.0.0.1)ping 主机h2(10.0.0.2)
1.添加VLAN标签
v1:
sudo ovs-ofctl add-flow m1-s1 in_port=,actions=mod_vlan_vid:,output:
v2:
sudo ovs-ofctl add-flow m1-s2 in_port=,dl_vlan=,action=output:
v3:
sudo ovs-ofctl add-flow m1-s3 in_port=,dl_vlan=,actions=strip_vlan,output:
2.添加MPLS标签
注意:ping是先用arp协议查看目标ip的mac地址,在发送icmp数据包,所以加标签完了去标签的时候要注意区分包类型!
V1
sudo ovs-ofctl add-flow -O OpenFlow13 m1-s1 icmp,in_port=,actions=push_mpls:0x8847,set_field:-\>mpls_label,output:
sudo ovs-ofctl add-flow -O OpenFlow13 m1-s1 arp,in_port=,actions=push_mpls:0x8847,set_field:-\>mpls_label,output:
V2
//改为ip协议 ,支持icmp
sudo ovs-ofctl add-flow -O OpenFlow13 m1-s2 mpls,in_port=,mpls_label=,actions=pop_mpls:0x0800,output:
sudo ovs-ofctl add-flow -O OpenFlow13 m1-s2 mpls,in_port=,mpls_label=,actions=pop_mpls:0x0806,output:
V3
sudo ovs-ofctl add-flow m1-s3 in_port=,actions=output:
附加:OVS操作cmd:
查看交换机流表
sudo ovs-ofctl dump-flows br0 "in_port=1"
删除指定交换机流表
sudo ovs-ofctl del-flows m1-s2