<?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 can I use the C API of MaxMind geolite in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/how-can-I-use-the-C-API-of-MaxMind-geolite/m-p/32796#M5850</link>
    <description>&lt;P&gt;One thing you can try to test your environment to see if you have everything installed correctly.&lt;BR /&gt;&lt;BR /&gt;
export PYTHONHOME=SPLUNK-INSTALL-DIR&lt;BR /&gt;
cd GeoIP-Python-1.2.7 (or what ever python GeoIP version you downloaded).&lt;BR /&gt;&lt;BR /&gt;
python test.py&lt;BR /&gt;&lt;/P&gt;

&lt;P&gt;You should see:&lt;/P&gt;

&lt;P&gt;US&lt;BR /&gt;
14&lt;BR /&gt;
Germany&lt;BR /&gt;
US&lt;BR /&gt;
United States&lt;BR /&gt;
('68.179.128.0', '68.181.255.255')&lt;BR /&gt;
1.4.8&lt;/P&gt;

&lt;P&gt;If you don't have everything setup correctly then you will see:&lt;/P&gt;

&lt;P&gt;Traceback (most recent call last):&lt;BR /&gt;
  File "test.py", line 3, in &lt;MODULE&gt;&lt;BR /&gt;
    import GeoIP&lt;BR /&gt;
ImportError: No module named GeoIP&lt;/MODULE&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 14 Aug 2012 02:25:04 GMT</pubDate>
    <dc:creator>verticaltier</dc:creator>
    <dc:date>2012-08-14T02:25:04Z</dc:date>
    <item>
      <title>how can I use the C API of MaxMind geolite</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/how-can-I-use-the-C-API-of-MaxMind-geolite/m-p/32791#M5845</link>
      <description>&lt;P&gt;after I install the GEOIP from &lt;A href="http://www.maxmind.com/download/geoip/api/c/GeoIP.tar.gz"&gt;http://www.maxmind.com/download/geoip/api/c/GeoIP.tar.gz&lt;/A&gt;&lt;BR /&gt;
I chose using C API in splunk,but it returns:"&lt;BR /&gt;
Encountered the following error while trying to update: In handler 'localapps': The Maxmind C based Geo IP API is not installed!"&lt;/P&gt;

&lt;P&gt;How can I fix it ?&lt;BR /&gt;
Thank you!&lt;/P&gt;</description>
      <pubDate>Sun, 12 Aug 2012 15:55:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/how-can-I-use-the-C-API-of-MaxMind-geolite/m-p/32791#M5845</guid>
      <dc:creator>perlish</dc:creator>
      <dc:date>2012-08-12T15:55:32Z</dc:date>
    </item>
    <item>
      <title>Re: how can I use the C API of MaxMind geolite</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/how-can-I-use-the-C-API-of-MaxMind-geolite/m-p/32792#M5846</link>
      <description>&lt;P&gt;The &lt;A href="http://splunk-base.splunk.com/apps/22284/geoasn"&gt;GeoASN app&lt;/A&gt; provides a pretty good tutorial on how to install the maxmind c api for use with Splunk.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Aug 2012 13:11:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/how-can-I-use-the-C-API-of-MaxMind-geolite/m-p/32792#M5846</guid>
      <dc:creator>ziegfried</dc:creator>
      <dc:date>2012-08-13T13:11:33Z</dc:date>
    </item>
    <item>
      <title>Re: how can I use the C API of MaxMind geolite</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/how-can-I-use-the-C-API-of-MaxMind-geolite/m-p/32793#M5847</link>
      <description>&lt;P&gt;Here is how I made mine work.&lt;/P&gt;

&lt;P&gt;&lt;A href="http://www.maxmind.com/download/geoip/api/python/"&gt;Download the GeoIP C API&lt;/A&gt; (compile and install)&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;./configure&lt;/LI&gt;
&lt;LI&gt;make&lt;/LI&gt;
&lt;LI&gt;make check&lt;/LI&gt;
&lt;LI&gt;sudo make install&lt;/LI&gt;
&lt;LI&gt;sudo ldconfig&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;&lt;A href="http://www.maxmind.com/download/geoip/api/python/"&gt;Download the GeoIP Python API&lt;/A&gt;&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;python2 setup.py build&lt;/LI&gt;
&lt;LI&gt;python2 setup.py install --prefix=SPLUNK-INSTALL-DIR&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;Restart Splunk.&lt;/P&gt;

