项目八 使用postman实现简易防火墙功能

实验目的:

  • 理解北向接口的作用;
  • 掌握使用Postman调用北向接口的方法;

实验内容:

  • 了解Postman北向接口工具
  • 学习并掌握使用Postman工具实现简易防火墙的方法。

实验拓扑:

实验步骤:

1. 创建拓扑并连接ODL控制器

1.1启动ODL控制器

1.2 创建拓扑连接ODL控制器,并进行pingall测试

1.3 查看流表

1.4 浏览器中查看拓扑

打开浏览器,在地址栏输入http://127.0.0.1:8181/index.html,用户名和密码都是admin

1.5 查看nodeid

点击左侧菜单栏的Node,查看交换机的nodeid

2.使用postman下发流表,使h1与h2不能ping通。

2.1 打开Postman工具,在Postman主界面,点"+"新增一个请求,

  • 输入URL :http:// [controller-ip]:8181/restconf/config/opendaylight-inventory:nodes/node/[node-id]/flow-node-inventory:table/0/flow/flow6

    controller-ip\]为当前控制器的数据层的ip,\[node-id\]即步骤4)中获得的node id

  • 单击Authorization,type选择basic auth。输入用户名和密码,用户名和密码都是admin

2.2 下发流表

  • 选择BODY的类型raw ->JSON。
  • Body内容如下:
    {
    "flow":[
    {
    "id": "flow0",
    "table_id":0,
    "priority": 300,
    "match":{
    "ethernet-match":{
    "ethernet-type":{
    "type":"2048"
    }
    },
    "ipv4-source":"10.0.0.1/32",
    "ipv4-destination":"10.0.0.2/32",
    "in-port": "1"
    },
    "instructions":{
    "instruction":[
    {
    "order":"0",
    "apply-actions":{
    "action":[
    {
    "order":"0",
    "drop-action":{}
    }
    ]
    }
    }
    ]
    }
    }
    ]
    }
  • 在Postman点击Send,发送请求后,查看响应是否正常。结果为200OK或201Created都是正确。

2.3 查看流表下发是否成功

2.4 再次验证连通性

3. 使用Postman删除流表,使h1与h2能ping通

3.1 在Postman新创建一个请求

  • URL输入如下:
    http://[controller-ip]:8181/restconf/config/opendaylight-inventory:nodes/node/[node-id]/table/0/flow/flow0
  • 请求类型选择DELETE访问一个页面需要输入用户名和密码,单击Authorization,type选择basic auth。输入用户名和密码,用户名和密码都是admin。点击Send。

3.2 查看流表项是否删除成功

3.3 验证h1与h2能ping通。

4. 使用Postman下发流表,禁止h2访问h1中的web服务,允许h2能ssh登录到h1。

4.1 在h1开启了SimpleHTTPServer服务

  • 打开h1的终端
  • 开启SimpleHTTPServer服务,并使用8888端口向外提供服务
  • 使用xterm登录h2,访问地址:10.0.0.1,验证可以正常访问h1的web服务

4.2 使用Postman下发流表项

4.2.1 打开Postman工具,创建请求

  • 输入URL :http://[controller-ip]:8181/restconf/config/opendaylight-inventory:nodes/node/[node-id]/flow-node-inventory:table/0/flow/flow1
  • 请求类型选择PUT。单击Authorization,type选择basic auth。输入用户名和密码,用户名和密码都是admin。
  • 选择BODY的类型raw ->JSON。
  • Body内容:
css 复制代码
{
    "flow":[
        {
            "id":"flow1",
            "table_id":0,
            "priority":300,
            "match":{
                "ethernet-match":{
                    "ethernet-type":{
                        "type":"2048"
                    }
                },
                "ipv4-source":"10.0.0.2/32",
                "ipv4-destination":"10.0.0.1/32",
                "ip-match":{
                    "ip-protocol":6
                },
                "tcp-destination-port":8888
            },
            "instructions":{
                "instruction":[
                    {
                        "order":"0",
                        "apply-actions":{
                            "action":[
                                {
                                    "order":"0",
                                    "drop-action":{

                                    }
                                }
                            ]
                        }
                    }
                ]
            }
        }
    ]
}

4.2.2 查看流表项是否下发成功

4.3 验证

登录h2,验证h2无法访问h1的web服务,验证h2可以正常ping通h1

5. 打开Postman,发送请求,删除步骤4.3添加的流表项。并验证删除流表项后,h2可以正常访问h1的web服务。

5.1 在Postman新创建一个请求

  • URL输入如下:
    http://[controller-ip]:8181/restconf/config/opendaylight-inventory:nodes/node/[node-id]/table/0/flow/flow1。
  • 单击Authorization,type选择basic auth。输入用户名和密码,用户名和密码都是admin。
  • Body选择None,点击Send。

5.2 查看流表项是否删除成功

5.3 登录h2,看是否能正常访问h1的web服务

相关推荐
一念一花一世界1 天前
PostIn从基础到实践(5) - 对接口进行快捷调试
postman·postin·api调试·接口管理工具
一点事2 天前
用postman,如何调用webservice接口?
测试工具·postman
咨询QQ688238862 天前
非线性悬架建模与UKF状态估计:Matlab/Simulink源码与详细建模说明
postman
彼岸花@开2 天前
postman配置jdk自签证书的双向认证功能
jdk·postman
测试人社区—84162 天前
Postman API测试指南
人工智能·git·测试工具·自动化·bug·postman
测试人社区—84162 天前
Appium移动自动化测试:从入门到精通实战
人工智能·安全·appium·自动化·bug·postman
程序员杰哥3 天前
如何用Postman做接口自动化测试?
自动化测试·软件测试·python·测试工具·测试用例·接口测试·postman
测试人社区—84163 天前
Mocking与Stubbing在单元测试中的正确使用
人工智能·git·单元测试·自动化·bug·postman
一念一花一世界4 天前
一文了解接口管理工具PostIn安装与配置
postman·安装配置·postin·接口管理工具
linuxcpp_4 天前
postman历史版本下载
postman