<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to match an IP address from a lookup table of cidr ranges? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-an-IP-address-from-a-lookup-table-of-cidr-ranges/m-p/204675#M59496</link>
    <description>&lt;P&gt;A friend pointed this out, but this can be done without CLI access now.  Perform the following:&lt;/P&gt;

&lt;P&gt;1) Settings -&amp;gt; Lookups -&amp;gt; Lookup Definitions&lt;BR /&gt;
2) Check the box for: "Advanced options"&lt;BR /&gt;
3) Match type:  CIDR([fieldname])   &amp;lt;-- fieldname is the field with the CIDR addresses in it&lt;/P&gt;

&lt;P&gt;Then in your search:&lt;BR /&gt;
... | lookup [fieldname] as src_ip OUTPUT site as src_site&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 23:58:13 GMT</pubDate>
    <dc:creator>TonyLeeVT</dc:creator>
    <dc:date>2020-09-29T23:58:13Z</dc:date>
    <item>
      <title>How to match an IP address from a lookup table of cidr ranges?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-an-IP-address-from-a-lookup-table-of-cidr-ranges/m-p/204667#M59488</link>
      <description>&lt;P&gt;I'm trying to search records where the destination IP is in a lookup table consisting of a list of cidr ranges, but the source IP is not in one of those ranges.  This was my initial thought on how to do it.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=* | fields srcip dstip | where cidrmatch([| inputlookup IP_Ranges], dstip)  AND !cidrmatch([| inputlookup IP_Ranges], srcip) 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The lookup table is just a list of cidr ranges like&lt;BR /&gt;
10.0.1.0/24&lt;BR /&gt;
10.0.5.0/24&lt;BR /&gt;
10.0.100.0/24&lt;/P&gt;

&lt;P&gt;Any suggestions are greatly appreciated.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Sep 2015 17:59:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-match-an-IP-address-from-a-lookup-table-of-cidr-ranges/m-p/204667#M59488</guid>
      <dc:creator>glenngermiathen</dc:creator>
      <dc:date>2015-09-03T17:59:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to match an IP address from a lookup table of cidr ranges?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-an-IP-address-from-a-lookup-table-of-cidr-ranges/m-p/204668#M59489</link>
      <description>&lt;P&gt;Or just how should I go about matching the IP address from the cidr ranges?&lt;/P&gt;

&lt;P&gt;index=* | fields srcip dstip | where cidrmatch([| inputlookup IP_Ranges], dstip)&lt;/P&gt;</description>
      <pubDate>Thu, 03 Sep 2015 19:40:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-match-an-IP-address-from-a-lookup-table-of-cidr-ranges/m-p/204668#M59489</guid>
      <dc:creator>glenngermiathen</dc:creator>
      <dc:date>2015-09-03T19:40:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to match an IP address from a lookup table of cidr ranges?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-an-IP-address-from-a-lookup-table-of-cidr-ranges/m-p/204669#M59490</link>
      <description>&lt;P&gt;The problem is that the first argument for cidrmatch is not a list of subnets, it is a string. And I don't know if the string can contain multiple subnets.&lt;/P&gt;

&lt;P&gt;Another way to do this is to use the lookup command.  But for this to work, you need to make sure that the following options appear in your &lt;CODE&gt;transforms.conf&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[IP_Ranges]
min_matches = 1
default_match = NONE
match_type = CIDR(cidr_range)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This assumes that your lookup file has a header row (which it must) and that the field name in the header is &lt;CODE&gt;cidr_range&lt;/CODE&gt;.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=* | fields srcip dstip 
| lookup IP_Ranges cidr_range as srcip OUTPUT cidr_range as src_match
| where src_match != "NONE"
| lookup IP_Ranges cidr_range as dstip OUTPUT cidr_range as dst_match
| where dst_match != "NONE"
| etc
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now you have two new fields, &lt;CODE&gt;src_match&lt;/CODE&gt; and &lt;CODE&gt;dst_match&lt;/CODE&gt; which will contain all the subnets that matched the srcip and dstip, respectively. If an ip does not match any subnets, the field will contain the string "NONE". &lt;/P&gt;</description>
      <pubDate>Thu, 03 Sep 2015 22:19:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-match-an-IP-address-from-a-lookup-table-of-cidr-ranges/m-p/204669#M59490</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2015-09-03T22:19:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to match an IP address from a lookup table of cidr ranges?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-an-IP-address-from-a-lookup-table-of-cidr-ranges/m-p/204670#M59491</link>
      <description>&lt;P&gt;nicely done&lt;/P&gt;</description>
      <pubDate>Thu, 03 Dec 2015 22:16:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-match-an-IP-address-from-a-lookup-table-of-cidr-ranges/m-p/204670#M59491</guid>
      <dc:creator>paulstark</dc:creator>
      <dc:date>2015-12-03T22:16:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to match an IP address from a lookup table of cidr ranges?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-an-IP-address-from-a-lookup-table-of-cidr-ranges/m-p/204671#M59492</link>
      <description>&lt;P&gt;Thanks that hellped me a lot ! &lt;/P&gt;</description>
      <pubDate>Mon, 08 Aug 2016 13:53:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-match-an-IP-address-from-a-lookup-table-of-cidr-ranges/m-p/204671#M59492</guid>
      <dc:creator>aakwah</dc:creator>
      <dc:date>2016-08-08T13:53:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to match an IP address from a lookup table of cidr ranges?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-an-IP-address-from-a-lookup-table-of-cidr-ranges/m-p/204672#M59493</link>
      <description>&lt;P&gt;How about mixed IPv4 and IPv6 CIDR matches&lt;/P&gt;

