Splunk Search

How do you use a lookup file to restrict unwanted IP addresses?

as0813
New Member

Use case description: I have a set of IP address that I would like to restrict across all requires, saved searches/alert/report/dashboards.

Currently I am using NOT IP IN (ip1, ip2...) condition in searches. But this creates an overhead if I have to make changes like adding a new IP address; I will have to add in multiple places.

Also, please suggest another easier way to implement if there are any that do not require a Splunk instance restart.

0 Karma
1 Solution

Vijeta
Influencer

You can create in eventtype from Settings->Eventtype and assign it equal to NOT IP IN(Ip1,IP2,....).

Later in your searches and dashboards you can use eventtype rather than the NOT IP in,this way you need to update only at one place i.e. your eventtype definition.

For adding eventtype toyour search you can refer this thread -
https://answers.splunk.com/answers/302235/how-do-i-add-an-eventtype-to-my-search.html

View solution in original post

0 Karma

woodcock
Esteemed Legend

You need to create a tag called something like restricted for each ip=value pair. Then when you need to add or remove an ip, you just change the single tag setting. Now, to add it to all searches, you can either modify each search to add NOT tag=restricted (which is better) OR, if you are really in a hurry to get this done, you can add it to Settings -> Access controls -> Roles -> edit the one that applies to your users or create a new one -> Restrict search terms and add it there.

0 Karma

ddrillic
Ultra Champion

Instead of the NOT IP IN (ip1, ip2...) construct, you can use something like index=<your index> NOT [ | inputlookup unwantedIPs.csv ]. It should work if you have a common field in the index and in the inputlookup, such as IPaddress.

For this point on you can maintain the lookup table and no Splunk restart is needed.

0 Karma

Vijeta
Influencer

You can create in eventtype from Settings->Eventtype and assign it equal to NOT IP IN(Ip1,IP2,....).

Later in your searches and dashboards you can use eventtype rather than the NOT IP in,this way you need to update only at one place i.e. your eventtype definition.

For adding eventtype toyour search you can refer this thread -
https://answers.splunk.com/answers/302235/how-do-i-add-an-eventtype-to-my-search.html

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

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...