示例:使用REST API创建使用端口的ACL
此示例显示在IP地址的开关上创建以下ACL和端口配置192.0.2.5:
接口1/1/2否关闭申请访问 - 列表IP ACLV4 OUT Access-List IP ACLV4 10许可证TCP 10.0.100.100.101 EQ 80 10.0.100.100.102 EQ 8000
创建ACL。
$curl -noproxy 192.0.2.5 -k -x post \ -b/tmp/auth_cookie -d'{“ cfg_version”:0,“ list_type”:“ ipv4”,“ name”:“ aclv4”}/192.0.2.5/rest/v1/system/acls“
创建ACL条目。
$curl - -noproxy 192.0.2.5 -k -k -x post \ -b/tmp/auth_cookie -d'{...“ action”:“ pluce”,“ dst_ip”:“ 10.0.100.100.102/255.255.255.255.255.255”,“:8000,” dst_l4_port_min“:8000,“协议”:6,“ sequence_number”:10,“ SRC_IP”:}'“ https://192.0.2.5/rest/v1/system/acls/aclv4/ipv4/cfg_aces”
在下一步中获取ACL配置信息。椭圆(…)表示示例未显示的数据。
$curl -noproxy 192.0.2.5 -k get \ -b/tmp/auth_cookie \“ https://192.0.2.5/rest/v1/v1/system/acls/acls/acls/aclv4/ipv4?selector=configuration = Configuration”{...“ cfg_aces”:{},“ cfg_version”:0 ...“ list_type”:“ ipv4”,“ name”:“ aclv4” ...}
使用从上一步中执行的GET请求收到的返回主体更新ACL配置。
当您发送PUT请求时,JSON请求主体不得包含不变的属性。这AOS-CXREST API参考模型的方法resource shows the mutable attributes. Any mutable attributes you do not include in the PUT request body are set to their defaults, which could be empty.
这AOS-CXREST API参考JSON模型的PUT方法
/system/acls/{id1}/{id2}
资源显示以下示例:{ "cfg_aces": { "integer": "URL" }, "cfg_version": 0 }
以下示例显示了更新ACL配置的请求:
$卷曲-Noproxy 192.0.2.5 -K -X put \ -b/tmp/auth_cookie -d'{“ cfg_aces”:{“ 10”:},“ cfg_version”:1}'\“ https://192.0.2.5/rest/v1/system/acls/acls/aclv4/ipv4”
创建端口1/1/2。
$curl --noproxy 192.0.2.5 -k -X POST \ -b /tmp/auth_cookie -d '{ "name": "1/1/2", "admin":"up", "interfaces":["/rest/v1/system/interfaces/1%2F1%2F2"], "vrf":"/rest/v1/system/vrfs/default"}' \ "https://192.0.2.5/rest/v1/system/ports"
获取接口的配置信息。
GET响应主体仅包含已设置的配置属性。
$curl -noproxy 192.0.2.5 -k get \ -b/tmp/auth_cookie \“ https://192.0.2.5/rest/v1/v1/system/interfaces/1%2f1%2%2F2?selector = Configuration = Configuration”{...“ options”:{},“ other_config”:{},“ udld_arubaos_compatibility_mode”:“ forward_then_verify”,“ udld_compatibility”:“ udld_compatibility”:“ aruba_os”:“ aruba_os”,“ ar aruba_enable”,“ udld_enable”,“ udld_enable”:udld_enable“4,“ udld_rfc5171_compatibility_mode”:“ normal”,“ user_config”:{} ...}
验证哪些配置属性是可变的,因此可以包含在看请求中。
当您发送PUT请求时,JSON请求主体不得包含不变的属性。这AOS-CX资源的PUT方法的REST API参考JSON模型显示了可变属性。您未包含在PUT请求主体中的任何可变属性都设置为它们的默认值,这可能是空的。
这AOS-CXREST API参考JSON模型的PUT方法
/system/Interfaces/{id}
资源显示以下示例:{...“ description”:“ string”,“ options”:{},“ other_config”:{},“ udld_arubaos_compatibility_mode_mode_mode_mode”:“ string”,“ udld_compatibility”:udld_compatibility':“ string”:“ string”,“ udld_enable”:udld_enable“:udld_interval”:udld_interval“:0,“ udld_retries”:0,“ udld_rfc5171_compatibility_mode”:“ string”,“ user_config”:{} ...}
使用从Get请求接收到的返回正文中的所有属性启用接口,修改
user_config
属性为:“ user_config”:{“ admin”:“ up”}
$curl -noproxy 192.0.2.5 -k -k -x put \ -b /tmp /auth_cookie -d'{...“ options”:{},“ elether” config“:{},” udld_arubaos_comcompatibility_mode_mode_mode_mode_mode_mode_mode_mode_mode_mode_mode_mode“:”“:“ aruba_os”,“ udld_enable”:false,“ udld_interval”:7000,“ udld_retries”:4,“ udld_rfc5171_compatibility_mode_mode_mode”:“\“ https://192.0.2.5/rest/v1/system/interfaces/1%2f1%2F2”
在前面的示例中,不包括上一个步骤中列出的以下可变属性,因此将其设置为默认值,该默认值可能为空:
selftest_disable
在下一步中获取端口配置信息。
椭圆(…)表示示例未显示的数据。
$curl -noproxy 192.0.2.5 -k get \ -b/tmp/auth_cookie \“ https://192.0.2.5/rest/v1/v1/system/ports/1%2F1%2F1;{...“ aclv4_out_cfg”:{},“ aclv4_out_out_cfg_version”:{},“ admin”:{},“ arp_timeout”:1800,...“ virtual_ip4_routers”:“:[] ...}
在验证PUT方法的JSON模型中允许的值后,使用从上一步中执行的GET请求收到的返回主体将ACL信息添加到端口中。修改值在以下示例中显示。
椭圆(…)表示示例未显示的数据。
$curl -noproxy 192.0.2.5 -k -x put \ -b/tmp/auth_cookie -d'{...“ admin”:“ up”,“ interfaces”:[/rets/rest/v1/v1/v1/v1/system/interfaces/1%2F1%2F2“],“ ACLV4_OUT_CFG”:“/REST/V1/SYSTEM/ACLS/ACLV4/IPV4”,“ ACLV4_OUT_CFG_VERSION”:0,...}'-D- \ \ https:/https:/https:///192.0.2.5/REST/V1/SYSTEM/PORTS/1%2F1%2F2“