<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to export firewall policies and NAT.csv in expert mode in API / CLI Discussion</title>
    <link>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-export-firewall-policies-and-NAT-csv-in-expert-mode/m-p/196860#M8149</link>
    <description>&lt;P&gt;Hi PhoneBoy,mgmt_cli Export policy The bar code has a maximum of 500 lines. What are the exported commands? What additional parameters do I need to add? I saw a python export policy on github, is this reliable? And you can export it in any format you want? For example, only the source IP address, destination IP address, vpn, port, action, and log parameters are exported. Other Uids do not need to be displayed.&lt;/P&gt;</description>
    <pubDate>Thu, 02 Nov 2023 02:32:46 GMT</pubDate>
    <dc:creator>Damon</dc:creator>
    <dc:date>2023-11-02T02:32:46Z</dc:date>
    <item>
      <title>How to export firewall policies and NAT.csv in expert mode</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-export-firewall-policies-and-NAT-csv-in-expert-mode/m-p/196775#M8138</link>
      <description>&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;This section describes how to export the firewall policy and nat rule policy to csv through the command line, or enter the policy in json format through the command.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2023 02:24:03 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-export-firewall-policies-and-NAT-csv-in-expert-mode/m-p/196775#M8138</guid>
      <dc:creator>Damon</dc:creator>
      <dc:date>2023-11-01T02:24:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to export firewall policies and NAT.csv in expert mode</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-export-firewall-policies-and-NAT-csv-in-expert-mode/m-p/196812#M8139</link>
      <description>&lt;P&gt;I would start with "mgmt_cli show packages"&lt;/P&gt;
&lt;P&gt;From there you can get/parse all policy names and run the following for every policy you like. If you have a unified policy package, the layer name is probably "network".&lt;/P&gt;
&lt;P&gt;mgmt_cli show access-rulebase name Network&amp;nbsp;package &amp;lt;policy_name&amp;gt;&lt;/P&gt;
&lt;P&gt;mgmt_cli show nat-rulebase package &amp;lt;policy_name&amp;gt;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2023 14:47:37 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-export-firewall-policies-and-NAT-csv-in-expert-mode/m-p/196812#M8139</guid>
      <dc:creator>Amir_Senn</dc:creator>
      <dc:date>2023-11-01T14:47:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to export firewall policies and NAT.csv in expert mode</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-export-firewall-policies-and-NAT-csv-in-expert-mode/m-p/196818#M8140</link>
      <description>&lt;P&gt;That would show it, but is there a flag to export it?&lt;/P&gt;
&lt;P&gt;Hope you are staying safe!&lt;/P&gt;
&lt;P&gt;Andy&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2023 16:26:09 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-export-firewall-policies-and-NAT-csv-in-expert-mode/m-p/196818#M8140</guid>
      <dc:creator>the_rock</dc:creator>
      <dc:date>2023-11-01T16:26:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to export firewall policies and NAT.csv in expert mode</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-export-firewall-policies-and-NAT-csv-in-expert-mode/m-p/196819#M8141</link>
      <description>&lt;P&gt;I think&amp;nbsp;&lt;EM&gt;web_api_show_package.sh&amp;nbsp;&lt;/EM&gt;under sk120342 is what you are looking for. Give it a shot, it has been really helpful in my case.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://support.checkpoint.com/results/sk/sk120342" target="_blank"&gt;https://support.checkpoint.com/results/sk/sk120342&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2023 16:40:48 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-export-firewall-policies-and-NAT-csv-in-expert-mode/m-p/196819#M8141</guid>
      <dc:creator>Zolocofxp</dc:creator>
      <dc:date>2023-11-01T16:40:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to export firewall policies and NAT.csv in expert mode</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-export-firewall-policies-and-NAT-csv-in-expert-mode/m-p/196820#M8142</link>
      <description>&lt;P&gt;I usually echo the response into a file and then it's easier for me. I haven't tried the tool from the sk&amp;nbsp;&lt;a href="https://community.checkpoint.com/t5/user/viewprofilepage/user-id/28648"&gt;@Zolocofxp&lt;/a&gt;&amp;nbsp;mentioned, if it works well it will be more presentable and worth a shot.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Trying to stay safe, thank you very much for your concern.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2023 16:48:35 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-export-firewall-policies-and-NAT-csv-in-expert-mode/m-p/196820#M8142</guid>
      <dc:creator>Amir_Senn</dc:creator>
      <dc:date>2023-11-01T16:48:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to export firewall policies and NAT.csv in expert mode</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-export-firewall-policies-and-NAT-csv-in-expert-mode/m-p/196821#M8143</link>
      <description>&lt;P&gt;That is true, BUT, I dont think it exports it into csv format, at least not that I can recall.&lt;/P&gt;
