- Access exclusive content
- Connect with peers
- Share your expertise
- Find support resources
07-14-2021 08:46 AM - edited 07-15-2021 07:58 AM
Trying to find the correct syntax for querying Panorama for policy post rules by matching IP address (source or destination IP) using the PanOS XML API.
I have looked at:
Still not finding what I am looking for. Is it me, or is API not sufficiently well documented? Can anyone point me to where I can find documentation for each PanOS XML API endpoint, preferably with syntax examples for all possible endpoint parameters?
07-23-2021 02:07 AM
Hi @julio.toledo, the API structure for this feature will match what you see in the GUI, where there are indeed mandatory fields (the red boxes) like destination ports, and protocol is a drop-down between TCP/UDP/ICMP:
I think this feature is designed to give people a way to test if specific traffic will theoretically pass through the firewall, rather than the very broad and almost audit-type requirement which you have. If you talk with your allocated Systems Engineer or reseller (if you're unsure who they are, send me a direct message on here and I will assist) then they will be able to discuss your requirements and potentially raise a feature request.
Other options to fulfil your requirements would involve an approach of systematically checking the live configurations of your firewall estate, by exporting the Panorama running config and walking through the XML data in your programming language of choice.
07-19-2021 10:13 AM
Hi @julio.toledo, I believe you're trying to use the "test policy match" feature via API? If so, I did something similar a couple of weeks ago. I did NAT rules, but you could easily change the API call below to use security rules instead.
https://{{panorama-host}}/api?key={{key}}&type=op&cmd=<request-batch><op-command><device><entry name="{{fw1-serial}}"><vsys><list><member>vsys1</member></list></vsys></entry><entry name="{{fw2-serial}}"><vsys><list><member>vsys1</member></list></vsys></entry></device><test><nat-policy-match><from>Management</from><to>External</to><source>172.31.10.50</source><destination>8.8.8.8</destination><destination-port>443</destination-port><protocol>6</protocol></nat-policy-match></test></op-command></request-batch>
I find the easiest way to find API calls is to debug the GUI, or debug the CLI.
07-19-2021 11:28 AM - edited 07-19-2021 11:31 AM
Thanks @JimmyHolland. Yes, I am trying to query security rules via API, either aggregate rules from all devices or from a particular device. However I am not a network or firewall engineer, so things like PanOS CLI commands and Panorama schema (objects, properties, etc.) are new to me.
I find it hard to understand that there is no online reference to the Panorama schema and how it maps to either CLI commands and/or API requests. Reverse engineering it by debugging the GUI or the CLI seems rather backwards, don't you agree?
07-19-2021 12:44 PM
Hi @julio.toledo, I understand learning the PAN-OS schema must be a challenge if you are new to PAN-OS and firewalls/network-security/networking. There is no exhaustive list of XML API endpoints to the full extent, which is why the debug approach usually works best, especially as the CLI/GUI are themselves clients of the XML API. The newer REST API is improving this situation, however, and continues to gain coverage with each release of PAN-OS, so that's something to keep an eye on.
07-22-2021 09:23 AM
Thanks @JimmyHolland I figured out how to structure a 'security-policy-match', however it's requiring arguments that make the query far too specific/narrow. It seems that both 'protocol' and 'destination-port' are required, and neither one allows 'any' or '*' or even a range of values (integers only).
Is there a way to match policies across:
07-23-2021 02:07 AM
Hi @julio.toledo, the API structure for this feature will match what you see in the GUI, where there are indeed mandatory fields (the red boxes) like destination ports, and protocol is a drop-down between TCP/UDP/ICMP:
I think this feature is designed to give people a way to test if specific traffic will theoretically pass through the firewall, rather than the very broad and almost audit-type requirement which you have. If you talk with your allocated Systems Engineer or reseller (if you're unsure who they are, send me a direct message on here and I will assist) then they will be able to discuss your requirements and potentially raise a feature request.
Other options to fulfil your requirements would involve an approach of systematically checking the live configurations of your firewall estate, by exporting the Panorama running config and walking through the XML data in your programming language of choice.
07-23-2021 08:49 AM
Ding, ding, ding! We have a winner. So what I am looking to accomplish is audit/research level work.
On a competitor's product (which shall remain nameless) I am able to issue the following simple, single-line CLI command (on a device-by-device basis) and get back an exhaustive std output of every member rule matching the IP that I'm searching for --either as source or as destination:
show access-list | include {{ lookupIP }}
This is exactly the kind of functionality that I'm looking for from Panorama/PAN-OS.
08-03-2021 02:30 AM
Thanks for confirming @julio.toledo. Per DM, we've connected you with your SE in order to discuss this topic in more detail.
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!