春风十里不如你 —— Taozi - Postman https://www.xiongan.host/index.php/tag/Postman/ zh-CN Thu, 11 May 2023 10:25:41 +0800 Thu, 11 May 2023 10:25:41 +0800 【SDN】使用Postman下发流表 https://www.xiongan.host/index.php/archives/206/ https://www.xiongan.host/index.php/archives/206/ Thu, 11 May 2023 10:25:41 +0800 admin 使用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

]]>
0 https://www.xiongan.host/index.php/archives/206/#comments https://www.xiongan.host/index.php/feed/tag/Postman/
【OpenDaylight】及Postman实现流表下发 https://www.xiongan.host/index.php/archives/198/ https://www.xiongan.host/index.php/archives/198/ Fri, 14 Apr 2023 00:25:00 +0800 admin 安装OVS
主机名ip角色
ovs192.168.123.10ovs

首先连接SSH

用finalshell连接,需要提前配置好ip和网卡

上传ovs源文件,并解压

68120158273

进入目录,执行./configure,生成Makefile文件

68120164422

然后进入编译安装

make
make install

68120167841

实验六-OpenDaylight及Postman实现流表下发

使用Opendaylight虚拟机

安装jdk1.8,并启动opendaylight

68120286124

安装组件:

68120391184

首先清理旧数据

DELETE http://127.0.0.1:8181/restconf/config/opendaylight-inventory:nodes/node/openflow:1/

image-20230413235336190

然后CLI命令行里再次清理

sudo mn -c

生成拓扑并连接 OpenDaylight

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

68120401669

68120403714

使用 Postman 填入 JSON 格式的 http 请求

image-20230413235939496

image-20230413235900248

//以下内容是Body中需要填写的
{
    "flow": [
         {
             "id": "1",
             "match": {
                 "in-port": "1",
                 "ethernet-match": {
                     "ethernet-type": {
                         "type": "0x0800"
                     }
                 },
                 "ipv4-destination": "10.0.0.3/32"
             },
             "instructions": {
                 "instruction": [
                     {
                         "order": "0",
                         "apply-actions": {
                             "action": [
                                 {
                                     "order": "0",
                                     "drop-action": {}
                                 }
                             ]
                         }
                     }
                 ]
             },
             "flow-name": "flow1",
             "priority": "65535",
             "hard-timeout": "5", //此处需要修改间隔,意味着h1 ping h3 有5秒时间是中断的
             "cookie": "2",
             "table_id": "0"
         }
     ]
 }

现在CLI中h1 ping h3,再去PUT数据链接

测试成功,结果符合预期

image-20230414000211597

鸣谢:小桂哥,King

]]>
0 https://www.xiongan.host/index.php/archives/198/#comments https://www.xiongan.host/index.php/feed/tag/Postman/