How To migrate FQDN address objects from a Gen 6 to Gen 7 device using SonicOS API?
08/13/2020 2 People found this article helpful 465,831 Views
Description
There are always situations where you have added many FQDN address objects to be used for exclusions and want the same address objects on other firewalls for similar exclusions. This KB explains how you can use SonicOS API to retrieve the FQDN address objects from a Generation 6 firewall and add them on a Gen 7 device running SonicOS 7.0 or SonicOSX 7.0.
TIP: The URL varies based on the type of the objects that you are adding or retrieving. Please refer https://sonicos-api.sonicwall.com for the entire list.
Resolution
EXAMPLE: In this example, we are going to retrieve the FQDN address objects from a TZ 500 running 6.5.4.6-79n reachable via IP: 192.168.188.100 on port TCP 444 and add those address objects on a TZ 670 running SonicOS 7.0 reachable via IP: 192.168.188.50 on port TCP 443.
NOTE: The same steps can be used for a Gen 7 device running SonicOSX 7.0. Also, if you already have the FQDN address objects in JSON format, scroll down to Part 2 of this KB and follow the steps required for Gen 7 device.
You would need to perform the following steps to retrieve the FQDN address objects from Gen 6 device:
- Enabling the API Module on the firewall UI.
Login to the SonicWall management UI. Navigate to MANAGE | Appliance | Base Settings and scroll down to SonicOS API section. Enable the option 'Enable SonicOS API' and 'Enable RFC-2617 HTTP Basic Access authentication' option.
- List of applicable APIs:
Navigate to MANAGE | API and click on the link https://SonicOS-api.sonicwall.com. Swagger will prepopulate your SonicWalls’s IP, MGMT Port, Firmware so it can give you a list of applicable APIs.
TIP: 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. In this article, we are using Postman on Windows.
- Login to the Firewall using Postman.
a) The HTTP method should be POST and we need to use the URL: https://192.168.188.100:444/api/sonicos/auth
Under the authorization tab, select Basic Auth and mention the correct admin credentials.
NOTE: https://192.168.188.100:444/-- Replace this with your SonicWall's Public or private IP address with the right management port number (If the management port is 443, you can directly use https:// followed by the IP address without the port number too).
b) Under the settings tab, turn OFF the Enable SSL certificate verification if the firewall is using a self-signed certificate for management.
c) Under the headers tab, include application/json as the value for keys Accept and Content-type. After this, click on the Send button and then you can see the response on the section below. The response should contain a message: "success".
- Retrieving all FQDN address objects in JSON format.
The HTTP method should be GET and we need to use the URL: https://192.168.188.100:444/api/sonicos/address-objects/fqdn
The other fields can be left the same as before and click on Send. The response for this HTTP method would contain the list of all FQDN address objects present on this firewall.
Use the Save Response button and save it in a file. You can open that file in any text editor and that should have all the FQDN address objects as a collection in JSON format as below. We would need this as an input in the next section.
- Log out of the SonicWall with API
It is recommended to log out from the SonicWall via API once the desired configuration is committed. In this case, we do not want to make any changes but just retrieve some information.
The HTTP method should be DELETE and we need to use the URL: https://192.168.188.100:444/api/sonicos/auth
Click on the Send button and then you can see the response on the section below. The response should contain a message: "success".
You would need to perform the following steps to add the FQDN address objects to Gen 7 device:
- Enabling the API Module on the firewall UI
Login to the SonicWall management UI. The SonicOS API module is enabled by default and cannot be disabled. Navigate to DEVICE | Settings | Administration | Audit/SonicOS API tab and enable the toggle switch for RFC-2617 HTTP Basic Access authentication option.
- Login to the Firewall using Postman.
a) The HTTP method should be POST and we need to use the URL: https://192.168.188.50/api/sonicos/auth
Under authorization tab, select Basic Auth and mention the correct admin credentials.
NOTE: https://192.168.188.50/-- Replace this with your SonicWalls Public or private IP address with the right management port number (If the management port is 443, you can directly use https:// followed by the IP address without the port number too).
b) Under the settings tab, turn OFF the Enable SSL certificate verification if the firewall is using a self-signed certificate for management.
c) Under the headers tab, include application/json as the value for keys Accept and Content-type.
d) The Gen 7 devices are token driven. Use the {"override" : true} under the body to override any older tokens. After this, click on the Send button and then you can see the response on the section below. The response should contain a message: "success".
- Adding the collection of FQDN address objects in JSON format.
The HTTP method should be PUT and we need to use the URL: https://192.168.188.50/api/sonicos/address-objects/fqdn
NOTE: The HTTP POST method can also be used for this step.
The body should contain the collection of FQDN address objects in JSON format. Copy the same taken from step 4 in part 1 of this KB. The other fields can be left the same as before and click on Send. The response should contain a message: "success".
- Committing all the configurational changes made with APIs:
The HTTP method should be POST and we need to use the URL: https://192.168.188.50/api/sonicos/config/pending
The other fields can be left the same as before and click on Send. The response should contain a message: "success".
- Log out of the SonicWall with API
It is recommended to log out from the SonicWall via API once the desired configuration is committed.
The HTTP method should be DELETE and we need to use the URL: https://192.168.188.50/api/sonicos/auth
Do not use {"override" : true} parameter in the body for log out. Click on the Send button and then you can see the response on the section below. The response should contain a message: "success".
You can manually log in to the firewall to check the changes made. Navigate to OBJECT | Match Objects | Addresses to check for the changes.
TIP: Postman offers another very good feature called as a global variable. You can save the URLs of the firewalls as global variables so that in case they change, all requests need not be re-written.
- To use this feature, click on the Eye button next to the Environment drop-down and click on Edit/Add next to Globals.
- Enter the variables and add their initial and current values that match the current IP address/hostnames for the firewalls and then click on Save.
- You can then use the variables in your requests as shown below. They should give you the exact same responses as before and the values can be updated if required.
Related Articles
Categories
Was This Article Helpful?
YESNO