&lt;P&gt;Andy&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2023 16:55:46 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-export-firewall-policies-and-NAT-csv-in-expert-mode/m-p/196821#M8143</guid>
      <dc:creator>the_rock</dc:creator>
      <dc:date>2023-11-01T16:55:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to export firewall policies and NAT.csv in expert mode</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-export-firewall-policies-and-NAT-csv-in-expert-mode/m-p/196822#M8144</link>
      <description>&lt;P&gt;True, that tool is good, agree! I pray for peace man no matter who it is or what nation. I lived in war myself (Hell, probably better word to use), so I know exactly how it is...sadly, ALWAYS innocent people pay the price.&lt;/P&gt;
&lt;P&gt;Andy&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2023 16:58:08 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-export-firewall-policies-and-NAT-csv-in-expert-mode/m-p/196822#M8144</guid>
      <dc:creator>the_rock</dc:creator>
      <dc:date>2023-11-01T16:58:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to export firewall policies and NAT.csv in expert mode</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-export-firewall-policies-and-NAT-csv-in-expert-mode/m-p/196823#M8145</link>
      <description>&lt;P&gt;In general, you'd use the output of a series of mgmt_cli commands piped through jq, which can output in CSV.&lt;BR /&gt;Note that NAT rules will not include "automatic NAT" rules that are created as these are configured in the relevant object.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2023 17:56:24 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-export-firewall-policies-and-NAT-csv-in-expert-mode/m-p/196823#M8145</guid>
      <dc:creator>PhoneBoy</dc:creator>
      <dc:date>2023-11-01T17:56:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to export firewall policies and NAT.csv in expert mode</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-export-firewall-policies-and-NAT-csv-in-expert-mode/m-p/196854#M8147</link>
      <description>&lt;P&gt;Hello, Amir_Senn, using mgmt_cli export has bar code restrictions, the policy can only display 20 items at a time, can you specify the main information such as source address, destination address, and port in a table?&lt;/P&gt;</description>
      <pubDate>Thu, 02 Nov 2023 02:16:10 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-export-firewall-policies-and-NAT-csv-in-expert-mode/m-p/196854#M8147</guid>
      <dc:creator>Damon</dc:creator>
      <dc:date>2023-11-02T02:16:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to export firewall policies and NAT.csv in expert mode</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-export-firewall-policies-and-NAT-csv-in-expert-mode/m-p/196859#M8148</link>
      <description>&lt;P&gt;Hi,@Zolocofxp,this sk has seen, is it necessary to export the policy file through python? I performed the configuration according to the requirements of sk, but the log content was empty and the path of the exported file was not found.&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1.png" style="width: 999px;"&gt;&lt;img src="https://community.checkpoint.com/t5/image/serverpage/image-id/23025i37058025D40E0032/image-size/large?v=v2&amp;amp;px=999" role="button" title="1.png" alt="1.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2.png" style="width: 999px;"&gt;&lt;img src="https://community.checkpoint.com/t5/image/serverpage/image-id/23026iF074FD6B337E0136/image-size/large?v=v2&amp;amp;px=999" role="button" title="2.png" alt="2.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Nov 2023 02:28:38 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-export-firewall-policies-and-NAT-csv-in-expert-mode/m-p/196859#M8148</guid>
      <dc:creator>Damon</dc:creator>
      <dc:date>2023-11-02T02:28:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to export firewall policies and NAT.csv in expert mode</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-export-firewall-policies-and-NAT-csv-in-expert-mode/m-p/196860#M8149</link>
      <description>&lt;P&gt;Hi PhoneBoy,mgmt_cli Export policy The bar code has a maximum of 500 lines. What are the exported commands? What additional parameters do I need to add? I saw a python export policy on github, is this reliable? And you can export it in any format you want? For example, only the source IP address, destination IP address, vpn, port, action, and log parameters are exported. Other Uids do not need to be displayed.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Nov 2023 02:32:46 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-export-firewall-policies-and-NAT-csv-in-expert-mode/m-p/196860#M8149</guid>
      <dc:creator>Damon</dc:creator>
      <dc:date>2023-11-02T02:32:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to export firewall policies and NAT.csv in expert mode</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-export-firewall-policies-and-NAT-csv-in-expert-mode/m-p/196942#M8150</link>
      <description>&lt;P&gt;Sorry, I don't understand which 20 items you're talking about, can you elaborate?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BTW, I made a one-liner that goes over the DB and takes all the policy packages and export access control RB + NAT RB for each and saves them as text file in json format. Still needs work but maybe you can use it. Not suitable for MDS at the moment.&lt;/P&gt;
