<?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 Find security gateways IPs through CLI on SMS in API / CLI Discussion</title>
    <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Find-security-gateways-IPs-through-CLI-on-SMS/m-p/185735#M7827</link>
    <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am wondering if there is a way to find the IP address of every single security gateway connected to it through a CLI command and store them in variables? I am trying to automate some tasks with bash scripts!&lt;BR /&gt;&lt;BR /&gt;I tried this, but it didn't give me any IPs at all.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;mgmt_cli -r true -f json show gateways-and-servers | jq -r '.objects[] | select(.type == "CpmiGateway") | .ipv4-address'&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;Thank you,&lt;/P&gt;</description>
    <pubDate>Thu, 06 Jul 2023 04:41:53 GMT</pubDate>
    <dc:creator>Diyaa3791</dc:creator>
    <dc:date>2023-07-06T04:41:53Z</dc:date>
    <item>
      <title>Find security gateways IPs through CLI on SMS</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Find-security-gateways-IPs-through-CLI-on-SMS/m-p/185735#M7827</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am wondering if there is a way to find the IP address of every single security gateway connected to it through a CLI command and store them in variables? I am trying to automate some tasks with bash scripts!&lt;BR /&gt;&lt;BR /&gt;I tried this, but it didn't give me any IPs at all.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;mgmt_cli -r true -f json show gateways-and-servers | jq -r '.objects[] | select(.type == "CpmiGateway") | .ipv4-address'&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;Thank you,&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jul 2023 04:41:53 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Find-security-gateways-IPs-through-CLI-on-SMS/m-p/185735#M7827</guid>
      <dc:creator>Diyaa3791</dc:creator>
      <dc:date>2023-07-06T04:41:53Z</dc:date>
    </item>
    <item>
      <title>Re: Find security gateways IPs through CLI on SMS</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Find-security-gateways-IPs-through-CLI-on-SMS/m-p/185741#M7828</link>
      <description>&lt;P&gt;You would also need the to see full details output by adding:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;-details-level full&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Based on this output modify your command&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jul 2023 06:52:22 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Find-security-gateways-IPs-through-CLI-on-SMS/m-p/185741#M7828</guid>
      <dc:creator>Tal_Paz-Fridman</dc:creator>
      <dc:date>2023-07-06T06:52:22Z</dc:date>
    </item>
    <item>
      <title>Re: Find security gateways IPs through CLI on SMS</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Find-security-gateways-IPs-through-CLI-on-SMS/m-p/185817#M7829</link>
      <description>&lt;P&gt;You may want to check out &lt;A href="https://community.checkpoint.com/t5/Scripts/GAIA-Easy-execute-CLI-commands-on-all-gateways-simultaneously/m-p/50883#M385" target="_self"&gt;a similar script&lt;/A&gt; posted to our Toolbox.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jul 2023 15:37:08 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Find-security-gateways-IPs-through-CLI-on-SMS/m-p/185817#M7829</guid>
      <dc:creator>PhoneBoy</dc:creator>
      <dc:date>2023-07-06T15:37:08Z</dc:date>
    </item>
    <item>
      <title>Re: Find security gateways IPs through CLI on SMS</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Find-security-gateways-IPs-through-CLI-on-SMS/m-p/192298#M8033</link>
      <description>&lt;P&gt;Hello PhoneBoy,&lt;/P&gt;&lt;P&gt;Thank you for your help and I am very sorry for my late reply. I did find a command from the script you referenced.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;more $FWDIR/conf/objects.C |grep -A 500 -B 1  ':type (gateway)'| sed -n '/gateway/,/:ipaddr (/p' | grep 'ipaddr (' | sed 's/^[ \t]*//' | sed 's/\:ipaddr (//' |sed 's/)//'&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Sep 2023 19:20:58 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Find-security-gateways-IPs-through-CLI-on-SMS/m-p/192298#M8033</guid>
      <dc:creator>Diyaa3791</dc:creator>
      <dc:date>2023-09-11T19:20:58Z</dc:date>
    </item>
    <item>
      <title>Re: Find security gateways IPs through CLI on SMS</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Find-security-gateways-IPs-through-CLI-on-SMS/m-p/192299#M8034</link>
      <description>&lt;P&gt;Thank you for your reply.&lt;BR /&gt;&lt;BR /&gt;This didn't work, but I found another command that is simpler than this.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Sep 2023 19:23:00 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Find-security-gateways-IPs-through-CLI-on-SMS/m-p/192299#M8034</guid>
      <dc:creator>Diyaa3791</dc:creator>
      <dc:date>2023-09-11T19:23:00Z</dc:date>
    </item>
    <item>
      <title>Re: Find security gateways IPs through CLI on SMS</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Find-security-gateways-IPs-through-CLI-on-SMS/m-p/192307#M8038</link>
      <description>&lt;P&gt;Note that a grep through objects.C mostly works, but sometimes fails in really bizarre and inscrutable ways. For example, it could catch an IP address from some other object. I would recommend instead 'mgmt_cli -f json -r true show gateways-and-servers limit 500 details-level full' like how you started, then filtering down based on the types of gateway you want. For example, to run things on physical members (e.g, a version check), you want to discard the cluster objects:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;portNumber=$(api status | grep "APACHE Gaia Port" | awk '{print $NF}')