&lt;P&gt;If all goes well you should see the library get installed into SPLUNK-INSTALL-DIR/lib/python2.7/site-packages/&lt;BR /&gt;&lt;BR /&gt;
GeoIP.so&lt;BR /&gt;&lt;BR /&gt;
GeoIP_Python-1.2.7-py2.7.egg-info&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Aug 2012 19:21:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/how-can-I-use-the-C-API-of-MaxMind-geolite/m-p/32793#M5847</guid>
      <dc:creator>verticaltier</dc:creator>
      <dc:date>2012-08-13T19:21:08Z</dc:date>
    </item>
    <item>
      <title>Re: how can I use the C API of MaxMind geolite</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/how-can-I-use-the-C-API-of-MaxMind-geolite/m-p/32794#M5848</link>
      <description>&lt;P&gt;Thank you !&lt;BR /&gt;
I've followed your step and still can not make it work.&lt;BR /&gt;
I also copy the /usr/local/lib/libGeoIP* to&lt;BR /&gt;
/home/splunk/lib/python2.7/site-packages/ /home/splunk/lib64/python2.6/site-packages/ /home/splunk/lib64 and /home/splunk/lib, then restart the splunk,but it did not work.&lt;/P&gt;

&lt;P&gt;[root@splunk ~]# ls /home/splunk/lib64/python2.6/site-packages/GeoIP*&lt;BR /&gt;
/home/splunk/lib64/python2.6/site-packages/GeoIP_Python-1.2.7-py2.6.egg-info  /home/splunk/lib64/python2.6/site-packages/GeoIP.so&lt;/P&gt;

&lt;P&gt;what shall I do to make it work ?&lt;BR /&gt;
Thank you !&lt;/P&gt;</description>
      <pubDate>Tue, 14 Aug 2012 00:26:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/how-can-I-use-the-C-API-of-MaxMind-geolite/m-p/32794#M5848</guid>
      <dc:creator>perlish</dc:creator>
      <dc:date>2012-08-14T00:26:40Z</dc:date>
    </item>
    <item>
      <title>Re: how can I use the C API of MaxMind geolite</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/how-can-I-use-the-C-API-of-MaxMind-geolite/m-p/32795#M5849</link>
      <description>&lt;P&gt;I may have left out a step.  After you installed the C API did you run sudo ldconfig ?&lt;/P&gt;</description>
      <pubDate>Tue, 14 Aug 2012 01:46:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/how-can-I-use-the-C-API-of-MaxMind-geolite/m-p/32795#M5849</guid>
      <dc:creator>verticaltier</dc:creator>
      <dc:date>2012-08-14T01:46:14Z</dc:date>
    </item>
    <item>
      <title>Re: how can I use the C API of MaxMind geolite</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/how-can-I-use-the-C-API-of-MaxMind-geolite/m-p/32796#M5850</link>
      <description>&lt;P&gt;One thing you can try to test your environment to see if you have everything installed correctly.&lt;BR /&gt;&lt;BR /&gt;
export PYTHONHOME=SPLUNK-INSTALL-DIR&lt;BR /&gt;
cd GeoIP-Python-1.2.7 (or what ever python GeoIP version you downloaded).&lt;BR /&gt;&lt;BR /&gt;
python test.py&lt;BR /&gt;&lt;/P&gt;

&lt;P&gt;You should see:&lt;/P&gt;

&lt;P&gt;US&lt;BR /&gt;
14&lt;BR /&gt;
Germany&lt;BR /&gt;
US&lt;BR /&gt;
United States&lt;BR /&gt;
('68.179.128.0', '68.181.255.255')&lt;BR /&gt;
1.4.8&lt;/P&gt;

&lt;P&gt;If you don't have everything setup correctly then you will see:&lt;/P&gt;

&lt;P&gt;Traceback (most recent call last):&lt;BR /&gt;
  File "test.py", line 3, in &lt;MODULE&gt;&lt;BR /&gt;
    import GeoIP&lt;BR /&gt;
