Splunk Search

How to check CIDR overlaps

yko84109
Loves-to-Learn

I have lookup with CIDR advanced field which contains:

 

id    cidr_field

1     1.1.1.1/24

2      8.8.8.8/24

 

 

If I search for single if in the range, i.e:

 

| makeresults | eval ip="8.8.8.1"
| lookup mylookup cidr_field as ip OUTPUT id

 

 

It's worked currently, But If I'm tried to search for CIDR it does not return any result:

 

| makeresults | eval ip="8.8.8.8/28"
| lookup mylookup cidr_field as ip OUTPUT id

 

 

So how can I search for CIDR in another CIDR?

Labels (1)
0 Karma

PickleRick
SplunkTrust
SplunkTrust

Do you want to find overlaps or containment?

Because for simple check whether 1.2.3.4/28 is within a 1.2.0.0/16 range you can just drop the mask from the first IP (as long as it's a valid range and the mask is longer).

And what result would you expect in your comparison of - for example 1.0.0.0/8 versus 1.0.2.0/24? Is 1.0.0.0/8 according to your semantics "in" 1.0.2.0/24 or not?

0 Karma

yko84109
Loves-to-Learn

Hi,

I want to check if CIDR exist in another CIDR

0 Karma

PickleRick
SplunkTrust
SplunkTrust

Well... you can't really account easily for the cases when the range you want to check is "wider" than the one you have in the lookup.

If your lookup matches the CIDR ranges to unique identifiers, you can try to calculate the "beginning" and "end" of the checked range (possibly using https://splunkbase.splunk.com/app/3490/ to help) and check if both ends are getting looked up into the same value.

Not a pretty solution, but should work.

Otherwise, you cannot easily detect situations in which you're checking, for example 10.0.0.0/8 against 10.0.0.0/24. Normally the iplookup only checks for a single IP.

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 ...