User Tools

Site Tools


paloaltonetworks:api:scripts:firewall_config_sync

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
paloaltonetworks:api:scripts:firewall_config_sync [2020/08/07 10:17] bstaffordpaloaltonetworks:api:scripts:firewall_config_sync [2022/11/23 12:49] (current) – external edit 127.0.0.1
Line 12: Line 12:
  
  
 +@echo off
 +
 +SET FW1_KEY=APIKEY_HERE
 +SET FW2_KEY=APIKEY_HERE
 +SET FW_KEY=%FW1_KEY%
 +
 +SET FIREWALL_1_IP=10.1.1.1
 +SET FIREWALL_2_IP=10.1.1.1
 +SET FW_2_HOSTNAME=palo2
 +SET FIREWALL_IP=%FIREWALL_1_IP%
 +SET FILENAME=FW_1.xml
 +
 +
 +:: Export FW 1
 +SET TYPE=export
 +SET URL=https://%FIREWALL_IP%/api/?type=%TYPE%^&key^=%FW_KEY%^&category=^configuration
 +SET CURL_COMMAND=curl --insecure -o %FILENAME% -s -g -X GET "%URL%"
 +ECHO Starting configuration export from %FIREWALL_IP% ...
 +%CURL_COMMAND%
 +ECHO Finished configuration export from %FIREWALL_IP%
 +
 +
 +:: Upload to FW 2  
 +SET TYPE=import
 +SET FIREWALL_IP=%FIREWALL_2_IP%
 +SET FW_KEY=%FW2_KEY%
 +SET URL=https://%FIREWALL_IP%/api/?type=%TYPE%^&key^=%FW_KEY%^&category^=configuration
 +SET CURL_COMMAND=curl --insecure -s -o nul --form file=@%FILENAME% "%URL%"
 +ECHO Starting configuration import to %FIREWALL_IP% ...
 +%CURL_COMMAND%
 +ECHO Finished configuration import to %FIREWALL_IP%
 +
 +::
 +ECHO Deleting the downloading configuration ...
 +ECHO DEL %FILENAME%
 +
 +
 +::Load on FW2
 +SET TYPE=op
 +SET CMD=%%3Cload%%3E%%3Cconfig%%3E%%3Cfrom%%3E%FILENAME%%%3C/from%%3E%%3C/config%%3E%%3C/load%%3E
 +SET URL=https://%FIREWALL_IP%/api/?type^=%TYPE%^&key^=%FW_KEY%^&cmd^=%CMD%
 +SET CURL_COMMAND=curl --insecure -s -o nul -g -X GET "%URL%"
 +ECHO Starting configuration load on %FIREWALL_IP% ...
 +%CURL_COMMAND%
 +ECHO Finished configuration load on %FIREWALL_IP%
 +
 +
 +
 +::Correct Hostname
 +SET TYPE=config
 +SET CMD1=/config/devices/entry%%5B%%40name=%%27localhost.localdomain%%27%%5D/deviceconfig/system
 +SET CMD2=element^=%%3Chostname%%3E%FW_2_HOSTNAME%%%3C/hostname%%3E
 +SET URL=https://%FIREWALL_IP%/api/?type^=%TYPE%^&key^=%FW_KEY%^&action^=set^&xpath=%CMD1%^&%CMD2%
 +SET CURL_COMMAND=curl --insecure -s -o nul -g -X GET "%URL%"
 +ECHO Starting hostname correction on %FIREWALL_IP% ...
 +%CURL_COMMAND%
 +ECHO Finished hostname correction on %FIREWALL_IP% ...
 +
 +
 +:: Commit
 +SET TYPE=commit
 +SET CMD=%%3Ccommit%%3E%%3C/commit%%3E
 +SET URL=https://%FIREWALL_IP%/api/?type^=%TYPE%^&key^=%FW_KEY%^&cmd=%CMD%
 +SET CURL_COMMAND=curl --insecure -s -o nul -g -X GET "%URL%"
 +ECHO Starting commit on %FIREWALL_IP% ...
 +%CURL_COMMAND%
 +ECHO Commit scheduled on %FIREWALL_IP% ...</code>
paloaltonetworks/api/scripts/firewall_config_sync.1596795469.txt.gz · Last modified: (external edit)