<?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: Getting all Hosts(ip addresses) under a big group that has other groups inside it in Firewall and Security Management</title>
    <link>https://community.checkpoint.com/t5/Firewall-and-Security-Management/Getting-all-Hosts-ip-addresses-under-a-big-group-that-has-other/m-p/35566#M88052</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;First of all this is not a single API call but a series of API calls in iteration.&lt;/P&gt;&lt;P&gt;It would actually be recursive.&lt;/P&gt;&lt;P&gt;At a high level, you would query the relevant group for:&lt;/P&gt;&lt;P&gt;1. All the host objects&lt;/P&gt;&lt;P&gt;2. All the network objects (e.g. objects that represent subnets)—how do you want to handle these?&lt;/P&gt;&lt;P&gt;3. All the groups, which would be iterated and queried as was the original group.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You could probably do this with a bash script and jq.&lt;/P&gt;&lt;P&gt;If you take this approach, I would make sure you create a single read-only session and use that for all your queries.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 26 Feb 2019 03:18:58 GMT</pubDate>
    <dc:creator>PhoneBoy</dc:creator>
    <dc:date>2019-02-26T03:18:58Z</dc:date>
    <item>
      <title>Getting all Hosts(ip addresses) under a big group that has other groups inside it</title>
      <link>https://community.checkpoint.com/t5/Firewall-and-Security-Management/Getting-all-Hosts-ip-addresses-under-a-big-group-that-has-other/m-p/35565#M88051</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using R80.10, and need some help regarding getting ip addresses under a big group.&lt;/P&gt;&lt;P&gt;Lets say i have a big group that has few groups under it, and then those groups have other groups inside them, and so on and so on until i reach the objects (servers,computers, etc).&lt;/P&gt;&lt;P&gt;i want to get to a situation that i have all ip addresses that are under the big group.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does anyone know/ or did do such thing in the past?&lt;/P&gt;&lt;P&gt;Maybe some way in the API or SQL query through posgresql?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Feb 2019 13:54:20 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Firewall-and-Security-Management/Getting-all-Hosts-ip-addresses-under-a-big-group-that-has-other/m-p/35565#M88051</guid>
      <dc:creator>Network_Engine2</dc:creator>
      <dc:date>2019-02-25T13:54:20Z</dc:date>
    </item>
    <item>
      <title>Re: Getting all Hosts(ip addresses) under a big group that has other groups inside it</title>
      <link>https://community.checkpoint.com/t5/Firewall-and-Security-Management/Getting-all-Hosts-ip-addresses-under-a-big-group-that-has-other/m-p/35566#M88052</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;First of all this is not a single API call but a series of API calls in iteration.&lt;/P&gt;&lt;P&gt;It would actually be recursive.&lt;/P&gt;&lt;P&gt;At a high level, you would query the relevant group for:&lt;/P&gt;&lt;P&gt;1. All the host objects&lt;/P&gt;&lt;P&gt;2. All the network objects (e.g. objects that represent subnets)—how do you want to handle these?&lt;/P&gt;&lt;P&gt;3. All the groups, which would be iterated and queried as was the original group.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You could probably do this with a bash script and jq.&lt;/P&gt;&lt;P&gt;If you take this approach, I would make sure you create a single read-only session and use that for all your queries.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Feb 2019 03:18:58 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Firewall-and-Security-Management/Getting-all-Hosts-ip-addresses-under-a-big-group-that-has-other/m-p/35566#M88052</guid>
      <dc:creator>PhoneBoy</dc:creator>
      <dc:date>2019-02-26T03:18:58Z</dc:date>
    </item>
    <item>
      <title>Re: Getting all Hosts(ip addresses) under a big group that has other groups inside it</title>
      <link>https://community.checkpoint.com/t5/Firewall-and-Security-Management/Getting-all-Hosts-ip-addresses-under-a-big-group-that-has-other/m-p/35567#M88053</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yeah I agree what happened to this button that was part of the Group Object definition:&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.checkpoint.com/legacyfs/online/checkpoint/79414_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Feb 2019 14:41:27 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Firewall-and-Security-Management/Getting-all-Hosts-ip-addresses-under-a-big-group-that-has-other/m-p/35567#M88053</guid>
      <dc:creator>Maarten_Sjouw</dc:creator>
      <dc:date>2019-02-26T14:41:27Z</dc:date>
    </item>
    <item>
      <title>Re: Getting all Hosts(ip addresses) under a big group that has other groups inside it</title>
      <link>https://community.checkpoint.com/t5/Firewall-and-Security-Management/Getting-all-Hosts-ip-addresses-under-a-big-group-that-has-other/m-p/35568#M88054</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That sounds like a great idea.&lt;/P&gt;&lt;P&gt;i know it sounds a bit too much, but i'm very rusty on scripting and these kinda methods, is there any chance you'd give a little low level example of how it would look?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you so much&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Feb 2019 08:36:40 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Firewall-and-Security-Management/Getting-all-Hosts-ip-addresses-under-a-big-group-that-has-other/m-p/35568#M88054</guid>
      <dc:creator>Network_Engine2</dc:creator>
      <dc:date>2019-02-27T08:36:40Z</dc:date>
    </item>
    <item>
      <title>Re: Getting all Hosts(ip addresses) under a big group that has other groups inside it</title>
      <link>https://community.checkpoint.com/t5/Firewall-and-Security-Management/Getting-all-Hosts-ip-addresses-under-a-big-group-that-has-other/m-p/35569#M88055</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Actually, it turns out there's a single API command that should give you every IP covered by a group (including its various sub objects).&lt;/P&gt;&lt;P class=""&gt;&lt;STRONG&gt;&lt;SPAN class=""&gt;mgmt_cli --session-id $SID --format json show group name&amp;nbsp;group_name show-as-ranges true&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;STRONG&gt;&lt;SPAN class=""&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;This will break down all the objects into a range of IP addresses (with start/end ranges).&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;Not sure how far down the rabbit hole this goes (i.e. nesting levels), but&amp;nbsp;it does appear to go down a couple levels at least.&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;I tested as follows:&lt;/SPAN&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN class=""&gt;Created a group called test group as follows:&lt;/SPAN&gt;&lt;UL&gt;&lt;LI&gt;A few host objects&lt;/LI&gt;&lt;LI&gt;A group containing the following:&lt;UL&gt;&lt;LI&gt;A group containing&amp;nbsp;some network objects (including some IPv6 objects)&lt;/LI&gt;&lt;LI&gt;A single network (not host) object&lt;/LI&gt;&lt;LI&gt;A group containing a single host object&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;Ran the above command&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;The resulting output gave me:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;The ranges of all IPv4 addresses covered by the above&lt;/LI&gt;&lt;LI&gt;No IPv6 ranges were returned&lt;/LI&gt;&lt;LI&gt;An "other" section that included the IPv6 objects&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Feb 2019 17:05:26 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Firewall-and-Security-Management/Getting-all-Hosts-ip-addresses-under-a-big-group-that-has-other/m-p/35569#M88055</guid>
      <dc:creator>PhoneBoy</dc:creator>
      <dc:date>2019-02-27T17:05:26Z</dc:date>
    </item>
    <item>
      <title>Re: Getting all Hosts(ip addresses) under a big group that has other groups inside it</title>
      <link>https://community.checkpoint.com/t5/Firewall-and-Security-Management/Getting-all-Hosts-ip-addresses-under-a-big-group-that-has-other/m-p/35570#M88056</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you so much for the reply.&lt;/P&gt;&lt;P&gt;but the&amp;nbsp;&amp;nbsp;&lt;SPAN class="" style="border: 0px;"&gt;show-as-ranges true&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="" style="border: 0px;"&gt;&lt;STRONG&gt;doesn't seem to work because&amp;nbsp;the parameter isn't right..?&amp;nbsp;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN class="" style="border: 0px;"&gt;and i don't really understand what the session id part means .&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN class="" style="border: 0px;"&gt;Maybe you can explain about what the command does exactly? i know what the show group name does but thats it&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="border: 0px; font-weight: bold;"&gt;&lt;SPAN class="" style="border: 0px; font-weight: inherit;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Feb 2019 13:27:07 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Firewall-and-Security-Management/Getting-all-Hosts-ip-addresses-under-a-big-group-that-has-other/m-p/35570#M88056</guid>
      <dc:creator>Network_Engine2</dc:creator>
      <dc:date>2019-02-28T13:27:07Z</dc:date>
    </item>
    <item>
      <title>Re: Getting all Hosts(ip addresses) under a big group that has other groups inside it</title>
      <link>https://community.checkpoint.com/t5/Firewall-and-Security-Management/Getting-all-Hosts-ip-addresses-under-a-big-group-that-has-other/m-p/35571#M88057</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Keep in mind the CLI is just a wrapper for API calls.&lt;/P&gt;&lt;P&gt;In general, the flow is something like this:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Login, which gives you a session ID&lt;/LI&gt;&lt;LI&gt;Perform tasks&lt;/LI&gt;&lt;LI&gt;If edits/additions were made, then you must publish (or discard) those changes&lt;/LI&gt;&lt;LI&gt;Logout, which clears the session&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Other than the login, every call needs a session ID passed.&lt;/P&gt;&lt;P&gt;Or, if you're using the CLI from the Security Management server, you can avoid all that by using a -r true to the command instead &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://community.checkpoint.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To break down my command:&amp;nbsp;&lt;STRONG style="color: #333333; background-color: #ffffff; border: 0px; font-weight: bold; font-size: 14px;"&gt;&lt;SPAN class="" style="border: 0px; font-weight: inherit; font-size: 14px;"&gt;mgmt_cli --session-id $SID --format json show group name&amp;nbsp;group_name show-as-ranges true&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;--session-id $SID&lt;/STRONG&gt; says to use the session ID specified in the $SID shell variable (I had set this previously)&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;--format json&lt;/STRONG&gt; says to give JSON output&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;show group name group_name show-as-ranges true&lt;/STRONG&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;shows the group group_name with the output in ranges (show-as-ranges true).&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Unfortunately, that feature (show-as-ranges true) was added in API version 1.3, which corresponds to R80.20, not R80.10.&lt;/P&gt;&lt;P&gt;I should have checked that before providing you a solution, my apologies.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In any case, it's easy enough to get the members of a group using:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P class=""&gt;&lt;STRONG&gt;&lt;SPAN class=""&gt;mgmt_cli -r true --format json --version 1.1 show group name test-group details-level full&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN class=""&gt;That will output (in JSON) the list of all objects in a group.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;All groups are referred to by UID.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;To parse that and get all the IPv4 and IPv6 addresses in said group:&lt;/SPAN&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P class=""&gt;&lt;STRONG&gt;&lt;SPAN class=""&gt;mgmt_cli -r true --format json --version 1.1 show group name test-group details-level full | jq -r '.members[] | select(.type=="host") | [."ipv4-address", ."ipv6-address"] | @csv'&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Note this will be in the format IPv4 Address,IPv6 Address (an object can have both)&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;To get all the networks, we have to parse IPv4 and IPv6 networks and netmasks (output in this case is CSV format):&lt;/SPAN&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P class=""&gt;&lt;STRONG&gt;&lt;SPAN class=""&gt;mgmt_cli -r true --format json --version 1.1 show group name test-group details-level full | jq -r '.members[] | select(.type=="network") | [.subnet4, ."mask-length4", .subnet6, ."mask-length6"] | @csv'&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;To get all the uids of the groups contained in my group (the API does not return names, only UIDs in this case):&lt;/SPAN&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P class=""&gt;&lt;STRONG&gt;&lt;SPAN class=""&gt;mgmt_cli -r true --format json --version 1.1 show group name test-group details-level full | jq -r '.members[] | select(.type=="group") | .uid'&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;Now you can repeat the above using the group(s) identified except you use "uid whatever" instead of "name test-group".&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;Hopefully that's enough to help you get started.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Feb 2019 23:06:34 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Firewall-and-Security-Management/Getting-all-Hosts-ip-addresses-under-a-big-group-that-has-other/m-p/35571#M88057</guid>
      <dc:creator>PhoneBoy</dc:creator>
      <dc:date>2019-02-28T23:06:34Z</dc:date>
    </item>
    <item>
      <title>Re: Getting all Hosts(ip addresses) under a big group that has other groups inside it</title>
      <link>https://community.checkpoint.com/t5/Firewall-and-Security-Management/Getting-all-Hosts-ip-addresses-under-a-big-group-that-has-other/m-p/35572#M88058</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So now i need to do a script that involves these commands recursively?&amp;nbsp; can you give me a little example of how it would look?&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 03 Mar 2019 14:11:37 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Firewall-and-Security-Management/Getting-all-Hosts-ip-addresses-under-a-big-group-that-has-other/m-p/35572#M88058</guid>
      <dc:creator>Network_Engine2</dc:creator>
      <dc:date>2019-03-03T14:11:37Z</dc:date>
    </item>
    <item>
      <title>Re: Getting all Hosts(ip addresses) under a big group that has other groups inside it</title>
      <link>https://community.checkpoint.com/t5/Firewall-and-Security-Management/Getting-all-Hosts-ip-addresses-under-a-big-group-that-has-other/m-p/35573#M88059</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That's the basic idea, yes.&lt;/P&gt;&lt;P&gt;I would put the relevant commands into a function that calls itself.&lt;/P&gt;&lt;P&gt;I would also do this with a single session versus trying to do this with a bunch of -r true commands (it will improve efficiency).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are several scripting examples in &lt;A href="https://community.checkpoint.com/space/2003"&gt;Developers (Code Hub)&lt;/A&gt;‌ you could borrow from.&lt;/P&gt;&lt;P&gt;They don't necessarily cover this exact use case, but they do show how you can work with the API.&lt;/P&gt;&lt;P&gt;For example &lt;A href="https://community.checkpoint.com/docs/DOC-1911"&gt;CLI API Example for exporting, importing, and deleting different objects using CSV files (v 00.33.00 and later)&lt;/A&gt;‌&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Mar 2019 09:31:01 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Firewall-and-Security-Management/Getting-all-Hosts-ip-addresses-under-a-big-group-that-has-other/m-p/35573#M88059</guid>
      <dc:creator>PhoneBoy</dc:creator>
      <dc:date>2019-03-04T09:31:01Z</dc:date>
    </item>
    <item>
      <title>Re: Getting all Hosts(ip addresses) under a big group that has other groups inside it</title>
      <link>https://community.checkpoint.com/t5/Firewall-and-Security-Management/Getting-all-Hosts-ip-addresses-under-a-big-group-that-has-other/m-p/35574#M88060</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok, Thank you very much for everything.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Mar 2019 11:48:01 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Firewall-and-Security-Management/Getting-all-Hosts-ip-addresses-under-a-big-group-that-has-other/m-p/35574#M88060</guid>
      <dc:creator>Network_Engine2</dc:creator>
      <dc:date>2019-03-04T11:48:01Z</dc:date>
    </item>
  </channel>
</rss>

