<?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 write a search to find if a field contains a valid IPv4 or IPv6 address? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-find-if-a-field-contains-a-valid-IPv4/m-p/707463#M239297</link>
    <description>&lt;P&gt;I created a Splunk Macros for regular expressions for IPv4 and IPv6 addresses.&lt;/P&gt;&lt;P&gt;Definitions and usages are in an article below.&lt;BR /&gt;&lt;A href="https://qiita.com/Joh256/private/659ef65897905890ef99" target="_blank"&gt;https://qiita.com/Joh256/private/659ef65897905890ef99&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I also put them in an add-on below.&lt;BR /&gt;&lt;A href="https://splunkbase.splunk.com/app/6595" target="_blank"&gt;https://splunkbase.splunk.com/app/6595&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 22 Dec 2024 23:12:24 GMT</pubDate>
    <dc:creator>tfujita_splunk</dc:creator>
    <dc:date>2024-12-22T23:12:24Z</dc:date>
    <item>
      <title>How to write a search to find if a field contains a valid IPv4 or IPv6 address?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-find-if-a-field-contains-a-valid-IPv4/m-p/166194#M47330</link>
      <description>&lt;P&gt;Hi all, as a splunk newbie I'm not sure what direction to go with the following.  Basically I have two Interesting fields, one contains an IPv4 address and the other contains an IPv6 address.  Sometime though these fields contain 0.0.0.0 for IPv4 and :: for IPv6. What I need is a search string that allows me to test these two fields to make sure they have valid addresses.  I know how to test for 0.0.0.0 or :: but want to test that a valid address exists.  Later I will have to verify that the address is correct based on values in other interesting fields (example: user is in building 1, IP address must be x.x.x.y etc..).  I see lots of examples of how to extract addresses but in my case I don't need to extract anything as the value exists in an interesting field.  Hope my question is clear.  Appreciate any guidance offered.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Oct 2014 20:40:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-find-if-a-field-contains-a-valid-IPv4/m-p/166194#M47330</guid>
      <dc:creator>hcastell</dc:creator>
      <dc:date>2014-10-17T20:40:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a search to find if a field contains a valid IPv4 or IPv6 address?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-find-if-a-field-contains-a-valid-IPv4/m-p/166195#M47331</link>
      <description>&lt;P&gt;You can verify IPv4 addresses like this (assuming field name is &lt;CODE&gt;ipv4&lt;/CODE&gt;&lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval ipv4_valid = if(match(ipv4, "^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"), "valid", "invalid")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And IPv6 like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval ipv6_valid = if(match(ipv6, "^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]).){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]).){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$"), "valid", "invalid")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The IPv6 regex has been shamelessly stolen from &lt;A href="http://stackoverflow.com/a/17871737"&gt;http://stackoverflow.com/a/17871737&lt;/A&gt; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;It'd probably be a good idea to plonk these things into a macro.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Oct 2014 23:05:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-find-if-a-field-contains-a-valid-IPv4/m-p/166195#M47331</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-10-17T23:05:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a search to find if a field contains a valid IPv4 or IPv6 address?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-find-if-a-field-contains-a-valid-IPv4/m-p/166196#M47332</link>
      <description>&lt;P&gt;Thanks Martin. This helps a lot. Will research creating a macro for these as you suggest.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Oct 2014 23:43:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-find-if-a-field-contains-a-valid-IPv4/m-p/166196#M47332</guid>
      <dc:creator>hcastell</dc:creator>
      <dc:date>2014-10-17T23:43:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a search to find if a field contains a valid IPv4 or IPv6 address?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-find-if-a-field-contains-a-valid-IPv4/m-p/166197#M47333</link>
      <description>&lt;P&gt;Doesn't take a lot of research - Go to Settings -&amp;gt; Advanced Search -&amp;gt; Macros -&amp;gt; New -&amp;gt; Give it a name and paste the content -&amp;gt; set permissions to "global" and "Everyone" -&amp;gt; use in a search like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval ipv6_valid = if(match(ipv6, `your_ipv6_regex_macro`)) | ...
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 18 Oct 2014 15:26:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-find-if-a-field-contains-a-valid-IPv4/m-p/166197#M47333</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-10-18T15:26:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a search to find if a field contains a valid IPv4 or IPv6 address?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-find-if-a-field-contains-a-valid-IPv4/m-p/166198#M47334</link>
      <description>&lt;P&gt;Thanks. Had not done a Macro before before so this is very helpful.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Oct 2014 00:57:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-find-if-a-field-contains-a-valid-IPv4/m-p/166198#M47334</guid>
      <dc:creator>hcastell</dc:creator>
      <dc:date>2014-10-20T00:57:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a search to find if a field contains a valid IPv4 or IPv6 address?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-find-if-a-field-contains-a-valid-IPv4/m-p/707463#M239297</link>
      <description>&lt;P&gt;I created a Splunk Macros for regular expressions for IPv4 and IPv6 addresses.&lt;/P&gt;&lt;P&gt;Definitions and usages are in an article below.&lt;BR /&gt;&lt;A href="https://qiita.com/Joh256/private/659ef65897905890ef99" target="_blank"&gt;https://qiita.com/Joh256/private/659ef65897905890ef99&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I also put them in an add-on below.&lt;BR /&gt;&lt;A href="https://splunkbase.splunk.com/app/6595" target="_blank"&gt;https://splunkbase.splunk.com/app/6595&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 22 Dec 2024 23:12:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-find-if-a-field-contains-a-valid-IPv4/m-p/707463#M239297</guid>
      <dc:creator>tfujita_splunk</dc:creator>
      <dc:date>2024-12-22T23:12:24Z</dc:date>
    </item>
  </channel>
</rss>

