- Access exclusive content
- Connect with peers
- Share your expertise
- Find support resources
11-29-2017 06:00 AM - edited 11-29-2017 06:08 AM
Hi all,
I'm searching through the API browser on my PAN-OS 8 instance, and wondering where the syntax exists for exploring/getting the local policies per-physical device.
Or for clarity's sake - what API endpoint would return all of the local device's security policies. I am using some from Panorama globally, and cleaning up local security policies.
Not asking for someone to write a query for me, just point me to the right place in the API, please.
Any help appreciated!
11-29-2017 08:58 AM
Policies on firewalls are located in `rulebase` under the vsys (for vsys1 below):
/config/devices/entry[@name='localhost.localdomain']/vsys/entry[@name='vsys1']/rulebase
Policies on panorama are split between `pre-rulebase` and `post-rulebase` (for device group `Some group` below):
/config/devices/entry[@name='localhost.localdomain']/device-group/entry[@name='Some group']/pre-rulebase
/config/devices/entry[@name='localhost.localdomain']/device-group/entry[@name='Some group']/post-rulebase
11-29-2017 08:58 AM
Policies on firewalls are located in `rulebase` under the vsys (for vsys1 below):
/config/devices/entry[@name='localhost.localdomain']/vsys/entry[@name='vsys1']/rulebase
Policies on panorama are split between `pre-rulebase` and `post-rulebase` (for device group `Some group` below):
/config/devices/entry[@name='localhost.localdomain']/device-group/entry[@name='Some group']/pre-rulebase
/config/devices/entry[@name='localhost.localdomain']/device-group/entry[@name='Some group']/post-rulebase
11-29-2017 10:13 AM
Awesome, thanks so much @gfreeman!
11-29-2017 10:44 AM - edited 11-29-2017 10:46 AM
@gfreeman, if I enter:
/config/devices/entry[@name='localhost.localdomain']/vsys/entry[@name='vsys1']/rulebase
into the XPath search in the API browser, I get a 403 response of:
panCmsHandleDeviceContextReq: getRemoteContent() got response code 403
and same response if I try and submit:
/config/devices/entry[@name='localhost.localdomain']/vsys/entry[@name='nameofmyfirewall']/rulebase
I'm a super user on my Panorama instance, and have 1 vsys in it, so not sure why that query when hitting submit isn't working.
Halps?
11-29-2017 12:35 PM
Ended up realizing my own fail - was using the URL for panorama and not the device I wanted to target (d'oh!)
For anyone seeing this later, here's a Powershell function I wrote to pull the information I was after:
Function Get-LocalDeviceSecurityPolicies($DeviceIP)
{
$response = Invoke-RestMethod "https://$DeviceIP/api/?key=$apiKey&type=config&action=get&xpath=/config/devices/entry[@name='localhost.localdomain']/vsys/entry[@name='vsys1']/rulebase/security"
return $response.response.result.security.rules.entry
}
Click Accept as Solution to acknowledge that the answer to your question has been provided.
The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!
These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!
The LIVEcommunity thanks you for your participation!