ImportError: No module named GeoIP&lt;/MODULE&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Aug 2012 02:25:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/how-can-I-use-the-C-API-of-MaxMind-geolite/m-p/32796#M5850</guid>
      <dc:creator>verticaltier</dc:creator>
      <dc:date>2012-08-14T02:25:04Z</dc:date>
    </item>
    <item>
      <title>Re: how can I use the C API of MaxMind geolite</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/how-can-I-use-the-C-API-of-MaxMind-geolite/m-p/32797#M5851</link>
      <description>&lt;H1&gt;Name: GeoASN Add On&lt;/H1&gt;

&lt;H1&gt;Desc: Fast local lookups of the Country, AS number and Organization to which an IP address belong&lt;/H1&gt;

&lt;H1&gt;Four lookup commands are provided:&lt;/H1&gt;

&lt;H1&gt;CMD            INPUT FIELDS    OUTPUT FIELDS&lt;/H1&gt;

&lt;H1&gt;--------------------------------------------&lt;/H1&gt;

&lt;H1&gt;geo            clientip        client_country client_region client_city client_lat client_lon&lt;/H1&gt;

&lt;H1&gt;asn            src_ip dest_ip  src_asn dest_asn&lt;/H1&gt;

&lt;H1&gt;geoasn         src_ip dest_ip  src_country dest_country src_asn src_as src_org dest_asn dest_as dest_org&lt;/H1&gt;

&lt;H1&gt;ga             ip              country asn org&lt;/H1&gt;

&lt;H1&gt;The Add-On is based on Will Hayes @ Splunk's MAXMIND Geo Location Lookup Script,&lt;/H1&gt;

&lt;H1&gt;but it has been rewritten to use the native Maxmind C libraries, for increased speed and functionality.&lt;/H1&gt;

&lt;H1&gt;GeoASN requires that you build the Maxmind C SDK and Python SDK,&lt;/H1&gt;

&lt;H1&gt;and copy the resulting libraries to $SPLUNK_HOME (see instructions below)&lt;/H1&gt;

&lt;H1&gt;This app includes GeoLite data created by MaxMind, available from &lt;A href="http://www.maxmind.com/" target="_blank"&gt;http://www.maxmind.com/&lt;/A&gt;&lt;/H1&gt;

&lt;H1&gt;Henrik Strom, Telenor Norway, April 2011&lt;/H1&gt;

&lt;P&gt;INSTALLATION&lt;/P&gt;

&lt;P&gt;Step 1 - Install Maxmind's GeoIP for C SDK&lt;/P&gt;

&lt;P&gt;cd /tmp&lt;BR /&gt;
  wget &lt;A href="http://geolite.maxmind.com/download/geoip/api/c/GeoIP.tar.gz" target="_blank"&gt;http://geolite.maxmind.com/download/geoip/api/c/GeoIP.tar.gz&lt;/A&gt;&lt;BR /&gt;
  tar zxvf GeoIP.tar.gz&lt;BR /&gt;
  cd GeoIP-1.4.7&lt;BR /&gt;
  ./configure&lt;BR /&gt;
  make&lt;BR /&gt;
  make install&lt;/P&gt;

&lt;P&gt;If this fails because configure complains about Zlib header not found, &lt;BR /&gt;
you need to install the zlib-devel package. Then rerun ./configure, &lt;BR /&gt;
make and make install.&lt;/P&gt;

&lt;P&gt;Next, copy the compiled GeoIP libs to $SPLUNK_HOME/lib&lt;/P&gt;

&lt;P&gt;cp -p /usr/local/lib/libGeoIP* /opt/splunk/lib/&lt;/P&gt;

&lt;P&gt;Step 2 - Install same Python on your Splunk server as Splunk itself is using&lt;/P&gt;

&lt;P&gt;Find out which version of python your Splunk installation is using:&lt;/P&gt;

&lt;P&gt;/opt/splunk/bin/splunk cmd python --version&lt;BR /&gt;
  Python 2.6.4&lt;/P&gt;

&lt;P&gt;Then download and install this on your Splunk server:&lt;/P&gt;

