2019年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地址和网关,并用浏览器访问

在这里插入图片描述
在这里插入图片描述

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

痞痞鸭

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值