春风十里不如你 —— Taozi - ubuntu 2023-05-11T10:25:41+08:00 Typecho https://xiongan.host/index.php/feed/atom/tag/ubuntu/ <![CDATA[【SDN】使用Postman下发流表]]> https://xiongan.host/index.php/archives/206/ 2023-05-11T10:25:41+08:00 2023-05-11T10:25:41+08:00 admin https://www.xiongan.host 使用Postman下发流表

实验环境检查

查看Opendaylight控制器

68324582647

登陆Opendaylight控制器,在查看控制器主机的6633端口监听状态

root@guest-virtual-machine:/home/guest# netstat -an|grep 6633

68324632013

关闭防火墙

sudo ufw disable

访问WEB页面

68324642802

在OVS主机(Miniet主机)中创建拓扑结构,并测试连通性

sudo mn --topo=single,3 --controller=remote,ip=192.168.123.10,port=6633 --switch ovsk,protocols=OpenFlow13

68324677224

在控制器页面查看到的拓扑图

68324681237

使用postman查看交换机id信息,交换机id为1

http://192.168.123.10:8080/restconf/operational/network-topology:network-topology

68324733334

下发第一条流表

PUT

http://192.168.123.10:8080/restconf/config/opendaylight-inventory:nodes/node/openflow:1/table/0/flow/1

68324871215

主机1的MAC地址:00:0c:29:91:9c:e6
主机2的MAC地址:42:59:6f:b2:ee:64
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<flow xmlns="urn:opendaylight:flow:inventory">
<priority>200</priority>
<flow-name>Foo1</flow-name>
<idle-timeout>0</idle-timeout>
<hard-timeout>0</hard-timeout>
<match>
<ethernet-match>
<ethernet-source>
<address>00:0c:29:91:9c:e6</address>
</ethernet-source>
<ethernet-destination>
<address>42:59:6f:b2:ee:64</address>
</ethernet-destination>
</ethernet-match>
</match>
<id>1</id>
<table_id>0</table_id>
<instructions>
<instruction>
<order>0</order>
<apply-actions>
<action>
<order>0</order>
<output-action>
<output-node-connector>2</output-node-connector>
</output-action>
</action>
</apply-actions>
</instruction>
</instructions>
</flow>

下发第二条流表

http://192.168.123.10:8080/restconf/config/opendaylight-inventory:nodes/node/openflow:1/table/0/flow/2
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<flow xmlns="urn:opendaylight:flow:inventory">
<priority>200</priority>
<flow-name>Foo1</flow-name>
<idle-timeout>0</idle-timeout>
<hard-timeout>0</hard-timeout>
<match>
<ethernet-match>
<ethernet-source>
<address>42:59:6f:b2:ee:64</address>
</ethernet-source>
<ethernet-destination>
<address>00:0c:29:91:9c:e6</address>
</ethernet-destination>
</ethernet-match>
</match>
<id>2</id>
<table_id>0</table_id>
<instructions>
<instruction>
<order>0</order>
<apply-actions>
<action>
<order>0</order>
<output-action>
<output-node-connector>1</output-node-connector>
</output-action>
</action>
</apply-actions>
</instruction>
</instructions>
</flow>

68324910358

登陆交换机,查看流表

ovs-ofctl dump-flows s1

删除第一条流表

http://192.168.123.10:8080/restconf/config/opendaylight-inventory:nodes/node/openflow:1/table/0/flow/1

68324966554

删除第二条流表

http://192.168.123.10:8080/restconf/config/opendaylight-inventory:nodes/node/openflow:1/table/0/flow/2

68324977418

]]>
<![CDATA[【OpenDaylight】使用界面下发流表]]> https://xiongan.host/index.php/archives/196/ 2023-04-05T23:13:53+08:00 2023-04-05T23:13:53+08:00 admin https://www.xiongan.host OpenDaylight使用界面下发流表
主机名ip角色
controller192.168.123.10控制器1
ovs192.168.123.20交换机
pc1192.168.123.30主机1

实验步骤

环境检查

登陆控制器1,查看该端口是否处监听状态

