To create a contention to block VLAN 100 traffic on port 1 of switch 00:00:00:00:00:00:00:01
, execute the following command:
curl -H 'Content-type: application/json' -X POST http://127.0.0.1:8181/api/hackinsdn/containment/v1 -d '{"switch": "00:00:00:00:00:00:00:01", "interface": 1, "match": {"vlan": 100}}'
Result: "contention created successfully ID 6a3c2d9afdd94136"
Remove the block (only by the rule ID):
curl -H 'Content-type: application/json' -X DELETE http://127.0.0.1:8181/api/hackinsdn/containment/v1 -d '{"block_id": "6a3c2d9afdd94136"}'
Result: "contention deleted successfully ID 6a3c2d9afdd94136"
To create a contention to block IPv4 traffic 10.1.0.254
on VLAN 100 on port 1 of switch 00:00:00:00:00:00:00:01
, execute the following command:
curl -H 'Content-type: application/json' -X POST http://127.0.0.1:8181/api/hackinsdn/containment/v1 -d '{"switch": "00:00:00:00:00:00:00:01", "interface": 1, "match": {"vlan": 100, "ipv4_dst": "10.1.0.254"}}'
Result: "contention created successfully ID 85b47cd567bb4b44"
To create a contention to block IPv4 traffic 10.1.0.254
on VLAN 100 and UDP protocol on port 1 of switch 00:00:00:00:00:00:00:01
, execute the following command:
curl -H 'Content-type: application/json' -X POST http://127.0.0.1:8181/api/hackinsdn/containment/v1 -d '{"switch": "00:00:00:00:00:00:00:01", "interface": 1, "match": {"vlan": 100, "ipv4_dst": "10.1.0.254", "ip_proto":17}}'
Result: "contention created successfully ID 8b47dda543cc4ad3"
To list the existing contentions, execute the following command (two options):
curl -s http://127.0.0.1:8181/api/hackinsdn/containment/v1/ or curl -X GET -H 'Content-type: application/json' http://127.0.0.1:8181/api/hackinsdn/containment/v1/
The NAPP does not allow duplicate rules to be created:
Add rule:
curl -H 'Content-type: application/json' -X POST http://127.0.0.1:8181/api/hackinsdn/containment/v1 -d '{"switch": "00:00:00:00:00:00:00:01", "interface": 1, "match": {"vlan": 100}}'
Result: "contention created successfully ID 6a3c2d9afdd94136"
Add the same rule again:
curl -H 'Content-type: application/json' -X POST http://127.0.0.1:8181/api/hackinsdn/containment/v1 -d '{"switch": "00:00:00:00:00:00:00:01", "interface": 1, "match": {"vlan": 100}}'
Result: "RULE already exists in the list. Contention doesn’t created"
In addition to the presented tests, it is also possible to create rules with match for IPV6. For this, consider VLAN101. You can also add "ipv6_src" or "ipv6_dst" in the match.