SDN
题目
在考试机器的任意一台PC上已部署的Vmware Workstation软件,导入ODL集成模板,虚拟机的内存设置为2G。添加两个网卡,两张网卡均采用桥接模式,ETH0网卡IP地址设置为192.168.23.100/24,ETH1网卡IP无须配置。默认系统登录的用户名/密码都是mininet(大小写区分)。
启动OpenDayLight的karaf程序,并安装如下组件:
feature:install odl-restconf
feature:install odl-l2switch-switch-ui
feature:install odl-mdsal-apidocs
feature:install odl-dluxapps-applications
使用Mininet和OpenVswitch构建拓扑,连接ODL的6653端口,采用OVS交换机,使用OpenFlow13协议连接控制器,创建如图7所示。
在浏览器上可以访问ODL管理页面查看网元拓扑结构。
通过OVS手动将ODL虚拟机eth1网卡添加到S2交换机中,将ODL虚拟机eth0网卡接口添加第二地址10.0.0.254/8的IP地址作为H1、H2、H3、H4的网关,同时开启ODL虚拟机系统的路由转发功能。
在S2交换机通过OVS手工下发流表,流表优先级为5,让odl虚拟机、H1、H2、H3、H4能够互通。
H1启动HTTP-Server功能,WEB端口为8000,在mn命令启动目录创建一个index.html,文件内容为“SDN test page”,Windows客户端作为HTTP-Client,获取H1的index.html网页内容。
一、安装并导入mininet
双击软件包
然后点导入
二、配置IP添加网卡以及karaf程序启动
用户名密码都是:mininet
mininet@mininet-vm:~$ sudo -s
root@mininet-vm:~# vim /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
#iface eth0 inet dhcp
iface eth0 inet static
address 192.168.23.100
netmask 255.255.255.0
gateway 192.168.23.254
crt连接上
启动OpenDayLight的karaf程序
root@mininet-vm:~# /home/mininet/ODL/bin/karaf
安装组件
feature:install odl-restconf
feature:install odl-l2switch-switch-ui
feature:install odl-mdsal-apidocs
feature:install odl-dluxapps-applications
添加网卡并启动
ifconfig eth1 up
三、创建拓扑
root@mininet-vm:~# cd /home/mininet/mininet/custom/
root@mininet-vm:~/mininet/custom# cp topo-2sw-2host.py mytopo.py
root@mininet-vm:~/mininet/custom# vim mytopo.py
"""Custom topology example
Two directly connected switches plus a host for each switch:
host --- switch --- switch --- host
Adding the 'topos' dict with a key/value pair to generate our newly defined
topology enables one to pass in '--topo=mytopo' from the command line.
"""
from mininet.topo import Topo
class MyTopo( Topo ):
"Simple topology example."
def __init__( self ):
"Create custom topo."
# Initialize topology
Topo.__init__( self )
# Add hosts and switches
H1 = self.addHost( 'h1' )
H2 = self.addHost( 'h2' )
H3 = self.addHost( 'h3' )
H4 = self.addHost( 'h4' )
S1 = self.addSwitch( 's1' )
S2 = self.addSwitch( 's2' )
# Add links
self.addLink( H1, S1)
self.addLink( H2, S1)
self.addLink( H3, S1)
self.addLink( H4, S2)
self.addLink( S1, S2)
topos = { 'mytopo': ( lambda: MyTopo() ) }
生成拓扑
root@mininet-vm:~/mininet/custom# mn --custom=mytopo.py --topo=mytopo --controller=remote,ip=127.0.0.1,port=6653 --switch=ovs,protocols=OpenFlow13
pingall一下生成
四、打开网页查看拓扑
浏览器输入http://192.168.23.100:8181/index.html
http://192.168.23.100:8181/index.html
用户名密码都是:admin
五、通过OVS手动添加网卡,设置网关
1.添加网卡
mininet> sh ovs-vsctl add-port s2 eth1
2.设置网关地址,开启路由转发
root@mininet-vm:~# ip addr add 10.0.0.254/8 dev eth0
root@mininet-vm:~# echo 1 > /proc/sys/net/ipv4/ip_forward
3.给H1,H2,H3,H4设置网关
六、OVS手工下发流表,流表优先级为5,让odl虚拟机能够互通。
1.下发流表
mininet> sh ovs-ofctl add-flow s2 priority=5,in_port=1,actions=output:2,3 -O openflow13
mininet> sh ovs-ofctl add-flow s2 priority=5,in_port=2,actions=output:1,3 -O openflow13
mininet> sh ovs-ofctl add-flow s2 priority=5,in_port=3,actions=output:1,2 -O openflow13
mininet>
2.ping H1主机测试连通性
root@mininet-vm:~# ping -c 4 10.0.0.1
七、启动HTTP-Server功能,端口为8000,目录创建一个index.html,文件内容为“SDN test page”,windows客户端作为HTTP-Client,获取H1的index.html网页内容。
1.H1开启HTTP-Server
h1 python -m SimpleHTTPServer 8000 &
2.创建index.html
root@mininet-vm:~# cd /home/mininet/mininet/custom/
root@mininet-vm:~/mininet/custom# vim index.html
SDN test page
3.设置客户端的IP地址和网关,并用浏览器访问