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

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...