參考鏈接: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