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
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...

Step into “Hunt the Insider: An Splunk ES Premier Mystery” to catch a cybercriminal ...

After a whole week of being on call, you fell asleep on your keyboard, and you hit a sequence of buttons that ...