1、搭建拓扑
搭建了三层的二叉树结构网络,开启SimpleSwitch3.py无法完成pingall联通测试,于是将拓扑结构更改为简单的line,四个交换机(OF13)连成一线,每个交换机下挂两个主机,依次h1--h8
s1 = net.addSwitch('s1', cls=OVSKernelSwitch, protocols='OpenFlow13', mac='00:00:00:00:00:11')
s2 = net.addSwitch('s2', cls=OVSKernelSwitch, protocols='OpenFlow13', mac='00:00:00:00:00:12')
s3 = net.addSwitch('s3', cls=OVSKernelSwitch, protocols='OpenFlow13', mac='00:00:00:00:00:13')
s4 = net.addSwitch('s4', cls=OVSKernelSwitch, protocols='OpenFlow13', mac='00:00:00:00:00:14')
h1 = net.addHost('h1', ip='10.0.0.1', defaultRoute=None, mac='00:00:00:00:00:01')
h2 = net.addHost('h2', ip='10.0.0.2', defaultRoute=None, mac='00:00:00:00:00:02')
h3 = net.addHost('h3', ip='10.0.0.3', defaultRoute=None, mac='00:00:00:00:00:03')
h4 = net.addHost('h4', ip='10.0.0.4', defaultRoute=None, mac='00:00:00:00:00:04')
h5 = net.addHost('h5', ip='10.0.0.5', defaultRoute=None, mac='00:00:00:00:00:05')
h6 = net.addHost('h6', ip='10.0.0.6', defaultRoute=None, mac='00:00:00:00:00:06')
h7 = net.addHost('h7', ip='10.0.0.7', defaultRoute=None, mac='00:00:00:00:00:07')
h8 = net.addHost('h8', ip='10.0.0.8', defaultRoute=None, mac='00:00:00:00:00:08')
net.addLink(s1, h1)
net.addLink(s1, h2)
net.addLink(s2, h3)
net.addLink(s2, h4)
net.addLink(s3, h5)
net.addLink(s3, h6)
net.addLink(s4, h7)
net.addLink(s4, h8)
net.addLink(s1, s2)
net.addLink(s2, s3)
net.addLink(s3, s4)
2、开启ryu控制器
命令:sudo ryu-manager --observe-links simple_switch_13.py ofctl_rest.py rest_topology.py
ofctl_rest.py:为了之后下发、查看流表预留的接口
3、进行连通性测试
利用pingall命令,在mininet界面测试拓扑的联通状况
4、利用Postman查看各交换机流表
查看各端口连接情况,为逻辑隔离做好预备工作(了解主机与交换机链接的端口情况,下发流表时心中有数)
5、逻辑隔离
5.1、测试DELETE方法
在Postman Url栏输入 http://127.0.0.1:8080/stats/flowentry/clear/1 方法选择为DELETE
,即删除S1上的所有流表,因此h1与h2会与外界断绝联系,用pingall测试:
成功。
5.2、测试Modify命令(POST)方法
流表下发成功(断绝2号交换机来自一号端口的寻找7号主机的信息,讲动作集设为空),测试pingall
成功。
继续测试,修改1号交换机上来自1端口寻找8号主机的信息(下图)和2号主机上h3寻找h8消息(未贴图)
mininet测试:
成功。
6、总结
通过以上方法可实现简单的逻辑隔离功能。
转载于:https://blog.51cto.com/3655559/1917429