flow1 = { "switch":"00:00:00:00:00:00:00:03", "name":"flow-mod-1", "cookie":"0", "priority":"1", "ether-type":"2048", #~ "ingress-port":"1", "active":"true", "src-ip":"10.0.0.0/16", "dst-ip":"10.0.0.4", "actions":"drop" }
以上代码表示,在00:00:00:00:00:00:00:03交换机中添加了一条flow,该flow规则将所有10.0.x.x到10.0.0.4的数据包drop掉。
flow的通配规则为:
10.0.0.0/0 --> 全匹配,相当于10.0.0.0 10.0.0.0/8 --> 10.0.0.x 10.0.0.0/16 --> 10.0.x.x 10.0.0.0/24 --> 10.x.x.x 10.0.0.0/32 --> 全匹配,相当于10.0.0.0
可以在mininet中对host更改IP做实验测试。更改IP命令为:
mininet> py h1.setIP(‘10.1.0.1‘)