Splunk Search

How to normalize the IPs in lookup table which is in CIDR notation ?

AL3Z
Builder

IPs in lookup table

3.124.56/32

64.37.99.0/24

55.63.24.7/16

 How to edit my search to Exclude  an IPs  from outside to a Subnet IP in a lookup file?

Labels (1)
0 Karma

scelikok
SplunkTrust
SplunkTrust

Hi @AL3Z,

You can easily use inputlookup command. Assuming your subnets is in subnets.csv lookup with ip field.  And your events are in src_ip field.

| search [|inputlookup subnets.csv | rename ip as src_ip]

 

If this reply helps you an upvote and "Accept as Solution" is appreciated.
0 Karma

starcher
Influencer

Follow the Splunk docs to setup your lookup with a lookup definition and match type of CIDR for that column.

https://docs.splunk.com/Documentation/Splunk/9.0.2/Knowledge/Usefieldlookupstoaddinformationtoyourev...

Then use the lookup as a lookup. The pattern is usually like the below to filter where in the lookup,

MYSEARCH
| lookup mylookup src OUTPUTNEW src as toFilter
| where isnotnull(toFilter)

  

yuanliu
SplunkTrust
SplunkTrust

To add to @starcher's instructions, I recently made this screenshot to help another question; the only difference is file name.

lookup-cidr.pngAs shown here, you need to check "Advanced options" in order to set up CIDR match type.

As you are looking for non-matching entries, your filter should be isnull as opposed to isnotnull.

MYSEARCH
| lookup mylookup src OUTPUTNEW src as toFilter
| where isnull(toFilter)

 

0 Karma

AL3Z
Builder
0 Karma
Get Updates on the Splunk Community!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Get the T-shirt to Prove You Survived Splunk University Bootcamp

As if Splunk University, in Las Vegas, in-person, with three days of bootcamps and labs weren’t enough, now ...

Wondering How to Build Resiliency in the Cloud?

IT leaders are choosing Splunk Cloud as an ideal cloud transformation platform to drive business resilience,  ...