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
Get Updates on the Splunk Community!

What the End of Support for Splunk Add-on Builder Means for You

Hello Splunk Community! We want to share an important update regarding the future of the Splunk Add-on Builder ...

Solve, Learn, Repeat: New Puzzle Channel Now Live

Welcome to the Splunk Puzzle PlaygroundIf you are anything like me, you love to solve problems, and what ...

Building Reliable Asset and Identity Frameworks in Splunk ES

 Accurate asset and identity resolution is the backbone of security operations. Without it, alerts are ...