&lt;P&gt;cd /tmp&lt;BR /&gt;
  wget &lt;A href="http://www.python.org/ftp/python/2.6.4/Python-2.6.4.tgz" target="_blank"&gt;http://www.python.org/ftp/python/2.6.4/Python-2.6.4.tgz&lt;/A&gt;&lt;BR /&gt;
  tar zxvf Python-2.6.4.tgz&lt;BR /&gt;
  cd Python-2.6.4&lt;BR /&gt;
  ./configure&lt;BR /&gt;
  make&lt;BR /&gt;
  make install&lt;/P&gt;

&lt;P&gt;Step 3 - Install Maxmind's GeoIP for Python SDK&lt;/P&gt;

&lt;P&gt;cd /tmp&lt;BR /&gt;
  wget &lt;A href="http://geolite.maxmind.com/download/geoip/api/python/GeoIP-Python-1.2.4.tar.gz" target="_blank"&gt;http://geolite.maxmind.com/download/geoip/api/python/GeoIP-Python-1.2.4.tar.gz&lt;/A&gt;&lt;BR /&gt;
  tar zxvf GeoIP-Python-1.2.4.tar.gz&lt;BR /&gt;
  cd GeoIP-Python-1.2.4&lt;BR /&gt;
  /usr/local/bin/python setup.py build&lt;BR /&gt;
  /usr/local/bin/python setup.py install&lt;/P&gt;

&lt;P&gt;Next, copy the compiled GeoIP Python lib to Splunk's Python directory:&lt;/P&gt;

&lt;P&gt;cp -p /usr/local/lib/python2.6/site-packages/GeoIP* /opt/splunk/lib/python2.6/site-packages/ &lt;/P&gt;

&lt;P&gt;Step 4 - Install GeoASN Add On&lt;/P&gt;

&lt;P&gt;Download the GeoASN Splunk Add On from &lt;A href="http://splunkbase.splunk.com" target="_blank"&gt;http://splunkbase.splunk.com&lt;/A&gt;&lt;BR /&gt;
Then install it under $SPLUNK_HOME/etc/apps/&lt;/P&gt;

&lt;P&gt;cd /opt/splunk/etc/apps&lt;BR /&gt;
  tar zxvf GeoASN.spl&lt;/P&gt;

&lt;P&gt;Step 5 - Restart Splunk&lt;/P&gt;

&lt;P&gt;/opt/splunk/bin/splunk restart&lt;/P&gt;

&lt;P&gt;Step 6 - Test it from the command line&lt;/P&gt;

&lt;P&gt;cd /opt/splunk/etc/apps/GeoASN/bin&lt;BR /&gt;
  /opt/splunk/bin/splunk cmd python ga.py &amp;lt; ga.csv &lt;/P&gt;

&lt;P&gt;If it works, it should output the following:&lt;/P&gt;

&lt;P&gt;ip,country,asn,org&lt;BR /&gt;
200.148.108.124,Brazil,27699,DE SAO PAULO S/A - TELESP&lt;BR /&gt;
203.129.108.100,Japan,10000,Nagasaki Cable Media Inc.&lt;/P&gt;

&lt;P&gt;You are now ready to start using the GeoASN lookup commands!&lt;/P&gt;

&lt;P&gt;UPDATING THE MAXMIND DATABASES&lt;/P&gt;

&lt;P&gt;We use two different databases from Maxmind.com, bundled with this Add On.&lt;BR /&gt;
A new version of each database comes out about every month.&lt;/P&gt;

&lt;P&gt;Here is how you update to the latest version of these databases:&lt;/P&gt;

&lt;P&gt;cd /opt/splunk/etc/apps/GeoASN/lookups&lt;BR /&gt;
wget &lt;A href="http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz" target="_blank"&gt;http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz&lt;/A&gt;&lt;BR /&gt;
wget &lt;A href="http://geolite.maxmind.com/download/geoip/database/asnum/GeoIPASNum.dat.gz" target="_blank"&gt;http://geolite.maxmind.com/download/geoip/database/asnum/GeoIPASNum.dat.gz&lt;/A&gt;&lt;BR /&gt;
gunzip GeoLiteCity.dat.gz&lt;BR /&gt;
gunzip GeoIPASNum.dat.gz&lt;/P&gt;

