<?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: Unable to write a query to check IP addresses in Subnets in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-query-to-check-IP-addresses-in-Subnets/m-p/645343#M223455</link>
    <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I expecting that your ip is like "10.1.2.34" not "10.1.2.342" and you have e.g. subnets 10.0.0.0 - 10.63.255.255 defined for America. Then you can check it like&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval ip = "10.1.2.34", subnet = "10.0.0.0/10"
| eval AMERICAS = if (cidrmatch(subnet,ip), "OK", "NOK")&lt;/LI-CODE&gt;&lt;P&gt;If your subnets are not exactly dived by suitable masks, you need to add needed smaller subnets and combine this if with several OR clauses.&lt;/P&gt;&lt;P&gt;r. Ismo&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 01 Jun 2023 12:45:23 GMT</pubDate>
    <dc:creator>isoutamo</dc:creator>
    <dc:date>2023-06-01T12:45:23Z</dc:date>
    <item>
      <title>How to write a query to check IP addresses in Subnets?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-query-to-check-IP-addresses-in-Subnets/m-p/645327#M223450</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I am trying to establish a query that checks whether a random src IP is in a specific subnet.&lt;BR /&gt;&lt;BR /&gt;However, all the subnets and IP addresses are in String format and I am unable to establish any mathematical relationship between the conditions.&lt;BR /&gt;&lt;BR /&gt;Here is a part of my current query:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;| inputlookup ABC.csv&lt;BR /&gt;| eval ip = 10.1.2.342&lt;/P&gt;
&lt;P&gt;| eval AMERICAS =if(ip &amp;gt;= 10.0.0.1 OR ip &amp;lt;= 10.63.255.254,"NOK","OK")&lt;/P&gt;
&lt;P&gt;| table AMERICAS&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you please help?&lt;/P&gt;
&lt;P&gt;Many thanks as always,&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jun 2023 12:50:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-query-to-check-IP-addresses-in-Subnets/m-p/645327#M223450</guid>
      <dc:creator>POR160893</dc:creator>
      <dc:date>2023-06-01T12:50:57Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to write a query to check IP addresses in Subnets</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-query-to-check-IP-addresses-in-Subnets/m-p/645331#M223452</link>
      <description>&lt;P&gt;If your subnets are in CIDR format, you can use the cidrmatch() function&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jun 2023 10:30:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-query-to-check-IP-addresses-in-Subnets/m-p/645331#M223452</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-06-01T10:30:32Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to write a query to check IP addresses in Subnets</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-query-to-check-IP-addresses-in-Subnets/m-p/645343#M223455</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I expecting that your ip is like "10.1.2.34" not "10.1.2.342" and you have e.g. subnets 10.0.0.0 - 10.63.255.255 defined for America. Then you can check it like&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval ip = "10.1.2.34", subnet = "10.0.0.0/10"
| eval AMERICAS = if (cidrmatch(subnet,ip), "OK", "NOK")&lt;/LI-CODE&gt;&lt;P&gt;If your subnets are not exactly dived by suitable masks, you need to add needed smaller subnets and combine this if with several OR clauses.&lt;/P&gt;&lt;P&gt;r. Ismo&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jun 2023 12:45:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-query-to-check-IP-addresses-in-Subnets/m-p/645343#M223455</guid>
      <dc:creator>isoutamo</dc:creator>
      <dc:date>2023-06-01T12:45:23Z</dc:date>
    </item>
  </channel>
</rss>

