Splunk Dev

How does cidrmatch work?

danielbb
Motivator

The following code -

| eval ipa="10.22.3.2" 
| eval ret=if(cidrmatch("10.0.0.0/8", ipa), "tr", "fl") 
| return ret

Returns -

alt text

Why is that?

Tags (1)
0 Karma
1 Solution

harsmarvania57
Ultra Champion

It is correct, because IP 10.22.3.2 belongs to CIDR Range 10.0.0.0/8 -> 10.0.0.0-10.255.255.255

View solution in original post

harsmarvania57
Ultra Champion

It is correct, because IP 10.22.3.2 belongs to CIDR Range 10.0.0.0/8 -> 10.0.0.0-10.255.255.255

danielbb
Motivator

Very kind @harsmarvania57 - please convert to an answer...

0 Karma

danielbb
Motivator

Ok,

by adding the makeresults

| makeresults
| eval ipa="10.22.3.2" 
| eval ret=if(cidrmatch("10.0.0.0/8", ipa), "tr", "fl")
| return ret

I get ret="tr".

Not sure whether ret="tr" is correct...

0 Karma
Get Updates on the Splunk Community!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...