Log forwarding profile in all security policies

Reply
L2 Linker

Log forwarding profile in all security policies

Is there any other way to configure Log forwarding profile in all 300+ security policies in single shot.

 

currently there is no log forwarding profile in all 300+ policies.

 

 

So below method is not applicable:

 

Not through web interface but you can export config out.

It is one single xml file.

 

Device > Setup > Operations > Export configuration version

Pick latest one from dropdown and click ok.

 

Then open this xml in your favourite text editor.

 

Find area between:

<rule base>

<security>

<rules>

and

</rules>

</security>

 

 

 Everywhere you see "</entry>" and log-setting config does not precede:

Then replace this with:

<log-setting>Log-Forwarding-Policy</log-setting>

</entry>

 

L7 Applicator

Re: Log forwarding profile in all security policies

@Javith_Ali,

Is there a specific reason why you can't export the XML and modify it manually? That would be a fairly logical conclussion for what you are looking to do, and would honestly take the least amount of time. This is something you could script, but you would need to collect all of the security policy names to actually write that script. 

L7 Applicator

Re: Log forwarding profile in all security policies

Other possibilities:

  • Script that first gets all existing rules and you then set the log forwarding profile with a foreach-loop in all existing rules
  • Issue the cli command "set cli config-output-format set", go into config mode, show the security rulebase and include match statement like source zone. This will show you a list with your rules which you can copy to a text editor to replace all source zone parts with "log-setting LOGFORWADRINGPROFILENAME". And finally paste all these commands into the cli and commit

@Javith_Ali it's now up to you which way to go...

L7 Applicator

Re: Log forwarding profile in all security policies

This link might give you some hints.

In your case you need to get list of rules like @vsys_remo menioned and go from there.

https://live.paloaltonetworks.com/t5/General-Topics/Changing-Profiles-assigned-to-security-Rule/m-p/...

Enterprise Architect @ Cloud Carib www.cloudcarib.com
ACE (3.0, 5.0, 6.0, 7.0), PCNSE (6, 7), PCNSI
L0 Member

Re: Log forwarding profile in all security policies

Another option would be to dump config in "set format" to see the actual cli command. I suggest adding the log forward option to at least 1 policy so you have a reference cli command. Then you can sve this as a csv file. Then sort the relevant data and delete everything else. Then add the missing syntax. Then convert the csv back to text and paste as cli. But PAN script mode gets flaky if you paste more than 50 lines at a time. I wish they would fix that. This is why they like to merge portions of the xml file because script mode is unreliable for large pastes.

 

 

L2 Linker

Re: Log forwarding profile in all security policies

Haven't seen this answer yet so needed to reply..

 

Migration Tool!!!    (or Expedition as it's called now) 

 

This is one of the best things about the tool - batch rule changes.

 

Setting Security Profiles on all rules, Log Forwarding, etc

 

Connect the FW (or Panorama) to the Migration Tool, ingest policies, multi-rule edit, then API push the rules back to Firewall.

Validate policies.

 

Commit!

 

c

L0 Member

Re: Log forwarding profile in all security policies

the pan-c tool will also allow you to do this.

 

https://github.com/cpainchaud/pan-configurator

 

Use the rules-edit function to update all your rules with the new log profile.

 

L2 Linker

Re: Log forwarding profile in all security policies

FYI, if you name the profile "default" all new security rules will apply the profile automatically.  Same goes for security profile groups

Highlighted
L0 Member

Re: Log forwarding profile in all security policies

For big pastes to CLI, use a terminal emmulator, like Secure CRT, that allows you to add a 'pause' between lines. I've used a pause of 50ms to paste several hundred lines at a time.

Like what you see?

Show your appreciation!

Click Like if a post is helpful to you or if you just want to show your support.

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 Live Community as a whole!

The Live Community thanks you for your participation!