Splunk Search

Need to search IP address in a list of IP/CIDR list and if matched need to return the Name associated with it.

sahastrabuddhe
Engager

I have a lookup table with 2 fields IP and Name

IP Name

['1.2.3.4', '2.3.5.0/24'] -> name1

['1.2.3.4',.6.7.8.9/31, 4.5.6.7,1.1.1.1] -> name2

[3.3.3.3/31, 4.4.4.4] -> name3

 

I have a list of IPs like "1.2.3.4, 2.3.5.1"

 

This should give me result of lookup table names where the IPs are present.

So in the above example result would be as the "1.2.3.4, 2.3.5.1" are present in first 2 rows.

name1

name2

 

Labels (1)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

Unless the lookup is defined with the CIDR, WILDCARD, or case-insensitive option, it will do exact string matching.  Even with those options, there is no way to get "1.2.3.4" to match "['1.2.3.4', '2.3.5.0/24']".  The multiple IP addresses in each line should be put on separate lines.

IPName
1.2.3.4name1
2.3.5.0/24name1
1.2.3.4name2
6.7.8.9/31name2
4.5.6.7name2
1.1.1.1name2
3.3.3.3/31name3
4.4.4.4name3

 

Note that the IP field is ambiguous because both name1 and name2 share an IP address.  The lookup command will return only the first matching IP.

---
If this reply helps you, Karma would be appreciated.

sahastrabuddhe
Engager

How should I format the lookup definition so that it takes both CIDR match and indivisual IP match
What I mean to say is if I go to advance settings and change the match criteria to CIDR(IP) its not matching the elements where the IP is single IP and not a CIDR 

0 Karma

richgalloway
SplunkTrust
SplunkTrust

I think you have to make all IP values CIDR (1.2.3.4/32, for example).

---
If this reply helps you, Karma would be appreciated.
0 Karma
Get Updates on the Splunk Community!

Feel the Splunk Love: Real Stories from Real Customers

Hello Splunk Community,    What’s the best part of hearing how our customers use Splunk? Easy: the positive ...

Data Management Digest – November 2025

  Welcome to the inaugural edition of Data Management Digest! As your trusted partner in data innovation, the ...

Splunk Mobile: Your Brand-New Home Screen

Meet Your New Mobile Hub  Hello Splunk Community!  Staying connected to your data—no matter where you are—is ...