openvswitch流表匹配原则(tp_dst跨端口)

参考链接:http://rpm.pbone.net/index.php3/stat/45/idpl/23319267/numer/8/nazwa/ovs-ofctl(英语好的建议看原文)

  • in_port=port
    ovs上的port接口名,可以通过ovs-ofctl show查看有哪些port
  • dl_vlan=vlan
    匹配的vlan,范围是0-4095
  • dl_vlan_pcp=priority
    匹配多个vlan时的优先级,范围0-7,值越大越优先
  • dl_src=xx:xx:xx:xx:xx:xx
    匹配源mac地址
  • dl_dst=xx:xx:xx:xx:xx:xx
    匹配目的mac
  • dl_type=ethertype
    匹配协议类型,比如0x0806代表arp协议,0x0800代表ip协议
  • nw_src=ip[/netmask]
    匹配源ip
  • nw_dst=ip[/netmask]
    匹配目的ip
  • nw_proto=proto
    匹配协议类型(十进制),范围0-255,比如1代表icmp,6代表tcp
  • nw_ttl=ttl
    匹配ip/ipv6 TTL的最大跳数,范围0-255
  • tp_src=port
    匹配源port端口
  • tp_dst=port
    匹配目的port端口

注意这种情况:tp_src=port/mask,tp_dst=port/mask
❗❗❗当你想匹配的端口不是具体的某一端口,而是一个范围,比如1000-1999,当然可以写1000条匹配原则,这里介绍将1000个端口归类
1、先将1000和1999转成二进制
0000 0011 1110 1000
0000 0111 1100 1111
2、从1000(二进制)最末尾的1开始取大于0的值,举个例子0000 0011 1110 1000前12位不动,最后的4位是1000,取比他大的值1100、1110、1111都可以,也就是说前13位不动,后3位取9或1都可以,所以变成0000001111101000/1111111111111000转换成16进制就是0x03e8/0xfff8,/后面的掩码1代表固定值即前13位不可以改,0代表可变值即后3位可以是0也可以是1
3、以此类推如下
0000001111101xxx
000000111111xxxx
0000010xxxxxxxxx
00000110xxxxxxxx
000001110xxxxxxx
0000011110xxxxxx
000001111100xxxx
同理,xxx可变值换成0,掩码除了xxx是0,其余位是1
tcp,tp_src=0x03e8/0xfff8
tcp,tp_src=0x03f0/0xfff0
tcp,tp_src=0x0400/0xfe00
tcp,tp_src=0x0600/0xff00
tcp,tp_src=0x0700/0xff80
tcp,tp_src=0x0780/0xffc0
tcp,tp_src=0x07c0/0xfff0
4、处理之后原来的1000条匹配规则就变成了7条,方便查看和归类

  • table=number
    匹配table,范围0-254
  • resubmit:port
    重定向到指定port
  • resubmit([port],[table])
    重定向到指定table
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章