前言:原文在我的博客网站中,持续更新数通、系统方面的知识,欢迎来访!
22年全国职业技能大赛——SDN配置(IspSrv)https://myweb.myskillstree.cn/93.html
目录
IspSrv
题目:
在 IspSrv 上导入 OpenDayLight 软件包;
启动 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 端口如下拓扑结构:
在浏览器上可以访问 ODL 管理页面查看网元拓扑结构;
通过 OVS 给 S2 下发流表,使得 H2 与 H1、H3 无法互通;
H1 启动 HTTP-Server 功能,WEB 端口为 8080,H3 作为 HTTP-Client,获取 H1 的 html 网页配置文件。
配置:
清空防火墙原先的所有规则且入口放行所有
iptables -F
iptables -P INPUT ACCEPT
iptables-save
安装相关软件包:
apt install openjdk-8-jdk mininet -y
mkdir /sdn
上传并解压OpenDayLinght,启动karaf
可以使用WinScp软件进行传输,也可以选择windows自带的Scp命令进行传输,这里使用的是scp命令进行传输
unzip distribution-karaf-0.6.0-Carbon.zip # 解压软件包
rm distribution-karaf-0.6.0-Carbon.zip # 删除原软件包
cd distribution-karaf-0.6.0-Carbon/bin
./start
./client # 这里需要稍微等一下
安装相应的组件
feature:install odl-restconf odl-l2switch-switch-ui odl-mdsal-apidocs odl-dluxapps-applications
安装完成后可以打开网页进行测试:
浏览器输入:ip地址:8080/index.html,用户名和密码都是admin
创建拓扑
logout # 退出
mn --controller=remote,ip=127.0.0.1,port=6653 --topo=linear,3 --switch default,protocols=OpenFlow10 # 创建线性拓扑
pingall
*** Ping: testing ping reachability
h1 -> h2 h3
h2 -> h1 h3
h3 -> h1 h2
*** Results: 0% dropped (6/6 received)
打开网页查看拓扑(一定要ping通再去查看)
下发流表
sh ovs-ofctl add-flow s2 in_port=1,actions=drop # 在switch2上添加一个流表项,将所有从1端口进入的数据包丢弃
pingall
*** Ping: testing ping reachability
h1 -> X h3
h2 -> X X
h3 -> h1 X
*** Results: 66% dropped (2/6 received)
启动HTTP-Server功能
h1 python -m SimpleHTTPServer 8080 &
sh apt install wget -y # 在 Mininet 创建的虚拟网络环境中的主机上安装 wget
h3 wget 10.0.0.1:8080
--2024-03-25 13:28:36-- http://10.0.0.1:8080/
正在连接 10.0.0.1:8080... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:1052 (1.0K) [text/html]
正在保存至: “index.html”
index.html 0%[ ] 0 --.-KB/s index.html 100%[===================>] 1.03K --.-KB/s 用时 0s
2024-03-25 13:28:36 (157 MB/s) - 已保存 “index.html” [1052/1052])