Splunk Search

Lookup table with several IP ranges per row

pgomezji
Engager

Hi, I have a lookup table with IP ranges and locations. The problem is in the IP range column there can be several IP ranges separated by comma. How can match the client IP address with the right location?

Labels (1)
0 Karma
1 Solution

nickhills
Ultra Champion

To use a CIDR match you need each row in the lookup to have a single row per CIDR block.

So if your lookup has comma separated CIDR blocks you need to split these into rows.

You can either do this by manually splitting the data and adding rows, or you could use |inputlookup,  split the field, then mvexpand and re-write the (or create a new)  lookup.

 

 

| makeresults 
| eval cidr="192.168.1.0/24,192.168.30.0/24", location="London"
| table cidr location
| eval cidr=split(cidr,",")|mvexpand cidr

 

 

replace the first 3 lines with |inputlookup yourfile.csv
add at the end |outputlookup yourNewfile.csv to write a new file

| inputlookup yourfile.csv 
| eval cidr=split(cidr,",")|mvexpand cidr
| outputlookup yourNewfile.csv
If my comment helps, please give it a thumbs up!

View solution in original post

0 Karma

nickhills
Ultra Champion

To use a CIDR match you need each row in the lookup to have a single row per CIDR block.

So if your lookup has comma separated CIDR blocks you need to split these into rows.

You can either do this by manually splitting the data and adding rows, or you could use |inputlookup,  split the field, then mvexpand and re-write the (or create a new)  lookup.

 

 

| makeresults 
| eval cidr="192.168.1.0/24,192.168.30.0/24", location="London"
| table cidr location
| eval cidr=split(cidr,",")|mvexpand cidr

 

 

replace the first 3 lines with |inputlookup yourfile.csv
add at the end |outputlookup yourNewfile.csv to write a new file

| inputlookup yourfile.csv 
| eval cidr=split(cidr,",")|mvexpand cidr
| outputlookup yourNewfile.csv
If my comment helps, please give it a thumbs up!
0 Karma

pgomezji
Engager

Thanks, I was afraid of that answer.

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