Splunk Search

… | where like(src, “10.9.165.%”) OR cidrmatch(“10.9.165.0/25”, dst) What will this search return as a result?

rashokciet
New Member

… | where like(src, “10.9.165.%”) OR cidrmatch(“10.9.165.0/25”, dst)

What will this search return as a result?

Any help is appreciated..!

0 Karma
1 Solution

ngatchasandra
Builder

Hi,

I think that It return events that match the IP or is in the specified subnet.

This because:

  • the like(x,y) funtion This function takes two arguments, a field X and a quoted string Y, and
    returns TRUE if and only if the first argument is like the SQLite pattern in y

  • the cidrmacth(x,y) function identifies IP addresses that belong to a particular subnet. The function uses two arguments: the first is the CIDR subnet, is contained in quotes; the second is the IP address to match, which may be values in field.

View solution in original post

0 Karma

esix_splunk
Splunk Employee
Splunk Employee

By syntax, CIDRMATCH("10.9.165.0/25",dst) will return 10.9.165 - 166. 1 - 254.

Whereas.. WHERE like(src,"10.9.165.%") will only return any src that is 10.9.165.x.

0 Karma

Runals
Motivator

Actually cidermatch("10.9.165.0/25", dst) will return values between 10.9.165.0 - 10.9.165.127
where like(src, "10.9.165.%") will return values that simply start with "10.9.165." and while one might assume validation has already been done to the data in "src" it will match 0-255 but also any string of characters

ngatchasandra
Builder

Hi,

I think that It return events that match the IP or is in the specified subnet.

This because:

  • the like(x,y) funtion This function takes two arguments, a field X and a quoted string Y, and
    returns TRUE if and only if the first argument is like the SQLite pattern in y

  • the cidrmacth(x,y) function identifies IP addresses that belong to a particular subnet. The function uses two arguments: the first is the CIDR subnet, is contained in quotes; the second is the IP address to match, which may be values in field.

0 Karma

rashokciet
New Member

Could you please explain how it works??

Thanks for the help in advance

0 Karma

ngatchasandra
Builder

Yes!

This because:

  • the like(x,y) funtion This function takes two arguments, a field X and a quoted string Y, and returns TRUE if and only if the first argument is like the SQLite pattern in y

  • the cidrmacth(x,y) function identifies IP addresses that belong to a particular subnet. The function uses two arguments: the first is the CIDR subnet, is contained in quotes; the second is the IP address to match, which may be values in field.

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...

Data Persistence in the OpenTelemetry Collector

This blog post is part of an ongoing series on OpenTelemetry. What happens if the OpenTelemetry collector ...

Thanks for the Memories! Splunk University, .conf25, and our Community

Thank you to everyone in the Splunk Community who joined us for .conf25, which kicked off with our iconic ...