&lt;P&gt;mgmt_cli show packages -r true | grep "name" &amp;gt; Senn_temp.txt ; cat Senn_temp.txt | cut -d':' -f2- &amp;gt; Senn_temp0.txt ; Lines=$(cat Senn_temp0.txt | wc -l) ; for (( N=0; $N&amp;lt;$Lines; N=(($N+2)))); { current=$(head -1 Senn_temp$N.txt); current=${current::-2}; current=${current:2}; echo $current &amp;gt;&amp;gt; policies0.txt; cat Senn_temp0.txt | tail -$(($Lines-$N-2)) &amp;gt; Senn_temp$(($N+2)).txt; } ; rm Senn_temp* ; Lines=$(cat policies0.txt | wc -l) ; for (( N=0; $N&amp;lt;$Lines; N=(($N+1)))); { current_policy=$(head -1 policies$N.txt); current_layer=$(mgmt_cli show package -r true name $current_policy | grep -A2 access-layers: | grep name* | cut -c8-); current_layer=${current_layer::-2}; current_layer=${current_layer:2}; current_name="${current_layer// /_}"; mgmt_cli show access-rulebase name "$current_layer" limit 500 -r true --format json &amp;gt; $current_name.txt; mgmt_cli show nat-rulebase package "$current_policy" limit 500 -r true --format json &amp;gt; NAT_$current_name.txt; cat policies$N.txt | tail -$(($Lines-$N-1)) &amp;gt; policies$(($N+1)).txt; } ; rm policies* ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Nov 2023 16:59:10 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-export-firewall-policies-and-NAT-csv-in-expert-mode/m-p/196942#M8150</guid>
      <dc:creator>Amir_Senn</dc:creator>
      <dc:date>2023-11-02T16:59:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to export firewall policies and NAT.csv in expert mode</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-export-firewall-policies-and-NAT-csv-in-expert-mode/m-p/196947#M8151</link>
      <description>&lt;P&gt;Hey Amir,&lt;/P&gt;
