Getting Data In

Using cidrmatch with a CSV file throws error.

ImanIself
Explorer

I am trying to match a list of CIDR ranges in a csv file to hosts that are going outbound on our network...basically trying to see if there are any naughty hosts trying to go to Russia. The search command is as follows:

sourcetype="cisco_syslog" | eval Fhost=cidrmatch([inputcsv rrcidrlist], cisco_dsthost)

When i run this the following error is returned: Error in 'eval' command: The number 46.19.104.0 is invalid.

The 46.19.104.0 just so happens to be the first IP in the list, however its doesn't appear to be reading the /21 at the end. Again, it doesn't appear to be reading the 46.19.104.0/21 CIDR range. There are no spaces in the CSV file. The documentation indicates that the double quotes should be used around the CIDR range however i have tried them everywhere and nothing seems to work. Any help would be greatly appreciated. Noobly appreciated 🙂

Tags (1)

hammon0u
Explorer

You can use the MAXMIND application to lookup IP against the MAXMIND db and report on anything that returns a lookup to Russia or China etc. You can even find the City in Russia where the packet went.

0 Karma

gkanapathy
Splunk Employee
Splunk Employee

The arguments to cidrmatch must be passed as strings, and therefore must be quoted. The results from your subsearch probably looks like:

( ( 46.19.104.0/21 ) )

or

( ( 46.19.104.0/21 ) OR ( 1.2.3.4/21 ) OR ... )

Anyway, the point is subsearch doesn't expand the way you think it does, and if you have multiple values, it is even less likely to work the way you think.

What you really need is:

sourcetype=ciso_syslog [ inputcsv rrcidrlist | fields iprange | rename iprange as cisco_dsthost ]

Which assumes that the fieldname in the CSV file that contains the CIDR ranges is iprange. If it isn't substitute appropriately.

gkanapathy
Splunk Employee
Splunk Employee

Yeah, so my example should do what you want.

0 Karma

ImanIself
Explorer

I appreciate the quick response. It appears i was going in the wrong direction. Basically I want to compare a CSV list of CIDR ranges to a field which contains hosts attempting to connect externally and return any matches. We want to see if any hosts are attempting to connect to Russia/Romania.

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Unlocking Unified Insights: New Gigamon Federated Search App for Splunk

In today’s data-heavy environment, organizations are caught in a data distribution dilemma. As data volumes ...

GA: New Data Management App in Splunk Platform

Streamlining Data Management: Introducing a unified experience in Splunk Managing data at scale shouldn’t feel ...

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...