Splunk Search

Why are tstats search not filtering out local IP ranges?

dmbrcx
Explorer

Hi,

I am using tstats to search the Network Datamodel for outbound SMB traffic (port 445) to external IP address ranges.

Why are local IP ranges still appearing in my search results?

Here is my syntax:

 

 

| tstats summariesonly=t fillnull_value="MISSING" count from datamodel=Network_Traffic.All_Traffic where All_Traffic.dest_port="445" AND NOT All_Traffic.dest IN ("10.0.0.0/8","172.16.0.0/16","192.168.0.0/24") earliest=-15m latest=now
by _time, All_Traffic.dest, All_Traffic.dest_port,All_Traffic.src, All_Traffic.src_port, All_Traffic.action, All_Traffic.bytes, index, sourcetype

 

 

Screenshot:

Splunk Forum Question 2023-03-15_15-01.png

I believe I have filtered them correctly, but hmm...

Labels (1)
0 Karma
1 Solution

yuanliu
SplunkTrust
SplunkTrust

Two things.  First, CIDR match doesn't go with the IN operator.  You have to specify them individually, like

| tstats summariesonly=t fillnull_value="MISSING" count from datamodel=Network_Traffic.All_Traffic where All_Traffic.dest_port="445"
 AND NOT (All_Traffic.dest="10.0.0.0/8" OR All_Traffic.dest="172.16.0.0/16" OR All_Traffic.dest="192.168.0.0/24")
 earliest=-15m latest=now
by _time, All_Traffic.dest, All_Traffic.dest_port,All_Traffic.src, All_Traffic.src_port, All_Traffic.action, All_Traffic.bytes, index, sourcetype

Second, beware of Limitations of CIDR matching with tstats.

View solution in original post

dmbrcx
Explorer

Thank you. Those limitations are interesting. I am surprised I have not noticed this issue before.

0 Karma

yuanliu
SplunkTrust
SplunkTrust

Two things.  First, CIDR match doesn't go with the IN operator.  You have to specify them individually, like

| tstats summariesonly=t fillnull_value="MISSING" count from datamodel=Network_Traffic.All_Traffic where All_Traffic.dest_port="445"
 AND NOT (All_Traffic.dest="10.0.0.0/8" OR All_Traffic.dest="172.16.0.0/16" OR All_Traffic.dest="192.168.0.0/24")
 earliest=-15m latest=now
by _time, All_Traffic.dest, All_Traffic.dest_port,All_Traffic.src, All_Traffic.src_port, All_Traffic.action, All_Traffic.bytes, index, sourcetype

Second, beware of Limitations of CIDR matching with tstats.

Get Updates on the Splunk Community!

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer at Splunk .conf24 ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

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

Combine Multiline Logs into a Single Event with SOCK: a Step-by-Step Guide for ...

Combine multiline logs into a single event with SOCK - a step-by-step guide for newbies Olga Malita The ...