&lt;P&gt;Just tested this in my lab and got below. PLEASE keep staying safe.&lt;/P&gt;
&lt;P&gt;Andy&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;[Expert@CP-management:0]# mgmt_cli show packages -r true | grep "LAB-POLICY" &amp;gt; Senn_temp.txt ; cat Senn_temp.txt | cut -d':' -f2- &amp;gt; Senn_temp0.txt ; Lines=$(cat Senn_temp0.txt | wc -l) ; for (( N=0; $N&amp;lt;$Lines; N=(($N+2)))); { current=$(head -1 Senn_temp$N.txt); current=${current::-2}; current=${current:2}; echo $current &amp;gt;&amp;gt; policies0.txt; cat Senn_temp0.txt | tail -$(($Lines-$N-2)) &amp;gt; Senn_temp$(($N+2)).txt; } ; rm Senn_temp* ; Lines=$(cat policies0.txt | wc -l) ; for (( N=0; $N&amp;lt;$Lines; N=(($N+1)))); { current_policy=$(head -1 policies$N.txt); current_layer=$(mgmt_cli show package -r true name $current_policy | grep -A2 access-layers: | grep name* | cut -c8-); current_layer=${current_layer::-2}; current_layer=${current_layer:2}; current_name="${current_layer// /_}"; mgmt_cli show access-rulebase name "$current_layer" limit 500 -r true --format json &amp;gt; $current_name.txt; mgmt_cli show nat-rulebase package "$current_policy" limit 500 -r true --format json &amp;gt; NAT_$current_name.txt; cat policies$N.txt | tail -$(($Lines-$N-1)) &amp;gt; policies$(($N+1)).txt; } ; rm policies* ;&lt;BR /&gt;tail: unrecognized option '--1'&lt;BR /&gt;Try 'tail --help' for more information.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Nov 2023 17:34:45 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-export-firewall-policies-and-NAT-csv-in-expert-mode/m-p/196947#M8151</guid>
      <dc:creator>the_rock</dc:creator>
      <dc:date>2023-11-02T17:34:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to export firewall policies and NAT.csv in expert mode</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-export-firewall-policies-and-NAT-csv-in-expert-mode/m-p/196948#M8152</link>
      <description>&lt;P&gt;Nm, disregard my last command, layer 8 issue lol&lt;/P&gt;
&lt;P&gt;Just ran same command without changing anything and it did produce 2 files, one for network, one for nat...looks good!&lt;/P&gt;
&lt;P&gt;Kind regards,&lt;/P&gt;
&lt;P&gt;Andy&lt;/P&gt;</description>
      <pubDate>Thu, 02 Nov 2023 17:36:20 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-export-firewall-policies-and-NAT-csv-in-expert-mode/m-p/196948#M8152</guid>
      <dc:creator>the_rock</dc:creator>
      <dc:date>2023-11-02T17:36:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to export firewall policies and NAT.csv in expert mode</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-export-firewall-policies-and-NAT-csv-in-expert-mode/m-p/196952#M8153</link>
      <description>&lt;P&gt;To be clear, there is no single command that will dump a large rulebase and/or object database.&lt;BR /&gt;The API limits the number of results returned by design to keep the service performant.&lt;BR /&gt;This means you will have to make multiple API calls with the offset parameter (offset 500, offset 1000, etc) to get the next set of results.&lt;BR /&gt;You can pipe the output of mgmt_cli to jq in order to get exactly the fields you want in the exact format you want.&lt;/P&gt;
&lt;P&gt;This tool, although not formally supported, is produced by Check Point R&amp;amp;D:&amp;nbsp;&lt;A href="https://community.checkpoint.com/t5/API-CLI-Discussion/Python-tool-for-exporting-importing-a-policy-package-or-parts-of/m-p/41100#M2829" target="_blank" rel="noopener"&gt;https://community.checkpoint.com/t5/API-CLI-Discussion/Python-tool-for-exporting-importing-a-policy-package-or-parts-of/m-p/41100#M2829&lt;/A&gt;&amp;nbsp;&lt;BR /&gt;Another tool, produced by one of our SEs, exports to/imports from CSV:&amp;nbsp;&lt;A href="https://community.checkpoint.com/t5/API-CLI-Discussion/CLI-API-Example-for-exporting-importing-and-deleting-different/m-p/40850#M2766" target="_blank" rel="noopener"&gt;https://community.checkpoint.com/t5/API-CLI-Discussion/CLI-API-Example-for-exporting-importing-and-deleting-different/m-p/40850#M2766&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Having said all of that, SmartConsole can export the current rulebase in CSV from here:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 999px;"&gt;&lt;img src="https://community.checkpoint.com/t5/image/serverpage/image-id/23034iA1B4335F037B3719/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The NAT rulebase can be exported similarly.&lt;BR /&gt;Note that you can not import rules directly from CSV.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Nov 2023 17:58:21 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-export-firewall-policies-and-NAT-csv-in-expert-mode/m-p/196952#M8153</guid>
      <dc:creator>PhoneBoy</dc:creator>
      <dc:date>2023-11-02T17:58:21Z</dc:date>
    </item>
  </channel>
</rss>