&lt;P&gt;Maxmind.com also provides commercial versions of its Geo databases, &lt;BR /&gt;
with better accuracy and more frequent updates.&lt;/P&gt;

&lt;P&gt;EXAMPLE SEARCHES&lt;/P&gt;

&lt;P&gt;If you have logs with a single IP address field:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;| lookup ga ip&lt;/LI&gt;
&lt;LI&gt;| lookup ga ip AS the_name_of_your_ip_addr_field&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;If you have logs with two IP address fields:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;| lookup geoasn src_ip dest_ip&lt;/LI&gt;
&lt;LI&gt;| lookup geoasn src_ip AS your_1st_field dest_ip AS your_2nd_field&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;EXAMPLE PROPS.CONF&lt;/P&gt;

&lt;P&gt;If you always want your searches to lookup the Country, AS number and &lt;BR /&gt;
Organization for IP addresses, you can configure props.conf to do this:&lt;/P&gt;

&lt;P&gt;[asa]&lt;BR /&gt;
LOOKUP-geoasn = geoasn src_ip dest_ip&lt;/P&gt;

&lt;P&gt;In this example, all events with sourcetype 'asa' (Cisco firewall logs) &lt;BR /&gt;
will use the geoasn command to lookup the src_ip and dest_ip &lt;BR /&gt;
This produces the following fields:&lt;/P&gt;

&lt;P&gt;src_country  : The Country as found in the Maxmind GeoCity database&lt;BR /&gt;
dest_country : The Country as found in the Maxmind GeoCity database&lt;BR /&gt;
src_asn      : The AS number and Org as found in the Maxmind ASN database&lt;BR /&gt;
src_as       : The AS number, without the 'AS' prefix &lt;BR /&gt;
src_org      : The Organization, without the AS number&lt;BR /&gt;
dest_asn     : The AS number and Orgn as found in the Maxmind ASN database&lt;BR /&gt;
dest_as      : The AS number, without the 'AS' prefix &lt;BR /&gt;
dest_org     : The Organization, without the AS number&lt;/P&gt;

&lt;P&gt;If the IP address being looked up is within the ranges defined in RFC 1918, &lt;BR /&gt;
the Country and Organization fields are set to 'RFC1918', to make it easy to &lt;BR /&gt;
filter on Private IP addresses. AS number is set to 0.&lt;/P&gt;

&lt;P&gt;If the address was not found in the database, and it is not an RFC 1918 address, &lt;BR /&gt;
the Country and/or Organization is set to 'Unknown', and the AS number is set to 0.&lt;/P&gt;

&lt;P&gt;PERFORMANCE&lt;/P&gt;

&lt;P&gt;Benchmarking from Maxmind has shown that the native C libraries are capable of &lt;BR /&gt;
doing 400.000 IP address lookups per second when memory caching is not used. &lt;BR /&gt;
The C implementation is capable of more than 1 million lookups/s when using memory&lt;BR /&gt;
caching. We use both the native C libraries and memory caching for maximum performance.&lt;/P&gt;

&lt;P&gt;Another optimization is the lookup of the Country, AS number and Organization &lt;BR /&gt;
for both the src_ip and dest_ip in one single command. Instead of executing &lt;BR /&gt;
multiple lookup commands, we only execute once.&lt;/P&gt;

&lt;P&gt;TYPICAL USE CASES&lt;/P&gt;

&lt;P&gt;All logs containing IP addresses will be easier to analyze if you, for each &lt;BR /&gt;
IP address, can tell which Country and Organization it belongs to. This is &lt;BR /&gt;
especially relevant for security analysis, where one can perform queries and &lt;BR /&gt;
reports to e.g., show all foreign communications.&lt;/P&gt;

&lt;P&gt;Enjoy!&lt;/P&gt;

&lt;P&gt;Henrik Strom&lt;BR /&gt;
Telenor Norway&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 12:17:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/how-can-I-use-the-C-API-of-MaxMind-geolite/m-p/32797#M5851</guid>
      <dc:creator>perlish</dc:creator>
      <dc:date>2020-09-28T12:17:30Z</dc:date>
    </item>
  </channel>
</rss>