&lt;P&gt;ip_range,info&lt;BR /&gt;
192.168.1.0/24,foo&lt;BR /&gt;
2001::1/48,bar&lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2016 22:28:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-match-an-IP-address-from-a-lookup-table-of-cidr-ranges/m-p/204672#M59493</guid>
      <dc:creator>mathiask</dc:creator>
      <dc:date>2016-08-16T22:28:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to match an IP address from a lookup table of cidr ranges?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-an-IP-address-from-a-lookup-table-of-cidr-ranges/m-p/204673#M59494</link>
      <description>&lt;P&gt;Hi Lisa,&lt;/P&gt;

&lt;P&gt;great thing.&lt;BR /&gt;
Can this be done without transforms.conf?&lt;BR /&gt;
I.E. just upload the csv and then do the lookup inline?&lt;BR /&gt;
(Our users are 'of course' not allowed to modify Splunk configs)&lt;/P&gt;

&lt;P&gt;Rgds,&lt;BR /&gt;
Jens&lt;/P&gt;</description>
      <pubDate>Thu, 02 Feb 2017 13:44:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-match-an-IP-address-from-a-lookup-table-of-cidr-ranges/m-p/204673#M59494</guid>
      <dc:creator>JensT</dc:creator>
      <dc:date>2017-02-02T13:44:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to match an IP address from a lookup table of cidr ranges?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-an-IP-address-from-a-lookup-table-of-cidr-ranges/m-p/204674#M59495</link>
      <description>&lt;P&gt;I'm trying to apply this query to a search of my Symantec logs and I'm having issues getting output to return the subnets that matched the src and dest IPs. My search is as follows:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=symantec sourcetype=symantec:ep:risk:file action=allowed OR action=deferred AND Risk_Action="Virus found" | rename actual_action as "Action" dest as "Host" dest_ip as "Host IP" user as "User" Risk_Action as "Detection Type" signature as "Malware Name" | fields "Host IP"
| lookup ip_cidr cidr_range as "Host IP" OUTPUT cidr_range as ip_match
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;My lookup file has three other columns in addition to cidr_range. What I'd like to do is match the src or dest IP to the IP cidr and then pull the zone/firewall/context the user is associated with.&lt;/P&gt;

&lt;P&gt;Would appreciate any help&lt;/P&gt;

&lt;P&gt;Thx&lt;/P&gt;</description>
      <pubDate>Thu, 24 Aug 2017 14:45:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-match-an-IP-address-from-a-lookup-table-of-cidr-ranges/m-p/204674#M59495</guid>
      <dc:creator>jwalzerpitt</dc:creator>
      <dc:date>2017-08-24T14:45:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to match an IP address from a lookup table of cidr ranges?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-an-IP-address-from-a-lookup-table-of-cidr-ranges/m-p/204675#M59496</link>
      <description>&lt;P&gt;A friend pointed this out, but this can be done without CLI access now.  Perform the following:&lt;/P&gt;

&lt;P&gt;1) Settings -&amp;gt; Lookups -&amp;gt; Lookup Definitions&lt;BR /&gt;
2) Check the box for: "Advanced options"&lt;BR /&gt;
3) Match type:  CIDR([fieldname])   &amp;lt;-- fieldname is the field with the CIDR addresses in it&lt;/P&gt;

&lt;P&gt;Then in your search:&lt;BR /&gt;
... | lookup [fieldname] as src_ip OUTPUT site as src_site&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 23:58:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-match-an-IP-address-from-a-lookup-table-of-cidr-ranges/m-p/204675#M59496</guid>
      <dc:creator>TonyLeeVT</dc:creator>
      <dc:date>2020-09-29T23:58:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to match an IP address from a lookup table of cidr ranges?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-an-IP-address-from-a-lookup-table-of-cidr-ranges/m-p/204676#M59497</link>
      <description>&lt;P&gt;This was very helpful, thanks&lt;/P&gt;</description>
      <pubDate>Sun, 26 May 2019 09:55:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-match-an-IP-address-from-a-lookup-table-of-cidr-ranges/m-p/204676#M59497</guid>
      <dc:creator>ankurpwc</dc:creator>
      <dc:date>2019-05-26T09:55:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to match an IP address from a lookup table of cidr ranges?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-an-IP-address-from-a-lookup-table-of-cidr-ranges/m-p/204677#M59498</link>
      <description>&lt;P&gt;HI,&lt;/P&gt;

&lt;P&gt;I did exactly the same steps, but i am only getting NONE (default) for all the entries. I have checked and matches do exists on the csv file. Any pointers on why ip is not getting matched to CIDR and how can it be resolved?&lt;/P&gt;</description>
      <pubDate>Thu, 30 May 2019 21:01:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-match-an-IP-address-from-a-lookup-table-of-cidr-ranges/m-p/204677#M59498</guid>
      <dc:creator>niddhi</dc:creator>
      <dc:date>2019-05-30T21:01:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to match an IP address from a lookup table of cidr ranges?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-an-IP-address-from-a-lookup-table-of-cidr-ranges/m-p/204678#M59499</link>
      <description>&lt;P&gt;Late to the show here, but I had the same issue.  Found I had spaces at the end of my cidr_range values.  If you copy/paste, make sure there are no leading/trailing spaces.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Nov 2019 18:14:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-match-an-IP-address-from-a-lookup-table-of-cidr-ranges/m-p/204678#M59499</guid>
      <dc:creator>ohbuckeyeio</dc:creator>
      <dc:date>2019-11-06T18:14:56Z</dc:date>
    </item>
  </channel>
</rss>

