-
Notifications
You must be signed in to change notification settings - Fork 16
unused objects
Sven Waschkut edited this page Feb 23, 2022
·
3 revisions
To cleanup your Palo Alto Networks Firewall / Panorama configuration, the first step can be to find all unused objects:
The examples listed below are describing the ONLINE connection method. It is always possible and recommended to first make yourself familiar with the PAN-OS-PHP tool against offline configuration files:
-
pan-os-php type=upload in=api://MGMT-IP out=start-config.xml
example for using OFFLINE method pan-os-php type=XYZ in=start-config.xml out=manipulated-config.xml
pan-os-php type=rule ruletype=security actions=display in=api://MGMT-IP location=any 'filter=(rule is.unused.fast)'
pan-os-php type=address actions=display in=api://MGMT-IP location=any 'filter=(object is.unused.recursive)'
pan-os-php type=service actions=display in=api://MGMT-IP location=any 'filter=(object is.unused.recursive)'
pan-os-php type=tag actions=display in=api://MGMT-IP location=any 'filter=(object is.unused)'
pan-os-php type=rule ruletype=security actions=exporttoexcel:ruleusage.xls in=api://MGMT-IP location=any 'filter=(rule is.unused.fast)'
pan-os-php type=address actions=exporttoexcel:addressusage.xls in=api://MGMT-IP location=any 'filter=(object is.unused.recursive)'
pan-os-php type=service actions=exporttoexcel:serviceusage.xls in=api://MGMT-IP location=any 'filter=(object is.unused.recursive)'
pan-os-php type=tag actions=exporttoexcel:tagusage.xls in=api://MGMT-IP location=any 'filter=(object is.unused)'
{DATE1} is a variable for e.g. 20220222, please replace this variable with a fix value.
To cleanup e.g. Security Rules, a longer time range is recommended to take a decision if a Rule can be deleted:
pan-os-php type=rule ruletype=security actions=tag-add:UNUSED-{DATE1} in=api://MGMT-IP location=any 'filter=(rule is.unused.fast)'
pan-os-php type=rule ruletype=security actions=tag-remove:UNUSED-{DATE1} in=api://MGMT-IP location=any 'filter=!(rule is.unused.fast) and (tag has UNUSED-{DATE1})'
This approach can be repeated weekly/monthly or what every time range fit best to your environment.
pan-os-php type=rule ruletype=security actions=delete in=api://MGMT-IP location=any 'filter=(rule is.unused.fast) and (tag has UNUSED-{DATE1})'
pan-os-php type=address actions=delete in=api://MGMT-IP location=any 'filter=(object is.unused.recursive)'
pan-os-php type=service actions=delete in=api://MGMT-IP location=any 'filter=(object is.unused.recursive)'
pan-os-php type=tag actions=delete in=api://MGMT-IP location=any 'filter=(object is.unused)'