mgmt_cli -f json \
--port "${portNumber}" \
-d "${cmaAddress}" \
-r true \
show gateways-and-servers \
limit 500 \
details-level full \
| jq -c '.objects[]|{name:.name,type:.type,address:."ipv4-address"}' \
| grep -v CpmiGatewayCluster \
| grep -v CpmiVsClusterNetobj \
| grep -v CpmiVsxClusterNetobj \
| grep -v "checkpoint-host"&lt;/LI-CODE&gt;
&lt;P&gt;cmaAddress should be the IP of the CMA you want to check in a multi-domain environment. With a single management server, you can just leave it unset and the script as written above should still work. Note that since each cluster member and each VS consumes an item slot, 500 items only covers a max of 166 two-member clusters. If you have over 500 items in the management domain, you'll have to run it multiple times with an offset to get all of the items.&lt;/P&gt;
&lt;P&gt;Tweak the 'grep -v' lines as needed. Once you have it down to just the items you want, pipe it through a final&amp;nbsp;jq -c '.address' and you have a list of only the addresses, one per line. Perfect for xargs.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Sep 2023 20:00:26 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Find-security-gateways-IPs-through-CLI-on-SMS/m-p/192307#M8038</guid>
      <dc:creator>Bob_Zimmerman</dc:creator>
      <dc:date>2023-09-11T20:00:26Z</dc:date>
    </item>
    <item>
      <title>Re: Find security gateways IPs through CLI on SMS</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Find-security-gateways-IPs-through-CLI-on-SMS/m-p/192319#M8041</link>
      <description>&lt;P&gt;I do remember getting a value of "&lt;SPAN&gt;(NULL BUF)" when trying to get the hostname of a gateway using&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;G_HostName=$(cprid_util -timeout 5 -server ${G_address} -verbose rexec -rcmd clish -c "show hostname")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;My work around was to check if the returned hostname of an IP fetched from objects.C is&amp;nbsp;"&lt;SPAN&gt;(NULL BUF)". I would skip that IP.&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;if [ "${G_HostName}" != "(NULL BUF)" ]; then
   # logging
   log 'info' "Backing up the configuration of Gateway: ${G_HostName} - ${G_address}"
   # backup the configuration of each gateway into a file while iterating through the loop
   cprid_util -server ${G_address} -verbose rexec -rcmd clish -c "show configuration" &amp;gt; "${BACKUP_DIR}/${G_HostName}_${G_address}_${CP_TIME}.clish"
   # logging
   log 'info' "Backup of ${G_HostName} - ${G_address} is completed."
else
   log 'info' "The following gateway didn't backup: ${G_address} - This could be because it has an invalid gateway object."
fi&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Sep 2023 21:15:15 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Find-security-gateways-IPs-through-CLI-on-SMS/m-p/192319#M8041</guid>
      <dc:creator>Diyaa3791</dc:creator>
      <dc:date>2023-09-11T21:15:15Z</dc:date>
    </item>
    <item>
      <title>Re: Find security gateways IPs through CLI on SMS</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Find-security-gateways-IPs-through-CLI-on-SMS/m-p/192332#M8043</link>
      <description>&lt;P&gt;So that's also not necessarily a safe assumption. "(NULL BUF)" just means CPRID isn't working from the management to that IP. It doesn't necessarily mean the IP is wrong. Maybe there's some issue between them, like a firewall from another vendor which isn't configured to allow CPRID.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Sep 2023 21:41:05 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Find-security-gateways-IPs-through-CLI-on-SMS/m-p/192332#M8043</guid>
      <dc:creator>Bob_Zimmerman</dc:creator>
      <dc:date>2023-09-11T21:41:05Z</dc:date>
    </item>
  </channel>
</rss>

