Create a Post
cancel
Showing results for 
Search instead for 
Did you mean: 
Bärbel
Participant

Show hosts filtered on ipv4-address

I want to use the API to query if there are network objects having a specific ipv4-address. Is there really no way except using a filter which would also return objects if the ipv4-address is in other fields like comment, name etc.?

R82 Smart Management

0 Kudos
3 Replies
Alex-
MVP Silver
MVP Silver

There's an example in the API documentation: https://sc1.checkpoint.com/documents/latest/APIs/#tips_best_practices~v2.1%20

Quickly with mgmt_cli:

mgmt_cli -r true show hosts details-level full -f json | jq -r '.objects[] | select(."ipv4-address" == "224.0.0.2")| [.name, .uid , ."ipv4-address"] |@csv'
"routers_multicast","<removed>","224.0.0.2"

 

ipv4-address is an explicit field. Easily reproducible with other languages.

Vincent_Bacher
MVP Silver
MVP Silver

In addition, example of an host

{
    "uid" : "94a3f624-48f2-4630-97cd-4468c7ca5af8",
    "name" : "host_2",
    "type" : "host",
    "domain" : {
      "uid" : "a59b701f-79dd-49dd-b054-f3c92af4b608",
      "name" : "dom82",
      "domain-type" : "domain"
    },
    "icon" : "Objects/host",
    "color" : "black",
    "ipv4-address" : "43.77.34.4"
  }

Unfortunately searching for a field like ipv4-address is not possible.

and now to something completely different - CCVS, CCAS, CCTE, CCCS, CCSM elite
0 Kudos
Vincent_Bacher
MVP Silver
MVP Silver

P.S.: I would use filter in the search to reduce the results and then do the jq and select stuff

mgmt_cli -r true show hosts filter "10.0.1.5" details-level full -f json | \
  jq -r '.objects[] | select(."ipv4-address" == "10.0.1.5") | [.name, .uid, ."ipv4-address"] | @csv'
and now to something completely different - CCVS, CCAS, CCTE, CCCS, CCSM elite
0 Kudos

Leaderboard

Epsum factorial non deposit quid pro quo hic escorol.

Upcoming Events

    CheckMates Events