Add new address object to an existing group - SonicOS API
08/29/2022 1 People found this article helpful 333,410 Views
Description
SonicOS API provides an alternative to the SonicOS Command Line Interface (CLI) for configuring selected functions.
SonicOS API is disabled by default in SonicOS. Any attempt to access SonicOS API while it is disabled results in an HTTP 403 Forbidden error
. To use the SonicOS API, you must enable it, either through the SonicOS Management Interface or from the CLI.
This article only explains how to add an Address group and add address objects to it. Please follow these articles for additional assistance:
- Introduction to SonicOS API
- Creating Address Object and Address Group Object using SonicOS API cURL
- Adding Multiple Address Objects Using SonicOS API
- SonicOS API for adding Address group in Postman and cURL
You are free to choose Swagger, Postman, Git bash, or any application that allows API calls, if you are using a Linux-based operating system you can execute cURL from the terminal. Please refer to https://sonicos-api.sonicwall.com for the entire list.
Only the first part of this article would change, depending on the SonicWall model you use. Commands are the same for both Gen6 and Gen7 SonicWall devices.
For this article, I'm using Postman App and will be showing the commands to run on cURL for each step.
Resolution
Please enable SonicOS API module in the SonicWall UI. For Gen 7: Enable SonicOS API Gen7 and for Gen 6: Enable SonicOS API Gen6
The above KB also has the steps on how to Login using API Applications.
Scenario:
- There are 2 IPv4 HOST address objects already in the Address group called "testgroup"
Adding one more address object to this group
cURL commands:
curl --location --request PUT 'https://192.168.168.168/api/sonicos/address-groups/ipv4/name/testgroup' \
--header 'Content-Type: application/Json' \
--header 'Accept: application/Json' \
--header 'Authorization: Basic YWRtaW46cGFzc3dvcmQ=' \
--data-raw '{
"Addressograph": {
"ipv4": {
"name": "testgroup",
"address_object": {
"ipv4": {
"name": "New_Object"
}
}
}
}
}'
- There is a group with a mix of address objects - IPv4, MAC, FQDN.
We are going to add one more object of the type MAC
NOTE: As you can notice in the GUI, there are only 2 schemas supported IPv4 and IPv6. But when you have a mix of object types, the group becomes "mixed" schema, which is not supported. In such scenarios, IPv6 is to be used to call the group.
cURL commands:
curl --location --request PUT 'https://192.168.168.168/api/sonicos/address-groups/ipv6/name/testgroup' \
--header 'Content-Type: application/Json' \
--header 'Accept: application/Json' \
--header 'Authorization: Basic YWRtaW46cGFzc3dvcmQ=' \
--data-raw '{
"Addressograph": {
"ipv6": {
"name": "testgroup",
"address_object": {
"mac": {
"name": "MAC_object2"
}
}
}
}
}'
Related Articles
Categories
Was This Article Helpful?
YESNO