root@guest-virtual-machine:/home/guest# netstat -an | grep 6633
tcp        0      0 192.168.123.10:44024    192.168.123.10:6633     ESTABLISHED
tcp6       0      0 :::6633                 :::*                    LISTEN     
tcp6       0      0 192.168.123.10:6633     192.168.123.10:44024    ESTABLISHED

保证控制器6633处监听状态后,使用root登陆交换机,查看交换机与控制器1的连接情况

连接情况

注:如果连接不成功会显示‘’fail_mode:secure‘’

则需要命令手动在交换机内重连

#ovs-vsctl del-controller br-sw
#ovs-vsctl set-controller br=sw tcp:192.168.123.10:6633

查看主机的ip地址:

控制器的ip地址

注:主机为获取到ip地址,需要手动重连

#ovs-vsctl del-controller br-sw
#ovs-vsctl set-controller br=sw tcp:192.168.123.10:6633

下发流表

切换到交换机,设置OpenFlow协议版本为1.0

root@guest-virtual-machine:/home/guest# ovs-vsctl set bridge br-sw protocols=OpenFlow10

访问控制器web UI,点击‘Nodes’ ‘1’为节点连接的具体信息

请输入图片描述

请输入图片描述

展开所有目录

所有目录

展开具体配置

具体配置

补全node id、table id、flow id

请输入图片描述

请输入图片描述

请输入图片描述

展开流表的相关参数

请输入图片描述

]]>
<![CDATA[【OpenDaylight】Karaf的使用]]> https://xiongan.host/index.php/archives/193/ 2023-03-24T11:20:00+08:00 2023-03-24T11:20:00+08:00 admin https://www.xiongan.host Karaf使用

ssh可能会连接不上,需要配置本地VM8的网卡,或者ssh,推荐下面方法

vi /etc/ssh/sshd_config
//最后添加一行
PermitRootLogin yes
//保存后重启服务器即可用远程工具连接Ubuntu主机

首先连接虚拟机

image-20230324103545964

上传安装包,解压缩并进入目录中,启动控制台

root@guest-virtual-machine:/home/guest# tar -zxvf distribution-karaf-0.3.0-Lithium.tar.gz
root@guest-virtual-machine:/home/guest# cd distribution-karaf-0.3.0-Lithium
//启动一(不推荐)
root@guest-virtual-machine:/home/guest# ./bin/karaf
//启动二(后台运行)
root@guest-virtual-machine:/home/guest/distribution-karaf-0.3.0-Lithium# ./bin/start
root@guest-virtual-machine:/home/guest/distribution-karaf-0.3.0-Lithium# ./bin/client -u karaf

image-20230324104253817

安装opendaylight组件

//安装REST API功能
opendaylight-user@root>feature:install odl-restconf
//安装L2交换机和OpenFlow功能
opendaylight-user@root>feature:install odl-l2switch-switch-ui
opendaylight-user@root>feature:install odl-openflowplugin-flow-services-ui
//安装Karaf控制台的md-sal功能
opendaylight-user@root>feature:install odl-mdsal-apidocs
//安装DLUX功能 0.3.0无需安装,0.6.0可以安装
//opendaylight-user@root>feature:install odl-dluxapps-applications
//opendaylight-user@root>feature:install odl-faas-all
//列出所有组件
opendaylight-user@root>feature:list

image-20230324105618145

验证opendaylight功能

首先查看ip地址:

image-20230324110258172

连接控制器

root@guest-virtual-machine:/home/guest# mn --controller=remote,ip=192.168.123.10,port=6633
mininet> pingall
*** Ping: testing ping reachability
h1 -> h2 
h2 -> h1 
*** Results: 0% dropped (2/2 received)

访问web控制器(账号密码admin)

image-20230324110455866

image-20230324110537387

卸载opendaylight组件

opendaylight-user@root>logout

logout退出,回到上一目录中

root@guest-virtual-machine:/home/guest/distribution-karaf-0.3.0-Lithium# rm -rf data
root@guest-virtual-machine:/home/guest/distribution-karaf-0.3.0-Lithium# ./bin/karaf clean
opendaylight-user@root>feature:list -i

查看已安装组件,确认已卸载

image-20230324110931770

]]>