Splunk Search

How to remove overlapping address ranges from a field of address ranges?

cofisher
New Member

I have a field of address ranges where i want to dedup any that overlap. For example:
10.10.20.0/23
10.10.20.160/27
10.10.20.192/26
10.10.20.64/26
10.10.21.0/26
The first range, 10.10.20.0/23, contains all the other list of ranges so I want to get rid of all the other ranges, 10.10.20.160/27, 10.10.20.192/26, 10.10.20.64/26, 10.10.21.0/26.

Tags (2)
0 Karma

bsinkk
New Member

Yes, I know I am posting to an old thread.

Use case 1:
I have an ACL that has multiple lines that may contain overlaps and I want to streamline the list.

Use case 2:
I have two tools.

The first tool allows overlapping ranges and and determines meta data by the most restrictive.
example..
10.10.0.0/22 Production
10.10.1.0/24 Production_webservers

if the address is 10.10.0.10, it will use the meta of Production. Easy...

Tool two doesn't like the overlap, so the same list would have to be split into multiples with no overlap.
example..
10.10.0.0/24 Production
10.10.1.0/24 Production_webservers
10.10.2.0/23 Production

Crazy, right?

0 Karma

shaskell_splunk
Splunk Employee
Splunk Employee

It would be helpful to understand the use case. What is the problem you're trying to solve?

You could create a custom search command using a utility like Python netaddr, more specifically IP Sets

>>> from netaddr import *
>>> ips = [IPNetwork('10.10.20.0/23'),IPNetwork('10.10.20.160/27'),IPNetwork('10.10.20.192/26'),IPNetwork('10.10.20.64/26'),IPNetwork('10.10.20.64/26'),IPNetwork('10.10.21.0/26')]
>>> print IPSet(ips)
IPSet(['10.10.20.0/23'])
0 Karma
Get Updates on the Splunk Community!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...