<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: IP2Location</title>
    <description>The latest articles on DEV Community by IP2Location (@ip2location).</description>
    <link>https://dev.to/ip2location</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F631053%2F5e59b139-bf2b-4af0-8197-617b94d7501c.png</url>
      <title>DEV Community: IP2Location</title>
      <link>https://dev.to/ip2location</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ip2location"/>
    <language>en</language>
    <item>
      <title>How to use IP2Location.io API in Anaconda Code</title>
      <dc:creator>IP2Location</dc:creator>
      <pubDate>Wed, 03 Dec 2025 09:32:03 +0000</pubDate>
      <link>https://dev.to/ip2location/how-to-use-ip2locationio-api-in-anaconda-code-bof</link>
      <guid>https://dev.to/ip2location/how-to-use-ip2locationio-api-in-anaconda-code-bof</guid>
      <description>&lt;h2&gt;
  
  
  Intro
&lt;/h2&gt;

&lt;p&gt;Anaconda Code is an Excel add-in that enables users to execute Python or R code directly within Excel. It allows you to create custom Python functions for use in Excel workbooks. In addition, its package management support makes it easy to add or remove packages, significantly extending Excel’s capabilities. With these features, tasks such as querying external APIs for data become possible right inside Excel.&lt;/p&gt;

&lt;p&gt;In this tutorial, we will guide you through using Anaconda Code to query the IP2Location.io API and display the results in your workbook. The IP2Location.io service provides a fast and accurate IP geolocation API that allows users to determine a visitor’s geographical location and apply geolocation data in various use cases.&lt;/p&gt;

&lt;p&gt;Before we begin, please ensure that Anaconda Code is installed in your Excel application. It can be installed by adding the Anaconda Toolbox Excel add-in. You may refer to their installation guide for detailed steps.&lt;/p&gt;

&lt;p&gt;In addition, to make a CORS request to the IP2Location.io API, you will need an active subscription. CORS support is available only for the Starter plan and above. You may view and purchase a plan here: &lt;a href="https://www.ip2location.io/pricing/#devto" rel="noopener noreferrer"&gt;https://www.ip2location.io/pricing&lt;/a&gt;  &lt;/p&gt;

&lt;h2&gt;
  
  
  Steps to Use the IP2Location.io API in Anaconda Code
&lt;/h2&gt;

&lt;p&gt;Step 1:&lt;br&gt;
In Excel, go to the Formulas tab and click the Code icon.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flh33wzailfnxm1m08f65.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flh33wzailfnxm1m08f65.png" alt="Step 1" width="800" height="68"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Step 2：&lt;br&gt;
Click the Sign In button, and click it again to proceed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F105p0pb6fejirxqqs07g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F105p0pb6fejirxqqs07g.png" alt="Step 2" width="427" height="618"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Step 3:&lt;br&gt;
By default, Anaconda Code requires you to &lt;a href="https://auth.anaconda.com/ui/registration/71ac082f-35c8-4395-a368-864657d50fce" rel="noopener noreferrer"&gt;sign in&lt;/a&gt; before use. Then, log in using your Anaconda account or sign in with Google, Microsoft, or GitHub.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0t3civdld2y8dy9uhdvw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0t3civdld2y8dy9uhdvw.png" alt="Step 3" width="740" height="1005"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Step 4:&lt;br&gt;
If this is your first time using it, you will need to create an Anaconda Code cell. For this tutorial, we will use the default settings. Click Create Code Cell to continue.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F691arrh89bvcujb8yfmp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F691arrh89bvcujb8yfmp.png" alt="Step 4" width="600" height="1139"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Step 5:&lt;br&gt;
Click the Imports and Definitions icon to import the necessary package. Enter the following to import the required library:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from pyodide.http import pyfetch
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 6:&lt;br&gt;
After that, scroll to the end of the Code tab and paste the provided code snippet:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;async def iplio_query(ip: str, column: str | None = None):
    base_api = 'https://api.ip2location.io/?'
    api_key = 'YOUR_API_KEY'
    full_url = f'{base_api}key={api_key}&amp;amp;ip={ip}'
    resp = await pyfetch(full_url)
    data = await resp.json()
    print(type(data))
    if column is not None:
        print(f'column is {column}')
        response = data[column]
        return response
    return data
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note to the API:&lt;br&gt;
You must upgrade to any paid plan to be able to use our API to bypass the &lt;a href="https://blog.ip2location.com/knowledge-base/understanding-cors-what-is-it-used-for/#devto" rel="noopener noreferrer"&gt;CORS&lt;/a&gt; limitation.&lt;/p&gt;

&lt;p&gt;Step 7:&lt;br&gt;
Click Apply when you are done.&lt;/p&gt;

&lt;p&gt;Step 8:&lt;br&gt;
You can now use the custom function to query the IP2Location.io API for geolocation results. For example, if you have an IP address stored in cell A14, simply enter the following formula in any cell you prefer:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;=ANACONDA.IPLIO_QUERY(A14)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In summary, Anaconda Code enhances Excel by enabling access to external data through Python or R. It is especially useful when you have a list of IP addresses stored in Excel and want to populate accurate geolocation information using a reliable API. In this tutorial, we have demonstrated how to query IP2Location.io, but you can use the same approach with any other API to achieve similar results.&lt;/p&gt;




&lt;p&gt;For more tutorials, please visit &lt;a href="https://blog.ip2location.com/#devto" rel="noopener noreferrer"&gt;IP2Location IP Gelocation&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Where can I find &lt;a href="https://www.ip2location.io/#devto" rel="noopener noreferrer"&gt;free IP Geolocation/Proxy Detection API&lt;/a&gt;?&lt;/p&gt;

&lt;p&gt;Are you looking for &lt;a href="https://lite.ip2location.com/#devto" rel="noopener noreferrer"&gt;free IP Geolocation/Proxy Detection database&lt;/a&gt;?&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>tutorial</category>
      <category>anaconda</category>
      <category>programming</category>
    </item>
    <item>
      <title>Check a list of IP addresses for proxies using IP2Proxy Dart</title>
      <dc:creator>IP2Location</dc:creator>
      <pubDate>Fri, 03 Oct 2025 02:37:30 +0000</pubDate>
      <link>https://dev.to/ip2location/check-a-list-of-ip-addresses-for-proxies-using-ip2proxy-dart-1jck</link>
      <guid>https://dev.to/ip2location/check-a-list-of-ip-addresses-for-proxies-using-ip2proxy-dart-1jck</guid>
      <description>&lt;h2&gt;
  
  
  Intro
&lt;/h2&gt;

&lt;p&gt;Dart is a client-optimized, object-oriented programming language developed by Google for building fast apps on multiple platforms, including mobile, desktop, web, and server-side applications. It is best known as the language behind Flutter, Google’s UI toolkit for creating cross-platform applications. Dart features C-style syntax, modern capabilities like null safety and async-await, and the ability to compile to different machine code and JavaScript targets.&lt;/p&gt;

&lt;p&gt;In this article, we’ll show how to use the IP2Proxy Dart package in a Dart command line (CLI) project to easily query the IP2Proxy BIN files to retrieve proxy data for a list of IP addresses. Our example will be using Debian 13 so some of the steps will be specific for that platform.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pre-requisites
&lt;/h2&gt;

&lt;p&gt;First, install Dart if you don’t have it installed on your system. Refer to &lt;a href="https://dart.dev/get-dart" rel="noopener noreferrer"&gt;https://dart.dev/get-dart&lt;/a&gt; for the installation steps specific to your system. In addition to that, you’ll also need the &lt;strong&gt;IP2Proxy PX12 BIN database files&lt;/strong&gt;, which contain the proxy detection data.  &lt;/p&gt;

&lt;p&gt;You can download the BIN files from the following sources:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Commercial BIN files (full data &amp;amp; accuracy):&lt;/strong&gt; &lt;a href="https://www.ip2location.com/#devto" rel="noopener noreferrer"&gt;IP2Location&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Free LITE BIN files (basic data):&lt;/strong&gt; &lt;a href="https://lite.ip2location.com/#devto" rel="noopener noreferrer"&gt;IP2Location LITE&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 The commercial edition provides the most comprehensive and up-to-date proxy detection, while the LITE edition is a good starting point for testing or smaller projects.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Next, download the zipped file and extract the BIN file to a folder of your choosing. For our case, we are storing the BIN file path as /home/admin/data/IP2PROXY-PX12.BIN so that’s what we’ll use later.&lt;/p&gt;

&lt;h2&gt;
  
  
  Create a new Dart console project
&lt;/h2&gt;

&lt;p&gt;Navigate to the folder where you want to create the new project. In our case, it’s &lt;strong&gt;dartarticle&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Next, run the below command to create an initial Dart console project.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dart create -t console ip2proxy_cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, navigate to the newly created folder.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd ip2proxy_cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqar9jegn8nsm7dqux9qc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqar9jegn8nsm7dqux9qc.png" alt="folder" width="800" height="422"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This creates a small CLI app with bin/ip2proxy_cli.dart as the entrypoint.&lt;/p&gt;

&lt;h2&gt;
  
  
  Include the IP2Proxy Dart as a dependency
&lt;/h2&gt;

&lt;p&gt;Check for the latest version of the &lt;a href="https://pub.dev/packages/ip2proxy/install" rel="noopener noreferrer"&gt;IP2Proxy Dart package&lt;/a&gt; and modify the code below for that version. We are also using the args package for specifying the command line parameters.&lt;/p&gt;

&lt;p&gt;Edit the pubspec.yaml and add the below under the dependencies section:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ip2proxy: ^3.0.0
args: ^2.7.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foh6rmx8ozdq8nsto29hl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foh6rmx8ozdq8nsto29hl.png" alt="Edit the pubspec.yaml" width="516" height="389"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Save the file and run the command below to fetch the dependencies.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dart pub get
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7xp96vxmjvmhub4gva49.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7xp96vxmjvmhub4gva49.png" alt="fetch the dependencies" width="636" height="183"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Implement the command line codes
&lt;/h2&gt;

&lt;p&gt;Edit bin/ip2proxy_cli.dart and replace the existing codes with the codes below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import 'dart:convert';
import 'dart:io';
import 'package:args/args.dart';
import 'package:ip2proxy/ip2proxy.dart';

Future&amp;lt;void&amp;gt; main(List&amp;lt;String&amp;gt; arguments) async {
  final parser = ArgParser()
    ..addOption('db', abbr: 'd', help: 'Path to IP2Proxy BIN database')
    ..addOption('input', abbr: 'i', help: 'Path to file containing IP addresses (or omit for stdin)');

  final results = parser.parse(arguments);

  final dbFile = results['db'] ?? 'IP2PROXY-LITE-PX1.BIN';
  final inputFile = results['input'] ?? '';

  final ipx = IP2Proxy(databasePath: dbFile);

  Stream&amp;lt;List&amp;lt;int&amp;gt;&amp;gt; inputStream;

  if (inputFile.isNotEmpty) {
    final file = File(inputFile);
    if (await file.exists()) {
      inputStream = file.openRead();
    } else {
      stderr.writeln('Error: File not found: $inputFile');
      exit(1);
    }
  } else {
    inputStream = stdin;
  }

  // Print CSV header (quoted)
  print([
    "ipAddress",
    "isProxy",
    "proxyType",
    "countryShort",
    "countryLong",
    "region",
    "city",
    "isp",
    "domain",
    "usageType",
    "asn",
    "as",
    "lastSeen",
    "threat",
    "provider",
    "fraudScore"
  ].map(_csvEscape).join(','));

  // Process line by line
  await for (final ip in inputStream.transform(utf8.decoder).transform(LineSplitter())) {
    final result = await ipx.getAll(ip.trim());
    print([
      result.ipAddress,
      result.isProxy,
      result.proxyType,
      result.countryShort,
      result.countryLong,
      result.region,
      result.city,
      result.isp,
      result.domain,
      result.usageType,
      result.asn,
      result.asName,
      result.lastSeen,
      result.threat,
      result.provider,
      result.fraudScore
    ].map((e) =&amp;gt; _csvEscape(e.toString())).join(','));
  }
}

/// Escapes values for CSV (wraps in quotes if needed, doubles inner quotes)
String _csvEscape(String s) {
  // Always quote, even if not strictly required
  return '"${s.replaceAll('"', '""')}"';
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;User can optionally specify the location of the BIN file using the -d flag. If not specified, the code will look for IP2PROXY-LITE-PX1.BIN instead. Using the optional -i flag, user can make the code read IP addresses from a text file. In the input file, there should be 1 IP address per line. If the input file is not specified, the code will assume &lt;strong&gt;STDIN&lt;/strong&gt; as the input.&lt;/p&gt;

&lt;h2&gt;
  
  
  Test the code
&lt;/h2&gt;

&lt;p&gt;Let’s test the code and make sure everything is working.&lt;/p&gt;

&lt;p&gt;Use the command below to test the code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;echo -e "8.8.8.8" | dart run bin/ip2proxy_cli.dart -d /home/admin/data/IP2PROXY-PX12.BIN
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You’ll see the results below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"ipAddress","isProxy","proxyType","countryShort","countryLong","region","city","isp","domain","usageType","asn","as","lastSeen","threat","provider","fraudScore"
"8.8.8.8","2","DCH","US","United States of America","California","Mountain View","Google LLC","google.com","DCH","15169","Google LLC","1","-","-","0"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwq7mghvdjahhgfyxkr2o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwq7mghvdjahhgfyxkr2o.png" alt="result" width="800" height="46"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Compile into executable binary
&lt;/h2&gt;

&lt;p&gt;To make it easier to distribute to other Linux users, we can go an extra step and compile it into a native executable binary.&lt;/p&gt;

&lt;p&gt;Run the below command in the root of your project folder to compile the code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dart compile exe bin/ip2proxy_cli.dart -o ip2proxy_cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flr17c4z67q0dobuvhy9d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flr17c4z67q0dobuvhy9d.png" alt="compile the code" width="800" height="53"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Run the executable to get your proxy results
&lt;/h2&gt;

&lt;p&gt;Run the executable to get your proxy data similar to our testing command, with just a slight difference. Let’s try piping 2 IP addresses to the program and see.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;echo -e "8.8.8.8\n1.1.1.1" | ./ip2proxy_cli -d /home/admin/data/IP2PROXY-PX12.BIN
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should see the results below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"ipAddress","isProxy","proxyType","countryShort","countryLong","region","city","isp","domain","usageType","asn","as","lastSeen","threat","provider","fraudScore"
"8.8.8.8","2","DCH","US","United States of America","California","Mountain View","Google LLC","google.com","DCH","15169","Google LLC","1","-","-","0"
"1.1.1.1","2","DCH","AU","Australia","Queensland","Brisbane","APNIC and CloudFlare DNS Resolver Project","cloudflare.com","CDN","13335","CloudFlare Inc","1","-","-","0"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzs0ehknqfdnrksblyljg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzs0ehknqfdnrksblyljg.png" alt="result" width="800" height="53"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;We’ve shown a simple example above for piping in the IP address to query for the proxy data. The code above also supports reading the IP addresses from a text file using the -i flag when calling the executable. Give it a try for yourself and you’ll soon find this to be a useful tool to have for a quick check for proxy servers in your IP address list. This feature is especially handy for system administrators who need to analyze web server logs or other log files.&lt;/p&gt;




&lt;p&gt;For more tutorials, please visit &lt;a href="https://blog.ip2location.com/#devto" rel="noopener noreferrer"&gt;IP2Location IP Gelocation&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Where can I find &lt;a href="https://www.ip2location.io/#devto" rel="noopener noreferrer"&gt;free IP Geolocation/Proxy Detection API&lt;/a&gt;?&lt;/p&gt;

&lt;p&gt;Are you looking for &lt;a href="https://lite.ip2location.com/#devto" rel="noopener noreferrer"&gt;free IP Geolocation/Proxy Detection database&lt;/a&gt;?&lt;/p&gt;

</description>
      <category>tutorial</category>
      <category>security</category>
      <category>tooling</category>
      <category>cli</category>
    </item>
    <item>
      <title>Using IP2Location Dart in console project</title>
      <dc:creator>IP2Location</dc:creator>
      <pubDate>Thu, 11 Sep 2025 04:55:01 +0000</pubDate>
      <link>https://dev.to/ip2location/using-ip2location-dart-in-console-project-f0n</link>
      <guid>https://dev.to/ip2location/using-ip2location-dart-in-console-project-f0n</guid>
      <description>&lt;h2&gt;
  
  
  Intro
&lt;/h2&gt;

&lt;p&gt;Dart is a client-optimized, object-oriented programming language developed by Google for building fast apps on multiple platforms, including mobile, desktop, web, and server-side applications. It is best known as the language behind Flutter, Google's UI toolkit for creating cross-platform applications. Dart features C-style syntax, modern capabilities like null safety and async-await, and the ability to compile to different machine code and JavaScript targets.&lt;/p&gt;

&lt;p&gt;In this article, we’ll show how to use the IP2Location Dart package in a Dart command line (CLI) project to easily query the IP2Location BIN files to retrieve geolocation data for an IPv4 or IPv6 address. Our example will be using Debian 13 so some of the steps will be specific for that platform.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pre-requisites
&lt;/h2&gt;

&lt;p&gt;First, install Dart if you don’t have it installed on your system. Refer to &lt;a href="https://dart.dev/get-dart" rel="noopener noreferrer"&gt;https://dart.dev/get-dart&lt;/a&gt; for the installation steps specific to your system. In addition to that, you’ll also need the IP2Location DB26 BIN database files that contains the geolocation data. You can download the &lt;a href="https://www.ip2location.com/#devto" rel="noopener noreferrer"&gt;IP2Location Commercial BIN files&lt;/a&gt; or the &lt;a href="https://lite.ip2location.com/#devto" rel="noopener noreferrer"&gt;Free LITE BIN files&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Download the zipped file and extract the BIN file to a folder of your choosing. For our case, we are storing the BIN file path as &lt;strong&gt;/home/admin/data/IP2LOCATION-DB26.IPV6.BIN&lt;/strong&gt; so that’s what we’ll use later.&lt;/p&gt;

&lt;h2&gt;
  
  
  Create a new Dart console project
&lt;/h2&gt;

&lt;p&gt;Navigate to the folder where you want to create the new project. In our case, it’s &lt;strong&gt;dartarticle&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Next, run the below command to create an initial Dart console project.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dart create -t console ip2location_cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, navigate to the newly created folder.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd ip2location_cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This creates a small CLI app with bin/ip2location_cli.dart as the entrypoint.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0syc6xo1gh9osz38pjv6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0syc6xo1gh9osz38pjv6.png" alt="CLI app" width="800" height="388"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Include the IP2Location Dart as a dependency
&lt;/h2&gt;

&lt;p&gt;Check for the latest version of the &lt;a href="https://pub.dev/packages/ip2location/install" rel="noopener noreferrer"&gt;IP2Location Dart package&lt;/a&gt; and modify the code below for that version. We are also using the &lt;a href="https://pub.dev/packages/args" rel="noopener noreferrer"&gt;args package&lt;/a&gt; for specifying the command line parameters.&lt;/p&gt;

&lt;p&gt;Edit the pubspec.yaml and add the below under the dependencies section:&lt;/p&gt;

&lt;p&gt;ip2location: ^8.1.0&lt;br&gt;
args: ^2.7.0&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi49pxa8bka19qhkd0i9x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi49pxa8bka19qhkd0i9x.png" alt="yaml" width="525" height="394"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Save the file and run the command below to fetch the dependencies.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dart pub get
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb0ki9l7cteeyw5bpxix6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb0ki9l7cteeyw5bpxix6.png" alt="dependencies" width="659" height="186"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Implement the command line codes
&lt;/h2&gt;

&lt;p&gt;Edit &lt;strong&gt;bin/ip2location_cli.dart&lt;/strong&gt; and replace the existing codes with the codes below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import 'dart:io';
import 'package:args/args.dart';
import 'package:ip2location/ip2location.dart';

void main(List&amp;lt;String&amp;gt; arguments) async {
  final parser = ArgParser()
    ..addOption('db', abbr: 'd', help: 'Path to IP2Location BIN database');
  final results = parser.parse(arguments);

  if (results.rest.isEmpty) {
    print('Usage: ip2location_cli &amp;lt;IP&amp;gt; -d &amp;lt;DB_PATH&amp;gt;');
    exit(1);
  }

  final ip = results.rest[0];
  final dbFile = results['db'] ?? 'IP2LOCATION-LITE-DB1.BIN';

  IP2Location ipl = IP2Location(databasePath: dbFile);

  try {
    final result = await ipl.getAll(ip);

    print('IP Address: ${ip}');
    print('countryShort: ${result.countryShort}');
    print('countryLong: ${result.countryLong}');
    print('region: ${result.region}');
    print('city: ${result.city}');
    print('isp: ${result.isp}');
    print('latitude: ${result.latitude?.toStringAsFixed(6)}');
    print('longitude: ${result.longitude?.toStringAsFixed(6)}');
    print('domain: ${result.domain}');
    print('zipCode: ${result.zipCode}');
    print('netSpeed: ${result.netSpeed}');
    print('timeZone: ${result.timeZone}');
    print('iddCode: ${result.iddCode}');
    print('areaCode: ${result.areaCode}');
    print('weatherStationCode: ${result.weatherStationCode}');
    print('weatherStationName: ${result.weatherStationName}');
    print('mcc: ${result.mcc}');
    print('mnc: ${result.mnc}');
    print('mobileBrand: ${result.mobileBrand}');
    print('elevation: ${result.elevation}');
    print('usageType: ${result.usageType}');
    print('addressType: ${result.addressType}');
    print('category: ${result.category}');
    print('district: ${result.district}');
    print('asn: ${result.asn}');
    print('asName: ${result.asName}');
    print('asDomain: ${result.asDomain}');
    print('asUsageType: ${result.asUsageType}');
    print('asCIDR: ${result.asCIDR}');
  } catch (e) {
    stderr.writeln('Error looking up IP: $e');
    exit(1);
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The code accepts the first parameter as the IP address to query for geolocation. User can also optionally specify the location of the BIN file using the &lt;strong&gt;-d&lt;/strong&gt; flag. If not specified, the code will look for &lt;strong&gt;IP2LOCATION-LITE-DB1.BIN&lt;/strong&gt; instead.&lt;/p&gt;

&lt;h2&gt;
  
  
  Test the code
&lt;/h2&gt;

&lt;p&gt;Let’s test the code and make sure everything is working.&lt;/p&gt;

&lt;p&gt;Use the command below to test the code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dart run bin/ip2location_cli.dart 8.8.8.8 -d /home/admin/data/IP2LOCATION-DB26.IPV6.BIN
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You’ll see the results below.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;IP Address: 8.8.8.8&lt;br&gt;
countryShort: US&lt;br&gt;
countryLong: United States of America&lt;br&gt;
region: California&lt;br&gt;
city: Mountain View&lt;br&gt;
isp: Google LLC&lt;br&gt;
latitude: 37.386051&lt;br&gt;
longitude: -122.083847&lt;br&gt;
domain: google.com&lt;br&gt;
zipCode: 94035&lt;br&gt;
netSpeed: T1&lt;br&gt;
timeZone: -07:00&lt;br&gt;
iddCode: 1&lt;br&gt;
areaCode: 650&lt;br&gt;
weatherStationCode: USCA0746&lt;br&gt;
weatherStationName: Mountain View&lt;br&gt;
mcc: -&lt;br&gt;
mnc: -&lt;br&gt;
mobileBrand: -&lt;br&gt;
elevation: 32.0&lt;br&gt;
usageType: DCH&lt;br&gt;
addressType: A&lt;br&gt;
category: IAB19-11&lt;br&gt;
district: Santa Clara County&lt;br&gt;
asn: 15169&lt;br&gt;
asName: Google LLC&lt;br&gt;
asDomain: google.com&lt;br&gt;
asUsageType: DCH&lt;br&gt;
asCIDR: 8.8.8.0/24&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9t68n7l19no84umuq3fn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9t68n7l19no84umuq3fn.png" alt="result" width="800" height="356"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Compile into executable binary
&lt;/h2&gt;

&lt;p&gt;To make it easier to distribute to other Linux users, we can go an extra step and compile it into a native executable binary.&lt;/p&gt;

&lt;p&gt;Run the below command in the root of your project folder to compile the code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dart compile exe bin/ip2location_cli.dart -o ip2location_cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F920yuv5enn06yov53ffa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F920yuv5enn06yov53ffa.png" alt="compilation" width="800" height="44"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Run the executable to get your geolocation results
&lt;/h2&gt;

&lt;p&gt;Run the executable to get your geolocation similar to our testing command, with just a slight difference. You should see the same results.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;./ip2location_cli 8.8.8.8 -d /home/admin/data/IP2LOCATION-DB26.IPV6.BIN
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz5kbqcl2g44bxklr388t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz5kbqcl2g44bxklr388t.png" alt="Final result" width="800" height="388"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;It is very straightforward to call the IP2Location Dart package in your code as we’ve shown above. So, no reason why you can’t include geolocation functionality into your Dart programs or apps. This will seriously enhance the functionality of your codes.&lt;/p&gt;




&lt;p&gt;For more tutorials, please visit &lt;a href="https://blog.ip2location.com/#devto" rel="noopener noreferrer"&gt;IP2Location IP Gelocation&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Where can I find &lt;a href="https://www.ip2location.io/#devto" rel="noopener noreferrer"&gt;free IP Geolocation API&lt;/a&gt;?&lt;/p&gt;

&lt;p&gt;Where can I get &lt;a href="https://lite.ip2location.com/#devto" rel="noopener noreferrer"&gt;free IP Geolocation database&lt;/a&gt;?&lt;/p&gt;

</description>
      <category>dart</category>
      <category>webdev</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Displaying User’s Local Time with DST Adjustment via IP2Location.io</title>
      <dc:creator>IP2Location</dc:creator>
      <pubDate>Tue, 02 Sep 2025 02:17:41 +0000</pubDate>
      <link>https://dev.to/ip2location/displaying-users-local-time-with-dst-adjustment-via-ip2locationio-12cd</link>
      <guid>https://dev.to/ip2location/displaying-users-local-time-with-dst-adjustment-via-ip2locationio-12cd</guid>
      <description>&lt;p&gt;Displaying local time correctly is crucial for both website owners and visitors. By showing the local time, including daylight saving adjustments on a website, visitors can understand date and time information accurately. This improves clarity for time-sensitive content and helps minimize potential confusion or misunderstandings.&lt;/p&gt;

&lt;p&gt;Incorrect timezone usage can lead to various issues and inconveniences. For example, users might misinterpret important information such as delivery dates or the start and end times of a promotional event. Inaccurate timezone handling can also cause miscommunication. Imagine a scenario where one person is in the United States and another is in Japan, with an online meeting scheduled at 2:00 PM UTC+0. If either side misreads the time, they could end up missing the meeting entirely.&lt;/p&gt;

&lt;p&gt;To help users identify the correct timezone and handle Daylight Saving Time (DST) effectively, IP2Location.io had recently introduced new fields in the API response, namely abbreviation, dst_start_date, and dst_end_date. These, combined with the existing timezone information, enable developers to manage datetime data across multiple regions effectively and effortlessly. &lt;/p&gt;

&lt;h2&gt;
  
  
  Using IP2Location.io to Get Timezone Info
&lt;/h2&gt;

&lt;p&gt;To get the result that contains the new fields, you just need to call the API again, for example &lt;a href="https://api.ip2location.io/?key=%7BYOUR_API_KEY%7D&amp;amp;ip=8.8.8.8&amp;amp;format=json" rel="noopener noreferrer"&gt;https://api.ip2location.io/?key={YOUR_API_KEY}&amp;amp;ip=8.8.8.8&amp;amp;format=json&lt;/a&gt; for the IP 8.8.8.8. You will see the output as below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "ip": "8.8.8.8",
  "country_code": "US",
  "country_name": "United States of America",
  "region_name": "California",
  "district": "Santa Clara County",
  "city_name": "Mountain View",
  "latitude": 37.38605,
  "longitude": -122.08385,
  "zip_code": "94035",
  "time_zone": "-07:00",
  "asn": "15169",
  "as": "Google LLC",
  "isp": "Google LLC",
  "domain": "google.com",
  "net_speed": "T1",
  "idd_code": "1",
  "area_code": "650",
  "weather_station_code": "USCA0746",
  "weather_station_name": "Mountain View",
  "mcc": "-",
  "mnc": "-",
  "mobile_brand": "-",
  "elevation": 32,
  "usage_type": "DCH",
  "address_type": "Anycast",
  "ads_category": "IAB19-11",
  "ads_category_name": "Data Centers",
  "continent": {
    "name": "North America",
    "code": "NA",
    "hemisphere": [
      "north",
      "west"
    ],
    "translation": {
      "lang": null,
      "value": null
    }
  },
  "country": {
    "name": "United States of America",
    "alpha3_code": "USA",
    "numeric_code": 840,
    "demonym": "Americans",
    "flag": "https://cdn.ip2location.io/assets/img/flags/us.png",
    "capital": "Washington, D.C.",
    "total_area": 9826675,
    "population": 339665118,
    "currency": {
      "code": "USD",
      "name": "United States Dollar",
      "symbol": "$"
    },
    "language": {
      "code": "EN",
      "name": "English"
    },
    "tld": "us",
    "translation": {
      "lang": null,
      "value": null
    }
  },
  "region": {
    "name": "California",
    "code": "US-CA",
    "translation": {
      "lang": null,
      "value": null
    }
  },
  "city": {
    "name": "Mountain View",
    "translation": {
      "lang": null,
      "value": null
    }
  },
  "time_zone_info": {
    "olson": "America/Los_Angeles",
    "current_time": "2025-07-30T21:08:34-07:00",
    "gmt_offset": -25200,
    "is_dst": true,
    "abbreviation": "PDT",
    "dst_start_date": "2025-03-09",
    "dst_end_date": "2025-11-02",
    "sunrise": "06:11",
    "sunset": "20:18"
  },
  "geotargeting": {
    "metro": "807"
  },
  "is_proxy": false,
  "fraud_score": 0,
  "proxy": {
    "last_seen": 1,
    "proxy_type": "DCH",
    "threat": "-",
    "provider": "-",
    "is_vpn": false,
    "is_tor": false,
    "is_data_center": true,
    "is_public_proxy": false,
    "is_web_proxy": false,
    "is_web_crawler": false,
    "is_residential_proxy": false,
    "is_consumer_privacy_network": false,
    "is_enterprise_private_network": false,
    "is_spammer": false,
    "is_scanner": false,
    "is_botnet": false,
    "is_bogon": false
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note: The abbreviation, dst_start, and dst_end fields are only available for the Plus and Security plan user. Please purchase the plan before proceeding.&lt;/p&gt;

&lt;h2&gt;
  
  
  Convert UTC to Local Time
&lt;/h2&gt;

&lt;p&gt;To convert a UTC timestamp to the user’s local time, you can use the time_zone_info &amp;gt;&amp;gt; olson&lt;/p&gt;

&lt;p&gt;value (e.g., America/New_York) returned from the IP2Location.io API. Most modern programming languages have built-in libraries that allow you to apply this timezone directly to a UTC datetime, automatically adjusting for daylight saving time if applicable.&lt;/p&gt;

&lt;p&gt;Below are the example code snippet that can be used to convert a UTC time to local time:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php
$apiKey = 'YOUR_API_KEY';
$ip = $_SERVER['REMOTE_ADDR'];

// Call the IP2Location.io API
$apiUrl = "https://api.ip2location.io/?key=$apiKey&amp;amp;ip=$ip";
$response = file_get_contents($apiUrl);
$data = json_decode($response, true);

// Get the Olson timezone from time_zone_info
$olson = $data['time_zone_info']['olson'] ?? 'UTC';

// Create and format local time
$utcTime = new DateTime('now', new DateTimeZone('UTC'));
$localTime = $utcTime-&amp;gt;setTimezone(new DateTimeZone($olson));

echo "Local time in $olson: " . $localTime-&amp;gt;format('Y-m-d H:i:s T');
?&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import requests
from datetime import datetime
from zoneinfo import ZoneInfo  # Python 3.9+

api_key = "YOUR_API_KEY"
ip = "8.8.8.8"  # Example, can change accordingly

# Fetch data from IP2Location.io
response = requests.get(f"https://api.ip2location.io/?key={api_key}&amp;amp;ip={ip}")
data = response.json()

# Extract Olson timezone
olson = data.get("time_zone_info", {}).get("olson", "UTC")

# Convert and format local time
utc_now = datetime.now().replace(tzinfo=ZoneInfo("UTC"))
local_time = utc_now.astimezone(ZoneInfo(olson))

print(f"Local time in {olson}: {local_time.strftime('%Y-%m-%d %H:%M:%S %Z')}")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const fetch = require('node-fetch');
const { DateTime } = require('luxon'); // Both are installable using npm install node-fetch@2 luxon

const apiKey = 'YOUR_API_KEY';
const ip = '8.8.8.8'; // Replace with actual IP

(async () =&amp;gt; {
  const response = await fetch(`https://api.ip2location.io/?key=${apiKey}&amp;amp;ip=${ip}`);
  const data = await response.json();

  const olson = data.time_zone_info?.olson || 'UTC';

  const localTime = DateTime.utc().setZone(olson);
  console.log(`Local time in ${olson}: ${localTime.toFormat('yyyy-MM-dd HH:mm:ss ZZZZ')}`);
})();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Handling DST &amp;amp; Display Time on Website
&lt;/h2&gt;

&lt;p&gt;The dst_start and dst_end fields definitely come in handy especially if you need to solve the time issue in the countries that are observing DST. By utilizing both fields, you can easily determine whether the country is currently observing DST.&lt;/p&gt;

&lt;p&gt;Nowadays, most timezone libraries automatically take into account when calculating the local time for those countries that are observing DST. Most of the time, by using the library, you will not have a problem getting the accurate local time calculated with the DST factored in. However, sometimes the government may choose to continue observing the DST in the upcoming year or not. If the libraries haven’t been updated to handle the changes, you still can use IP2Location.io API result to make a quick check on whether the DST is in effect or not.&lt;/p&gt;

&lt;p&gt;Below is a simple example of how to show the formatted local time in a website:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php
// Replace with your actual API key
$apiKey = 'YOUR_API_KEY';
// Get the user's IP address (fallbacks to REMOTE_ADDR if not behind proxy)
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'] ?? $_SERVER['REMOTE_ADDR'];

// Call IP2Location.io API
$apiUrl = "https://api.ip2location.io/?key=$apiKey&amp;amp;ip=$ip";
$response = file_get_contents($apiUrl);
$data = json_decode($response, true);

// Fallback timezone
$timezone = $data['timezone'] ?? 'UTC';

// Create datetime in user's local timezone
$utc = new DateTime('now', new DateTimeZone('UTC'));
$local = $utc-&amp;gt;setTimezone(new DateTimeZone($timezone));
$formattedTime = $local-&amp;gt;format('Y-m-d H:i:s T');
?&amp;gt;
&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
  &amp;lt;title&amp;gt;Local Time Display&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
  &amp;lt;p&amp;gt;Your local time is: &amp;lt;strong&amp;gt;&amp;lt;?php echo $formattedTime; ?&amp;gt;&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Displaying accurate local time for your user isn’t a difficult task. With IP2Location.io IP Geolocation API, you can easily achieve the mission in a few steps, starting with detecting the user’s IP address, fetching the timezone information, and converting and displaying the local time. The &lt;a href="https://www.ip2location.io/#devto" rel="noopener noreferrer"&gt;IP2Location.io API&lt;/a&gt; will benefit you in many ways, such as improving user experience, ensuring effective communication, and delivering accurate datetime information — including adjustments for daylight saving time where applicable.&lt;/p&gt;




&lt;p&gt;For more tutorials, please visit &lt;a href="https://blog.ip2location.com/#devto" rel="noopener noreferrer"&gt;IP2Location IP Gelocation&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Where can I find &lt;a href="https://www.ip2location.io/#devto" rel="noopener noreferrer"&gt;free IP Geolocation API&lt;/a&gt;?&lt;/p&gt;

&lt;p&gt;Where can I get &lt;a href="https://lite.ip2location.com/#devto" rel="noopener noreferrer"&gt;free IP Geolocation database&lt;/a&gt;?&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Using IP2Location MMDB inside Wireshark for geolocation</title>
      <dc:creator>IP2Location</dc:creator>
      <pubDate>Fri, 20 Jun 2025 09:32:30 +0000</pubDate>
      <link>https://dev.to/ip2location/using-ip2location-mmdb-inside-wireshark-for-geolocation-26eh</link>
      <guid>https://dev.to/ip2location/using-ip2location-mmdb-inside-wireshark-for-geolocation-26eh</guid>
      <description>&lt;p&gt;Wireshark is a powerful, open-source network protocol analyzer used to capture and inspect data traveling through a network in real time. It's commonly used by network administrators, security professionals, developers, and IT engineers for tasks such as network troubleshooting and security analysis. With the newly released IP2Location MMDB, users can now enhance their network traffic analysis by integrating IP geolocation data directly within Wireshark.&lt;/p&gt;

&lt;p&gt;One useful feature that is beneficial for troubleshooting and analysis is the ability to get geolocation data for the IP addresses found in the network packets. Wireshark does this by querying MaxMind’s GeoIP2 or GeoLite2 databases which comes in the MMDB format. This format was created for fast IP address lookups.&lt;/p&gt;

&lt;h2&gt;
  
  
  IP2Location now includes MMDB format
&lt;/h2&gt;

&lt;p&gt;Now, users of the IP2Location’s geolocation databases have the ability to download data in the MMDB format so they can easily use IP2Location’s data within Wireshark. There are 3 MMDB files supplied by IP2Location that corresponds to the equivalent MaxMind files. They are the LITE DB1 (equivalent of GeoLite2 Country), LITE DB9 (equivalent of GeoLite2 City) and LITE ASN (equivalent of GeoLite2 ASN). For this article, we’ll focus on the free IP2Location LITE DB9 &amp;amp; ASN MMDB databases to show how to query geolocation data within Wireshark.&lt;/p&gt;

&lt;h2&gt;
  
  
  Installing Wireshark
&lt;/h2&gt;

&lt;p&gt;In order to follow our guide below, you will need to install Wireshark for your operating system. For our demo, we’ll be using Windows 11, hence we’ll &lt;a href="https://www.wireshark.org/download.html" rel="noopener noreferrer"&gt;install the relevant Wireshark version&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Download the IP2Location LITE DB9 &amp;amp; ASN MMDB databases
&lt;/h2&gt;

&lt;p&gt;Now, we need to download the IP2Location LITE DB9 &amp;amp; ASN MMDB databases so we can perform city-level geolocation &amp;amp; ASN queries inside Wireshark. You can sign up and download the free LITE DB9 &amp;amp; ASN MMDB files from &lt;a href="https://lite.ip2location.com/ip2location-lite" rel="noopener noreferrer"&gt;https://lite.ip2location.com/ip2location-lite#devto&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Under the IP2Location Database tab, download the LITE DB9 MMDB file.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fovjiz07rf1v270svda19.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fovjiz07rf1v270svda19.jpg" alt="Using IP2Location MMDB inside Wireshark" width="800" height="302"&gt;&lt;/a&gt;&lt;br&gt;
After downloading the zipped file, extract the IP2LOCATION-LITE-DB9.MMDB and store it in a folder called C:\TestWireShark. Create the folder if it doesn’t exist.&lt;/p&gt;

&lt;p&gt;Next, we’ll download the LITE ASN MMDB file under the ASN Database tab.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa6pn9m0ccfu1vqesjwhs.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa6pn9m0ccfu1vqesjwhs.jpg" alt="Using IP2Location MMDB inside Wireshark" width="800" height="138"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After downloading the zipped file, extract the IP2LOCATION-LITE-ASN.MMDB and store it in the same folder as above.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;WARNING&lt;/strong&gt;: You will need to rename both files so that the file extension is .mmdb instead of .MMDB as Wireshark will not be able to read the files if the file extension is in upper case.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw21p3r69ns9gfoztx1e8.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw21p3r69ns9gfoztx1e8.jpg" alt="Using IP2Location MMDB inside Wireshark" width="800" height="174"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Configure Wireshark to enable the IP geolocation feature
&lt;/h2&gt;

&lt;p&gt;Launch Wireshark then in the menu bar, click on Edit -&amp;gt; Preferences.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fylx6gdb5ehu29n298v5n.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fylx6gdb5ehu29n298v5n.jpg" alt="launch wireshark" width="800" height="650"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Inside the Preferences, click on Name Resolution on the left-hand side. Then, click on Edit next to the MaxMind database directories.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fphlficv1brr044arbsyk.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fphlficv1brr044arbsyk.jpg" alt="name resoution" width="800" height="509"&gt;&lt;/a&gt;&lt;br&gt;
Add the path to our folder from above inside the MaxMind Database Paths. This is so that Wireshark knows where to look for the MMDB files to query.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsa7yhw83tnmcvmnv5l80.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsa7yhw83tnmcvmnv5l80.jpg" alt="add path" width="800" height="462"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Keep pressing OK until you are back in the main Wireshark window.&lt;/p&gt;

&lt;h2&gt;
  
  
  Choose which network adapter to capture traffic
&lt;/h2&gt;

&lt;p&gt;Double-click on the network adapter that you wish to capture traffic from. In our case, it is Wi-Fi.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fozaa3zywkvc5sa3edh2c.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fozaa3zywkvc5sa3edh2c.jpg" alt="Wifi adapter" width="800" height="253"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It should start to capture network traffic like below from the Wi-Fi adapter.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn1i63ab5dvnv716rxug0.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn1i63ab5dvnv716rxug0.jpg" alt="Capturing" width="800" height="474"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s stop the data capture and analyse the data&lt;/p&gt;

&lt;p&gt;Once we’ve collected enough network traffic, press the Stop capturing packets button and take a closer look at the geolocation data for the IP addresses in the captured data. Click on one of the lines of traffic, then click on Internet Protocol Version 6 and you’ll see the below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiisel5md420gul6qplaa.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiisel5md420gul6qplaa.jpg" alt="Geolocation" width="800" height="474"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can see that the source of the traffic is coming from Sydney in Australia while the Autonomous System (AS) shows that the IP belongs to Google. Meanwhile, you can see that the destination for the traffic is Bayan Lepas in Malaysia and the AS is telling us that the IP is from TM Technology Services.&lt;/p&gt;

&lt;h2&gt;
  
  
  View geolocation for all endpoints
&lt;/h2&gt;

&lt;p&gt;Viewing a single line of traffic may or may not be useful depending on your goals. Wireshark has the ability to display geolocation for all of the endpoints captured. Let’s take a look. In the menu bar, click on Statistics -&amp;gt; Endpoints.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7wbclk1fb8sceu5immya.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7wbclk1fb8sceu5immya.jpg" alt="Endpoints" width="800" height="707"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Inside, you can click on the IPv4 or the IPv6 tab and you can view the related geolocation data along with the Autonomous System (AS) info. This overview is a great way to quickly spot anomalous data or suspicious traffic.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F06ivjz1dwdqz9h5col2p.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F06ivjz1dwdqz9h5col2p.jpg" alt="IPv4" width="800" height="364"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcuucjurr4v8a23sd5897.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcuucjurr4v8a23sd5897.jpg" alt="IPv6" width="800" height="364"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Visualize the geolocation on a map
&lt;/h2&gt;

&lt;p&gt;Sometimes, you just need a form of visualization to do your job more efficiently. Fortunately, Wireshark can easily plot the geolocation on a map for your viewing pleasure. Click on Map -&amp;gt; Open in browser.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm92czu141h8krehq9ors.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm92czu141h8krehq9ors.jpg" alt="Open map" width="800" height="364"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can now see the geolocation data rendered on a map below. With just a glance, you can easily see if you have traffic coming from any region that you don’t expect to receive traffic.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F21ceiiawwu8v1a251isa.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F21ceiiawwu8v1a251isa.jpg" alt="map" width="800" height="451"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Use geolocation to filter the traffic data
&lt;/h2&gt;

&lt;p&gt;The geolocation data is also handy if you wish to filter your captured traffic data. This could be especially useful when you are doing network troubleshooting. No point viewing unrelated traffic.&lt;/p&gt;

&lt;p&gt;Let’s close the Endpoints window and go back to the main window. For example, if I want to filter traffic coming from Sydney, I can just right-click on the city name and click Prepare as filter -&amp;gt; Selected.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fke7l8635xv6aryxn9yw0.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fke7l8635xv6aryxn9yw0.jpg" alt="filter city" width="800" height="474"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You’ll now see the below with the filter created in the green bar below. Just press the arrow at the end of the green bar to apply the filter.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foza1hl1myi0h6cbu5lls.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foza1hl1myi0h6cbu5lls.jpg" alt="apply filter" width="800" height="474"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, you will only see traffic coming from Sydney.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F18rbvavjwnv9sp9qvmoz.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F18rbvavjwnv9sp9qvmoz.jpg" alt="Sydney traffic" width="800" height="474"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;It is that simple to use IP2Location LITE DB9 and ASN MMDB files in Wireshark to provide geolocation and ASN data enrichment. Hopefully, this article can guide IP2Location users to fully utilize the power of IP2Location within Wireshark.&lt;/p&gt;

&lt;h2&gt;
  
  
  Disclaimer
&lt;/h2&gt;

&lt;p&gt;MaxMind and GeoIP are registered trademarks of MaxMind, Inc. Wireshark and the “fin” logo are registered trademarks of the Wireshark Foundation.&lt;/p&gt;




&lt;p&gt;For more tutorials, please visit &lt;a href="https://blog.ip2location.com/#devto" rel="noopener noreferrer"&gt;IP2Location IP Gelocation&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Where can I find &lt;a href="https://www.ip2location.io/#devto" rel="noopener noreferrer"&gt;free IP Geolocation API&lt;/a&gt;?&lt;/p&gt;

&lt;p&gt;Where can I get &lt;a href="https://lite.ip2location.com/#devto" rel="noopener noreferrer"&gt;free IP Geolocation database&lt;/a&gt;?&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>database</category>
      <category>tutorial</category>
      <category>programming</category>
    </item>
    <item>
      <title>How to use IP2Location.io and IP2WHOIS in Django?</title>
      <dc:creator>IP2Location</dc:creator>
      <pubDate>Tue, 20 Aug 2024 05:04:05 +0000</pubDate>
      <link>https://dev.to/ip2location/how-to-use-ip2locationio-and-ip2whois-in-django-c08</link>
      <guid>https://dev.to/ip2location/how-to-use-ip2locationio-and-ip2whois-in-django-c08</guid>
      <description>&lt;p&gt;Django is a widely-used, free and open source web framework built in Python. It allows web developers to get started to build their website easily. Furthermore, to support their web application development, developers will have numerous external packages to choose from. Those packages can help with improving the user experience and reducing hassle for managing a website. For example, a site admin can use packages to detect where their site visitors are coming from. Such information will help with designing region-specific content. In this article, we will show you how to use IP2Location.io and IP2WHOIS API to perform geolocation and domain WHOIS lookup in Django.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisite
&lt;/h2&gt;

&lt;p&gt;Before we start, you will be required to install the following components into your server.&lt;/p&gt;

&lt;h2&gt;
  
  
  IP2Location.io Python SDK
&lt;/h2&gt;

&lt;p&gt;To perform geolocation lookup, you need to install it using this command: &lt;code&gt;pip install ip2location-io&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  IP2WHOIS Python SDK
&lt;/h2&gt;

&lt;p&gt;To perform domain WHOIS lookup, you need to install it using this command: &lt;code&gt;pip install IP2WHOIS&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;You will also need a IP2Location.io API key to perform any type of lookup. You can &lt;a href="https://www.ip2location.io/sign-up#devto" rel="noopener noreferrer"&gt;sign up for a free API key&lt;/a&gt;, or purchase a plan according to your need.&lt;/p&gt;

&lt;h2&gt;
  
  
  Steps
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Step 1:&lt;/strong&gt;&lt;br&gt;
Open your terminal, and create a new Django project by using the following command:&lt;br&gt;
&lt;code&gt;django-admin startproject mysite&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2:&lt;/strong&gt;&lt;br&gt;
A new folder with the name mysite will be created. Cd to the folder, and type the following command to create a new Django app:&lt;br&gt;
&lt;code&gt;python manage.py startapp myapp&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3:&lt;/strong&gt;&lt;br&gt;
We will then start to create the view of the app. Open the &lt;em&gt;mysite/myapp/views.py&lt;/em&gt; file, and add the following code into the file:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

from django.shortcuts import render
from django.template import loader
import ip2locationio
import ip2whois

# Create your views here.
from django.http import HttpResponse

from django.shortcuts import redirect

def get_client_ip(request):
    x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR')
    if x_forwarded_for:
        ip = x_forwarded_for.split(',')[0]
    else:
        ip = request.META.get('REMOTE_ADDR')
    return ip

def geolocation_lookup(request):

    template = loader.get_template('myapp/view-ip2locationio-result.html')
    ip = get_client_ip(request)
    if ip == '127.0.0.1': # Only define the IP if you are testing on localhost.
        ip = '8.8.8.8'

    # Configures IP2Location.io API key
    configuration = ip2locationio.Configuration('YOUR_API_KEY')
    ipgeolocation = ip2locationio.IPGeolocation(configuration)

    rec = ipgeolocation.lookup(ip)
    context = {
        'ip': ip,
        'country_code': rec['country_code'],
        'country_name': rec['country_name'],
        'region_name': rec['region_name'],
        'city_name': rec['city_name'],
        'latitude': rec['latitude'],
        'longitude': rec['longitude'],
        'zip_code': rec['zip_code'],
        'time_zone': rec['time_zone'],
        'asn': rec['asn'],
        'asname': rec['as'],
        'is_proxy': 'True' if rec['is_proxy'] else 'False',
    }

    return HttpResponse(template.render(context, request))

def whois_lookup(request):

    template = loader.get_template('myapp/view-ip2whois-result.html')
    domain = "locaproxy.com" # We will use a fixed value for domain name in this tutorial, but you can always change it to accept input from a form or url.
    # Configures IP2WHOIS API key
    ip2whois_init = ip2whois.Api('YOUR_API_KEY')

    # Lookup domain information
    results = ip2whois_init.lookup(domain)

    # Convert JSON to Python dictionary
    # data = json.loads(results)

    # Pass the data to the template
    return HttpResponse(template.render(results, request))


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Step 4:&lt;/strong&gt;&lt;br&gt;
In the same directory, create a new file called &lt;em&gt;urls.py&lt;/em&gt;. Open this file, and add the following code into it:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

from django.urls import path

from . import views

urlpatterns = [
    path('lookup', views.geolocation_lookup, name='geolocation_lookup'),
    path('whoislookup', views.whois_lookup, name='whois_lookup'),
]


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Step 5:&lt;/strong&gt;&lt;br&gt;
We will also need to create a template file for displaying the result. Under the &lt;em&gt;myapp_folder, create a new folder called _templates&lt;/em&gt;, and under the templates folder create another new folder called &lt;em&gt;myapp&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 6:&lt;/strong&gt;&lt;br&gt;
Inside the mysite/myapp/templates/myapp folder, create two new html files called &lt;em&gt;view-ip2locationio-result.html&lt;/em&gt; and &lt;em&gt;view-ip2whois-result.html&lt;/em&gt;. Copy the following code into both html files:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

&amp;lt;!-- view-ip2locationio-result.html --&amp;gt;
&amp;lt;html&amp;gt;
   &amp;lt;head&amp;gt;
        &amp;lt;title&amp;gt;View IP2Location.io result&amp;lt;/title&amp;gt;
   &amp;lt;/head&amp;gt;
   &amp;lt;body&amp;gt;
      &amp;lt;p&amp;gt;IP: {{ip}}&amp;lt;/p&amp;gt;
      &amp;lt;p&amp;gt;Country Code: {{country_code}}&amp;lt;/p&amp;gt;
      &amp;lt;p&amp;gt;Country Name : {{country_name}}&amp;lt;/p&amp;gt;
      &amp;lt;p&amp;gt;Region Name: {{region_name}}&amp;lt;/p&amp;gt;
      &amp;lt;p&amp;gt;City Name: {{city_name}}&amp;lt;/p&amp;gt;
      &amp;lt;p&amp;gt;Latitude: {{latitude}}&amp;lt;/p&amp;gt;
      &amp;lt;p&amp;gt;Longitude: {{longitude}}&amp;lt;/p&amp;gt;
      &amp;lt;p&amp;gt;ZIP Code: {{zip_code}}&amp;lt;/p&amp;gt;
      &amp;lt;p&amp;gt;Time Zone: {{time_zone}}&amp;lt;/p&amp;gt;
      &amp;lt;p&amp;gt;ASN: {{asn}}&amp;lt;/p&amp;gt;
      &amp;lt;p&amp;gt;AS Name: {{asname}}&amp;lt;/p&amp;gt;
      &amp;lt;p&amp;gt;Is Proxy: {{is_proxy}}&amp;lt;/p&amp;gt;
   &amp;lt;/body&amp;gt;

&amp;lt;/html&amp;gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

&amp;lt;!-- view-ip2whois-result.html --&amp;gt;
&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;title&amp;gt;Domain Information: {{ domain }}&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;h1&amp;gt;Domain Information for {{ domain }}&amp;lt;/h1&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Domain ID:&amp;lt;/strong&amp;gt; {{ domain_id }}&amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Status:&amp;lt;/strong&amp;gt; {{ status }}&amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Creation Date:&amp;lt;/strong&amp;gt; {{ create_date }}&amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Update Date:&amp;lt;/strong&amp;gt; {{ update_date }}&amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Expiration Date:&amp;lt;/strong&amp;gt; {{ expire_date }}&amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Domain Age:&amp;lt;/strong&amp;gt; {{ domain_age }} days&amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;WHOIS Server:&amp;lt;/strong&amp;gt; {{ whois_server }}&amp;lt;/p&amp;gt;

    &amp;lt;h2&amp;gt;Registrar Information&amp;lt;/h2&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;IANA ID:&amp;lt;/strong&amp;gt; {{ registrar.iana_id }}&amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Name:&amp;lt;/strong&amp;gt; {{ registrar.name }}&amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;URL:&amp;lt;/strong&amp;gt; &amp;lt;a href="{{ registrar.url }}"&amp;gt;{{ registrar.url }}&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;

    &amp;lt;h2&amp;gt;Registrant Information&amp;lt;/h2&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Name:&amp;lt;/strong&amp;gt; {{ registrant.name }}&amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Organization:&amp;lt;/strong&amp;gt; {{ registrant.organization }}&amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Street Address:&amp;lt;/strong&amp;gt; {{ registrant.street_address }}&amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;City:&amp;lt;/strong&amp;gt; {{ registrant.city }}&amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Region:&amp;lt;/strong&amp;gt; {{ registrant.region }}&amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;ZIP Code:&amp;lt;/strong&amp;gt; {{ registrant.zip_code }}&amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Country:&amp;lt;/strong&amp;gt; {{ registrant.country }}&amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Phone:&amp;lt;/strong&amp;gt; {{ registrant.phone }}&amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Fax:&amp;lt;/strong&amp;gt; {{ registrant.fax }}&amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Email:&amp;lt;/strong&amp;gt; &amp;lt;a href="{{ registrant.email }}"&amp;gt;{{ registrant.email }}&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;

    &amp;lt;h2&amp;gt;Administrative Contact Information&amp;lt;/h2&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Name:&amp;lt;/strong&amp;gt; {{ admin.name }}&amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Organization:&amp;lt;/strong&amp;gt; {{ admin.organization }}&amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Street Address:&amp;lt;/strong&amp;gt; {{ admin.street_address }}&amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;City:&amp;lt;/strong&amp;gt; {{ admin.city }}&amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Region:&amp;lt;/strong&amp;gt; {{ admin.region }}&amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;ZIP Code:&amp;lt;/strong&amp;gt; {{ admin.zip_code }}&amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Country:&amp;lt;/strong&amp;gt; {{ admin.country }}&amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Phone:&amp;lt;/strong&amp;gt; {{ admin.phone }}&amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Fax:&amp;lt;/strong&amp;gt; {{ admin.fax }}&amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Email:&amp;lt;/strong&amp;gt; &amp;lt;a href="{{ admin.email }}"&amp;gt;{{ admin.email }}&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;

    &amp;lt;h2&amp;gt;Technical Contact Information&amp;lt;/h2&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Name:&amp;lt;/strong&amp;gt; {{ tech.name }}&amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Organization:&amp;lt;/strong&amp;gt; {{ tech.organization }}&amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Street Address:&amp;lt;/strong&amp;gt; {{ tech.street_address }}&amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;City:&amp;lt;/strong&amp;gt; {{ tech.city }}&amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Region:&amp;lt;/strong&amp;gt; {{ tech.region }}&amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;ZIP Code:&amp;lt;/strong&amp;gt; {{ tech.zip_code }}&amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Country:&amp;lt;/strong&amp;gt; {{ tech.country }}&amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Phone:&amp;lt;/strong&amp;gt; {{ tech.phone }}&amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Fax:&amp;lt;/strong&amp;gt; {{ tech.fax }}&amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Email:&amp;lt;/strong&amp;gt; &amp;lt;a href="{{ tech.email }}"&amp;gt;{{ tech.email }}&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;

    &amp;lt;h2&amp;gt;Billing Contact Information&amp;lt;/h2&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Name:&amp;lt;/strong&amp;gt; {{ billing.name }}&amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Organization:&amp;lt;/strong&amp;gt; {{ billing.organization }}&amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Street Address:&amp;lt;/strong&amp;gt; {{ billing.street_address }}&amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;City:&amp;lt;/strong&amp;gt; {{ billing.city }}&amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Region:&amp;lt;/strong&amp;gt; {{ billing.region }}&amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;ZIP Code:&amp;lt;/strong&amp;gt; {{ billing.zip_code }}&amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Country:&amp;lt;/strong&amp;gt; {{ billing.country }}&amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Phone:&amp;lt;/strong&amp;gt; {{ billing.phone }}&amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Fax:&amp;lt;/strong&amp;gt; {{ billing.fax }}&amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Email:&amp;lt;/strong&amp;gt; {{ billing.email }}&amp;lt;/p&amp;gt;

    &amp;lt;h2&amp;gt;Nameservers&amp;lt;/h2&amp;gt;
    &amp;lt;ul&amp;gt;
        {% for nameserver in nameservers %}
            &amp;lt;li&amp;gt;{{ nameserver }}&amp;lt;/li&amp;gt;
        {% endfor %}
    &amp;lt;/ul&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Step 7:&lt;/strong&gt;&lt;br&gt;
In order to make sure that the page can be found and loaded, we still need to do some configuration. Open the &lt;em&gt;mysite/mysite/urls.py&lt;/em&gt;, and add the following line in the &lt;em&gt;urlpatterns&lt;/em&gt; list:&lt;br&gt;
&lt;code&gt;path('myapp/', include('myapp.urls')),&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 8:&lt;/strong&gt;&lt;br&gt;
Open the &lt;em&gt;mysite/mysite/settings.py&lt;/em&gt;, and add the following line into the INSTALLED_APPS list:&lt;br&gt;
&lt;code&gt;'myapp',&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 9:&lt;/strong&gt;&lt;br&gt;
Remember to save all the changes. Next, change back to the project root directory and use the following command to start a Django development server:&lt;br&gt;
&lt;code&gt;python manage.py runserver&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 10:&lt;/strong&gt;&lt;br&gt;
Now you can go to your browser, and navigate to &lt;a href="http://127.0.0.1:8000/myapp/lookup" rel="noopener noreferrer"&gt;http://127.0.0.1:8000/myapp/lookup&lt;/a&gt; and &lt;a href="http://127.0.0.1:8000/myapp/whoislookup" rel="noopener noreferrer"&gt;http://127.0.0.1:8000/myapp/whoislookup&lt;/a&gt; to see the outcome. You will see a similar output displayed in the screenshot below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F44b50f7y3c3twt63shp3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F44b50f7y3c3twt63shp3.png" alt="IP address lookup result"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvffkmmqiungwkzertlxo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvffkmmqiungwkzertlxo.png" alt="Domain information"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;For more tutorials, please visit &lt;a href="https://blog.ip2location.com/#devto" rel="noopener noreferrer"&gt;IP2Location IP Gelocation&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Where can I find &lt;a href="https://www.ip2location.io/#devto" rel="noopener noreferrer"&gt;free IP Geolocation API&lt;/a&gt;?&lt;/p&gt;

&lt;p&gt;Where can I get &lt;a href="https://lite.ip2location.com/#devto" rel="noopener noreferrer"&gt;free IP Geolocation database&lt;/a&gt;?&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>tutorial</category>
      <category>django</category>
      <category>programming</category>
    </item>
    <item>
      <title>How to use IP2Location.io and IP2WHOIS in Flask?</title>
      <dc:creator>IP2Location</dc:creator>
      <pubDate>Fri, 05 Jul 2024 02:44:33 +0000</pubDate>
      <link>https://dev.to/ip2location/how-to-use-ip2locationio-and-ip2whois-in-flask-59lk</link>
      <guid>https://dev.to/ip2location/how-to-use-ip2locationio-and-ip2whois-in-flask-59lk</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Flask is a Python micro web framework that does not rely on any particular tool or library to work. Because of it’s simplicity and lightweight nature, many websites had adapted Flask into their backend, such as Pinterest and LinkedIn. Flask allows developers to use any third party extensions to add more functionality. For example, developers can utilize a geolocation lookup extension to lookup for the geolocation information of their visitor. In this article, we will show you how to use IP2Location.io and IP2WHOIS API to perform geolocation and domain WHOIS lookup in Flask.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisite
&lt;/h2&gt;

&lt;p&gt;Before we start, you will be required to install the following components into your server.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;IP2Location.io Python SDK&lt;br&gt;
To perform geolocation lookup, you need to install it using this command: &lt;code&gt;pip install ip2location-io&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;IP2WHOIS Python SDK&lt;br&gt;
To perform domain WHOIS lookup, you need to install it using this command: &lt;code&gt;pip install IP2WHOIS&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You will also need a IP2Location.io API key to perform any type of lookup. You can sign up for a &lt;a href="https://www.ip2location.io/sign-up#devto"&gt;free API key&lt;/a&gt;, or &lt;a href="https://www.ip2location.io/pricing#devto"&gt;purchase a plan&lt;/a&gt; according to your need.&lt;/p&gt;

&lt;h2&gt;
  
  
  Steps
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Step 1:&lt;/strong&gt;&lt;br&gt;
In your local server, create a new directory called &lt;em&gt;mywebsite&lt;/em&gt;, and navigate to the directory.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2:&lt;/strong&gt;&lt;br&gt;
Create a new file called &lt;em&gt;app.py&lt;/em&gt;, and paste the following code into the file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from flask import Flask, render_template, jsonify, request
import ip2locationio
import ip2whois

app = Flask(__name__)

@app.route('/geolocation-lookup')
def geolocation_lookup():
    if request.environ.get('HTTP_X_FORWARDED_FOR') is None:
        ip = request.environ['REMOTE_ADDR']
    else:
        ip = request.environ['HTTP_X_FORWARDED_FOR']
    if ip == '127.0.0.1': # Happened in Windows, if the IP got is 127.0.0.1, need to substitute with real IP address
        ip = '8.8.8.8' # Google Public IP

    # Configures IP2Location.io API key
    configuration = ip2locationio.Configuration('YOUR_API_KEY')
    ipgeolocation = ip2locationio.IPGeolocation(configuration)

    rec = ipgeolocation.lookup(ip)
    return render_template('display_ip2locationio_result.html', data=rec)

@app.route('/whois-lookup')
def index():
    domain = "locaproxy.com" # We will use a fixed value for domain name in this tutorial, but you can always change it to accept input from a form or url.

    # Configures IP2WHOIS API key
    ip2whois_init = ip2whois.Api('YOUR_API_KEY')

    # Lookup domain information
    results = ip2whois_init.lookup(domain)
    return render_template('display_ip2whois_result.html', data=results)

if __name__ == '__main__':
    app.run(debug=True)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 3:&lt;/strong&gt;&lt;br&gt;
Create a new sub directory called templates. Then, in the templates folder, create two new html files called &lt;em&gt;display_ip2locationio_result.html&lt;/em&gt; and &lt;em&gt;display_ip2whois_result.html&lt;/em&gt;. Paste the following contents into both files respectively:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!-- display_ip2locationio_result.html --&amp;gt;
&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;meta charset="UTF-8"&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
    &amp;lt;title&amp;gt;IP Information&amp;lt;/title&amp;gt;
    &amp;lt;style&amp;gt;
        body {
            font-family: Arial, sans-serif;
            margin: 20px;
        }
        table {
            width: 100%;
            border-collapse: collapse;
            margin-bottom: 20px;
        }
        table, th, td {
            border: 1px solid #ccc;
        }
        th, td {
            padding: 10px;
            text-align: left;
        }
        th {
            background-color: #f4f4f4;
        }
    &amp;lt;/style&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;h1&amp;gt;IP Information for {{ data.ip }}&amp;lt;/h1&amp;gt;
    &amp;lt;table&amp;gt;
        &amp;lt;tr&amp;gt;
            &amp;lt;th&amp;gt;Field&amp;lt;/th&amp;gt;
            &amp;lt;th&amp;gt;Value&amp;lt;/th&amp;gt;
        &amp;lt;/tr&amp;gt;
        &amp;lt;tr&amp;gt;
            &amp;lt;td&amp;gt;IP&amp;lt;/td&amp;gt;
            &amp;lt;td&amp;gt;{{ data.ip }}&amp;lt;/td&amp;gt;
        &amp;lt;/tr&amp;gt;
        &amp;lt;tr&amp;gt;
            &amp;lt;td&amp;gt;Country Code&amp;lt;/td&amp;gt;
            &amp;lt;td&amp;gt;{{ data.country_code }}&amp;lt;/td&amp;gt;
        &amp;lt;/tr&amp;gt;
        &amp;lt;tr&amp;gt;
            &amp;lt;td&amp;gt;Country Name&amp;lt;/td&amp;gt;
            &amp;lt;td&amp;gt;{{ data.country_name }}&amp;lt;/td&amp;gt;
        &amp;lt;/tr&amp;gt;
        &amp;lt;tr&amp;gt;
            &amp;lt;td&amp;gt;Region Name&amp;lt;/td&amp;gt;
            &amp;lt;td&amp;gt;{{ data.region_name }}&amp;lt;/td&amp;gt;
        &amp;lt;/tr&amp;gt;
        &amp;lt;tr&amp;gt;
            &amp;lt;td&amp;gt;City Name&amp;lt;/td&amp;gt;
            &amp;lt;td&amp;gt;{{ data.city_name }}&amp;lt;/td&amp;gt;
        &amp;lt;/tr&amp;gt;
        &amp;lt;tr&amp;gt;
            &amp;lt;td&amp;gt;Latitude&amp;lt;/td&amp;gt;
            &amp;lt;td&amp;gt;{{ data.latitude }}&amp;lt;/td&amp;gt;
        &amp;lt;/tr&amp;gt;
        &amp;lt;tr&amp;gt;
            &amp;lt;td&amp;gt;Longitude&amp;lt;/td&amp;gt;
            &amp;lt;td&amp;gt;{{ data.longitude }}&amp;lt;/td&amp;gt;
        &amp;lt;/tr&amp;gt;
        &amp;lt;tr&amp;gt;
            &amp;lt;td&amp;gt;Zip Code&amp;lt;/td&amp;gt;
            &amp;lt;td&amp;gt;{{ data.zip_code }}&amp;lt;/td&amp;gt;
        &amp;lt;/tr&amp;gt;
        &amp;lt;tr&amp;gt;
            &amp;lt;td&amp;gt;Time Zone&amp;lt;/td&amp;gt;
            &amp;lt;td&amp;gt;{{ data.time_zone }}&amp;lt;/td&amp;gt;
        &amp;lt;/tr&amp;gt;
        &amp;lt;tr&amp;gt;
            &amp;lt;td&amp;gt;ASN&amp;lt;/td&amp;gt;
            &amp;lt;td&amp;gt;{{ data.asn }}&amp;lt;/td&amp;gt;
        &amp;lt;/tr&amp;gt;
        &amp;lt;tr&amp;gt;
            &amp;lt;td&amp;gt;AS&amp;lt;/td&amp;gt;
            &amp;lt;td&amp;gt;{{ data.as }}&amp;lt;/td&amp;gt;
        &amp;lt;/tr&amp;gt;
        &amp;lt;tr&amp;gt;
            &amp;lt;td&amp;gt;Is Proxy&amp;lt;/td&amp;gt;
            &amp;lt;td&amp;gt;{{ data.is_proxy }}&amp;lt;/td&amp;gt;
        &amp;lt;/tr&amp;gt;
    &amp;lt;/table&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!-- display_ip2whois_result.html --&amp;gt;
&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;meta charset="UTF-8"&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
    &amp;lt;title&amp;gt;Domain Information&amp;lt;/title&amp;gt;
    &amp;lt;style&amp;gt;
        body {
            font-family: Arial, sans-serif;
            margin: 20px;
        }
        table {
            width: 100%;
            border-collapse: collapse;
            margin-bottom: 20px;
        }
        table, th, td {
            border: 1px solid #ccc;
        }
        th, td {
            padding: 10px;
            text-align: left;
        }
        th {
            background-color: #f4f4f4;
        }
    &amp;lt;/style&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;h1&amp;gt;Domain Information for {{ data.domain }}&amp;lt;/h1&amp;gt;
    &amp;lt;table&amp;gt;
        &amp;lt;tr&amp;gt;
            &amp;lt;th&amp;gt;Field&amp;lt;/th&amp;gt;
            &amp;lt;th&amp;gt;Value&amp;lt;/th&amp;gt;
        &amp;lt;/tr&amp;gt;
        &amp;lt;tr&amp;gt;
            &amp;lt;td&amp;gt;Domain&amp;lt;/td&amp;gt;
            &amp;lt;td&amp;gt;{{ data.domain }}&amp;lt;/td&amp;gt;
        &amp;lt;/tr&amp;gt;
        &amp;lt;tr&amp;gt;
            &amp;lt;td&amp;gt;Domain ID&amp;lt;/td&amp;gt;
            &amp;lt;td&amp;gt;{{ data.domain_id }}&amp;lt;/td&amp;gt;
        &amp;lt;/tr&amp;gt;
        &amp;lt;tr&amp;gt;
            &amp;lt;td&amp;gt;Status&amp;lt;/td&amp;gt;
            &amp;lt;td&amp;gt;{{ data.status }}&amp;lt;/td&amp;gt;
        &amp;lt;/tr&amp;gt;
        &amp;lt;tr&amp;gt;
            &amp;lt;td&amp;gt;Create Date&amp;lt;/td&amp;gt;
            &amp;lt;td&amp;gt;{{ data.create_date }}&amp;lt;/td&amp;gt;
        &amp;lt;/tr&amp;gt;
        &amp;lt;tr&amp;gt;
            &amp;lt;td&amp;gt;Update Date&amp;lt;/td&amp;gt;
            &amp;lt;td&amp;gt;{{ data.update_date }}&amp;lt;/td&amp;gt;
        &amp;lt;/tr&amp;gt;
        &amp;lt;tr&amp;gt;
            &amp;lt;td&amp;gt;Expire Date&amp;lt;/td&amp;gt;
            &amp;lt;td&amp;gt;{{ data.expire_date }}&amp;lt;/td&amp;gt;
        &amp;lt;/tr&amp;gt;
        &amp;lt;tr&amp;gt;
            &amp;lt;td&amp;gt;Domain Age&amp;lt;/td&amp;gt;
            &amp;lt;td&amp;gt;{{ data.domain_age }} days&amp;lt;/td&amp;gt;
        &amp;lt;/tr&amp;gt;
        &amp;lt;tr&amp;gt;
            &amp;lt;td&amp;gt;Whois Server&amp;lt;/td&amp;gt;
            &amp;lt;td&amp;gt;{{ data.whois_server }}&amp;lt;/td&amp;gt;
        &amp;lt;/tr&amp;gt;
        &amp;lt;tr&amp;gt;
            &amp;lt;td&amp;gt;Registrar&amp;lt;/td&amp;gt;
            &amp;lt;td&amp;gt;
                Name: {{ data.registrar.name }}&amp;lt;br&amp;gt;
                URL: &amp;lt;a href="{{ data.registrar.url }}" target="_blank"&amp;gt;{{ data.registrar.url }}&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt;
                IANA ID: {{ data.registrar.iana_id }}
            &amp;lt;/td&amp;gt;
        &amp;lt;/tr&amp;gt;
        &amp;lt;tr&amp;gt;
            &amp;lt;td&amp;gt;Registrant&amp;lt;/td&amp;gt;
            &amp;lt;td&amp;gt;
                Name: {{ data.registrant.name }}&amp;lt;br&amp;gt;
                Organization: {{ data.registrant.organization }}&amp;lt;br&amp;gt;
                Address: {{ data.registrant.street_address }}, {{ data.registrant.city }}, {{ data.registrant.region }} {{ data.registrant.zip_code }}, {{ data.registrant.country }}&amp;lt;br&amp;gt;
                Phone: {{ data.registrant.phone }}&amp;lt;br&amp;gt;
                Fax: {{ data.registrant.fax }}&amp;lt;br&amp;gt;
                Email: {{ data.registrant.email }}
            &amp;lt;/td&amp;gt;
        &amp;lt;/tr&amp;gt;
        &amp;lt;tr&amp;gt;
            &amp;lt;td&amp;gt;Admin&amp;lt;/td&amp;gt;
            &amp;lt;td&amp;gt;
                Name: {{ data.admin.name }}&amp;lt;br&amp;gt;
                Organization: {{ data.admin.organization }}&amp;lt;br&amp;gt;
                Address: {{ data.admin.street_address }}, {{ data.admin.city }}, {{ data.admin.region }} {{ data.admin.zip_code }}, {{ data.admin.country }}&amp;lt;br&amp;gt;
                Phone: {{ data.admin.phone }}&amp;lt;br&amp;gt;
                Fax: {{ data.admin.fax }}&amp;lt;br&amp;gt;
                Email: {{ data.admin.email }}
            &amp;lt;/td&amp;gt;
        &amp;lt;/tr&amp;gt;
        &amp;lt;tr&amp;gt;
            &amp;lt;td&amp;gt;Tech&amp;lt;/td&amp;gt;
            &amp;lt;td&amp;gt;
                Name: {{ data.tech.name }}&amp;lt;br&amp;gt;
                Organization: {{ data.tech.organization }}&amp;lt;br&amp;gt;
                Address: {{ data.tech.street_address }}, {{ data.tech.city }}, {{ data.tech.region }} {{ data.tech.zip_code }}, {{ data.tech.country }}&amp;lt;br&amp;gt;
                Phone: {{ data.tech.phone }}&amp;lt;br&amp;gt;
                Fax: {{ data.tech.fax }}&amp;lt;br&amp;gt;
                Email: {{ data.tech.email }}
            &amp;lt;/td&amp;gt;
        &amp;lt;/tr&amp;gt;
        &amp;lt;tr&amp;gt;
            &amp;lt;td&amp;gt;Billing&amp;lt;/td&amp;gt;
            &amp;lt;td&amp;gt;
                Name: {{ data.billing.name }}&amp;lt;br&amp;gt;
                Organization: {{ data.billing.organization }}&amp;lt;br&amp;gt;
                Address: {{ data.billing.street_address }}, {{ data.billing.city }}, {{ data.billing.region }} {{ data.billing.zip_code }}, {{ data.billing.country }}&amp;lt;br&amp;gt;
                Phone: {{ data.billing.phone }}&amp;lt;br&amp;gt;
                Fax: {{ data.billing.fax }}&amp;lt;br&amp;gt;
                Email: {{ data.billing.email }}
            &amp;lt;/td&amp;gt;
        &amp;lt;/tr&amp;gt;
        &amp;lt;tr&amp;gt;
            &amp;lt;td&amp;gt;Nameservers&amp;lt;/td&amp;gt;
            &amp;lt;td&amp;gt;
                &amp;lt;ul&amp;gt;
                    {% for nameserver in data.nameservers %}
                        &amp;lt;li&amp;gt;{{ nameserver }}&amp;lt;/li&amp;gt;
                    {% endfor %}
                &amp;lt;/ul&amp;gt;
            &amp;lt;/td&amp;gt;
        &amp;lt;/tr&amp;gt;
    &amp;lt;/table&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 4:&lt;/strong&gt;&lt;br&gt;
In your terminal, navigate to the project directory, and run the following command to start the local server: &lt;code&gt;flask run&lt;/code&gt;. &lt;br&gt;
Take note that if you named the &lt;em&gt;app.py&lt;/em&gt; to other name such as &lt;em&gt;website.py&lt;/em&gt;, the command will become &lt;code&gt;flask --app website run&lt;/code&gt; instead.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5:&lt;/strong&gt;&lt;br&gt;
Now you can go to your browser, and navigate to the link &lt;a href="http://127.0.0.1:5000/geolocation-lookup"&gt;http://127.0.0.1:5000/geolocation-lookup&lt;/a&gt; and &lt;a href="http://127.0.0.1:5000/whois-lookup"&gt;http://127.0.0.1:5000/whois-lookup&lt;/a&gt; to see the results. You will see similar outputs displayed in the screenshot below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F382f0xzu1zyvk87kes2m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F382f0xzu1zyvk87kes2m.png" alt="IP address information" width="800" height="380"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fen17144ae8g6uq7eoof1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fen17144ae8g6uq7eoof1.png" alt="Domain information" width="800" height="488"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;For more tutorials, please visit &lt;a href="https://blog.ip2location.com/#devto"&gt;IP2Location IP Gelocation&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Where can I find &lt;a href="https://www.ip2location.io/#devto"&gt;free IP Geolocation API&lt;/a&gt;?&lt;/p&gt;

&lt;p&gt;Where can I get &lt;a href="https://lite.ip2location.com/#devto"&gt;free IP Geolocation database&lt;/a&gt;?&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>python</category>
      <category>developers</category>
    </item>
    <item>
      <title>Using IP2Convert to create MMDB geolocation database for use with WireShark</title>
      <dc:creator>IP2Location</dc:creator>
      <pubDate>Wed, 05 Jun 2024 02:28:50 +0000</pubDate>
      <link>https://dev.to/ip2location/using-ip2convert-to-create-mmdb-geolocation-database-for-use-with-wireshark-3961</link>
      <guid>https://dev.to/ip2location/using-ip2convert-to-create-mmdb-geolocation-database-for-use-with-wireshark-3961</guid>
      <description>&lt;p&gt;WireShark is a free and open-source packet analyzer. It can be used to check for network attacks or to troubleshoot networking issues. Meanwhile, MMDB is a database format created by MaxMind for IP lookup. Inside WireShark, there is an option to retrieve IP geolocation data using the MMDB IP database. In this article, we’ll explore how to use &lt;a href="https://github.com/ip2location/ip2convert" rel="noopener noreferrer"&gt;IP2Convert Geolocation File Format Converter&lt;/a&gt; to read data from IP2Location LITE DB9 IPv6 CSV file and generate the corresponding GeoLite2 City MMDB file.&lt;/p&gt;

&lt;h2&gt;
  
  
  So why the need for conversion?
&lt;/h2&gt;

&lt;p&gt;Wireshark natively supports the MMDB format from MaxMind for geolocation services. However, if you want to use an alternative geolocation service like &lt;a href="https://www.ip2location.com#devto" rel="noopener noreferrer"&gt;IP2Location&lt;/a&gt;, there is no external plugin available for integration. The only method would be via the MMDB data file. Therefore, this tutorial provides a workaround to convert the IP2Location CSV file into MMDB format so it can be used by WireShark with the geolocation function turned on.&lt;/p&gt;

&lt;p&gt;Let’s get started with our guide for the conversion.&lt;/p&gt;

&lt;h2&gt;
  
  
  Installing WireShark
&lt;/h2&gt;

&lt;p&gt;First and foremost, you will need to have WireShark installed on your system. In our case, we are doing the conversion using our Windows 11 machine, hence the steps will be more Windows-specific. Do note however that WireShark can also be used in Linux or macOS. You can just change the steps for the platform you are using. We’ll download WireShark from &lt;a href="https://www.wireshark.org/download.html" rel="noopener noreferrer"&gt;https://www.wireshark.org/download.html&lt;/a&gt; and install it in our Windows 11.&lt;/p&gt;

&lt;h2&gt;
  
  
  Download the IP2Convert tool
&lt;/h2&gt;

&lt;p&gt;Now, we’ll download the free IP2Convert tool from GitHub at &lt;a href="https://github.com/ip2location/ip2convert/releases/latest" rel="noopener noreferrer"&gt;https://github.com/ip2location/ip2convert/releases/latest&lt;/a&gt; where we will get the windows_amd64 version. Remember to download the version specific to your platform. Extract the .exe file into a folder. In our case, we’ll use C:\TestWireShark\ as our folder to store the IP2Convert executable.&lt;/p&gt;

&lt;h2&gt;
  
  
  Download the IP2Location LITE DB9 IPv6 CSV
&lt;/h2&gt;

&lt;p&gt;Download the &lt;a href="https://lite.ip2location.com/database/db9-ip-country-region-city-latitude-longitude-zipcode#devto" rel="noopener noreferrer"&gt;IP2Location LITE DB9 IPv6 CSV file&lt;/a&gt; which you can download for free after signing up for an account. Extract the file IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE.CSV from the downloaded zipped file and save it to the same folder as above.&lt;/p&gt;

&lt;p&gt;Your TestWireShark folder should now look like the below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fem50hajemjcvn358s880.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fem50hajemjcvn358s880.png" alt="TestWireShark folder"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In our case, the latest version of the IP2Convert at the point of writing is 1.2.1 so that’s what you’ll see above. To make it easier to type, let's rename the .exe to ip2convert.exe so that we don’t have to type so long in the next steps.&lt;/p&gt;

&lt;h2&gt;
  
  
  Let’s generate the MMDB file
&lt;/h2&gt;

&lt;p&gt;Open a Command Prompt window and navigate to the TestWireShark folder.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

cd C:\TestWireShark


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Then run the below command to perform the CSV to MMDB conversion.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

ip2convert csv2mmdb -t city -i IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE.CSV -o DB9IPV6.mmdb


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The -t parameter is to specify that we want to generate the GeoLite2 City MMDB while the -i and -o are used to specify the input CSV file and output MMDB file.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftwt31nk1y3ba8mnxj0my.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftwt31nk1y3ba8mnxj0my.png" alt="CSV to MMDB conversion"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Launch WireShark and configure the IP geolocation function
&lt;/h2&gt;

&lt;p&gt;Launch WireShark then click on “Edit” in the menu bar. Click on “Preferences”.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F86dw0uulmmm6p0pi1b0g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F86dw0uulmmm6p0pi1b0g.png" alt="WireShark"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You should now see the Preferences window. Click on “Name Resolution” on the left hand side. There are a couple of settings we need to set. Make sure the “Enable IP geolocation” checkbox is checked. Next, click on “Edit” next to the “MaxMind database directories”.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe9xiaduzas2axfwjwmd0.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe9xiaduzas2axfwjwmd0.jpeg" alt="Preferences window"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Add the folder that we’ve created above into the list. Then click on OK.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj3718yk6z7xhqmggmvu2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj3718yk6z7xhqmggmvu2.png" alt="Maxmind database directory"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Select the network adapter to capture traffic
&lt;/h2&gt;

&lt;p&gt;You can double click on the network adapter that you want to capture the network traffic from. In our example, it’s “Ethernet 2”.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkkbpnfy2lapgeqxth36y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkkbpnfy2lapgeqxth36y.png" alt="network adapter"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Start the network traffic capture
&lt;/h2&gt;

&lt;p&gt;Click the start capture button and you should start seeing a bunch of traffic coming and going from the adapter you’ve selected.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4dhyca667k5aq7tgm1zz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4dhyca667k5aq7tgm1zz.png" alt="network traffic capture"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Take a look at the inline geolocation data
&lt;/h2&gt;

&lt;p&gt;Once you’ve captured enough traffic, we can stop the capture and delve into the IP geolocation data. Let’s click on one of the lines of traffic and expand the “Internet Protocol Version 6” section so we can see the IP geolocation for the traffic source &amp;amp; destination.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwr1uouwmmt8fbdcvghf0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwr1uouwmmt8fbdcvghf0.png" alt="Inline geolocation data"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can see that the source of the traffic is Sydney, Australia while the destination is Kuala Lumpur, Malaysia.&lt;/p&gt;

&lt;h2&gt;
  
  
  See the geolocation for all endpoints
&lt;/h2&gt;

&lt;p&gt;That’s just 1 line of traffic. Now, let’s go to the Endpoints window to view all of the geolocation traffic. In the menu, click on “Statistics” and then click on “Endpoints”.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj4dus0ojcs68qanolnhj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj4dus0ojcs68qanolnhj.png" alt="Endpoints"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Inside, you’ll see the below. Just click on the IPv4 or IPv6 tab and you can view all of the IP geolocation data. Pretty good way to quickly scan for potential issues.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fak6gb26is3xcfqjiavfs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fak6gb26is3xcfqjiavfs.png" alt="Endpoints geolocation IPv4"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuf5irulwfy10litbhura.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuf5irulwfy10litbhura.png" alt="Endpoints geolocation IPv6"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  View the geolocations on a map
&lt;/h2&gt;

&lt;p&gt;Looking at the list of locations is useful for troubleshooting and security purposes. But, sometimes you want to have a nice visual representation of the locations. That’s what the map feature is for. With the locations plotted on a map, you can easily discern if the traffic is coming from specific regions. Click on “Map” then click on “Open in browser”.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp2c3hso7lima2a3xhh56.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp2c3hso7lima2a3xhh56.png" alt="Geolocation on a map"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;All of the geolocation is now shown in the map below. Pretty interesting and useful.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3ynwhtm6n1anxbq7gv3t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3ynwhtm6n1anxbq7gv3t.png" alt="Map plots"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Bonus Tip: Filtering the traffic by geolocation
&lt;/h2&gt;

&lt;p&gt;Let’s close the Endpoints window and take another look at the main capture window. The data, while useful, certainly could use some filtering to make more sense. Say that I want to see traffic to Dublin. We can easily right-click on the city name and click “Prepare as Filter” then click “Selected”. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjtfvk4n0776tn2m224li.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjtfvk4n0776tn2m224li.png" alt="Prepare Filter"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You’ll now see the filter created near the top of the window. Press the arrow at the end of the green bar and you’ll see the filtering being applied.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdp895ca1ibwprbfsvtmj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdp895ca1ibwprbfsvtmj.png" alt="Filter prepared"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, you’ll only see traffic that matches the filter which is Dublin, Ireland as the destination.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F75j7vjjuyxgpixkvx2sd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F75j7vjjuyxgpixkvx2sd.png" alt="Filter by Dublin"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Hope you’ve found our little guide for using IP2Convert to create MMDB files and using them in WireShark to be useful in your day-to-day operations. With IP2Convert, you now have the flexibility to deploy IP geolocation data from IP2Location and use them wherever MMDB is supported. We’ve shown you how to use the generated MMDB in WireShark but you could potentially use the MMDB files in other applications that utilizes MMDB files for geolocation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Disclaimer
&lt;/h2&gt;

&lt;p&gt;MaxMind and GeoIP are registered trademarks of the MaxMind, Inc.&lt;br&gt;
Wireshark and the “fin” logo are registered trademarks of the Wireshark Foundation.&lt;br&gt;
IP2Location and IP2Proxy are registered trademarks of Hexasoft Development Sdn. Bhd.&lt;/p&gt;




&lt;p&gt;For more tutorials, please visit &lt;a href="https://blog.ip2location.com/#devto" rel="noopener noreferrer"&gt;IP2Location IP Gelocation&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Where can I find &lt;a href="https://www.ip2location.io/#devto" rel="noopener noreferrer"&gt;free IP Geolocation API&lt;/a&gt;?&lt;/p&gt;

&lt;p&gt;Where can I get &lt;a href="https://lite.ip2location.com/#devto" rel="noopener noreferrer"&gt;free IP Geolocation database&lt;/a&gt;?&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>tutorial</category>
      <category>database</category>
      <category>programming</category>
    </item>
    <item>
      <title>IP Geolocation API in Cerb</title>
      <dc:creator>IP2Location</dc:creator>
      <pubDate>Tue, 23 Apr 2024 04:52:38 +0000</pubDate>
      <link>https://dev.to/ip2location/ip-geolocation-api-in-cerb-2bf1</link>
      <guid>https://dev.to/ip2location/ip-geolocation-api-in-cerb-2bf1</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fppd5ui6m4rzrnl8mm6j8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fppd5ui6m4rzrnl8mm6j8.png" alt="IP Geolocation" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Cerb is a web-based application designed for tasks automation and enterprise communication. With a history spanning over 22 years, Cerb continues their improvement based on feedback from a multitude of teams around the world. User can run Cerb on their own hardware, in Docker, or in Cerb Cloud as a fully managed service.&lt;/p&gt;

&lt;p&gt;Cerb allows API integration by using two features called automations and interactions. Automations add conditional actions to any event, while interactions extend any toolbar for complex multi-step workflows that require user input. By doing so, user can make use of any API service to extend the Cerb feature. For example, they can use an external API service to get geolocation information before moving to the next step.&lt;/p&gt;

&lt;p&gt;IP2Location.io is a geolocation API service that can provide fast and accurate IP geolocation data to determine a user’s location and use the geolocation information in different use cases. User can get geolocation information such as country, region, city plus proxy detection.&lt;/p&gt;

&lt;p&gt;In this article, we will shows how to use the IP2Location.io IP Geolocation API in Cerb to get geolocation data. We will also brief on how to install Cerb in your local machine with Docker.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;Before we start, please ensure that the Docker and Git are installed in your local machine, as both will be used in Cerb installation process. The IP2Location.io API requires an API key to function. You may &lt;a href="https://www.ip2location.io/pricing#devto"&gt;sign up for a free API key&lt;/a&gt; if you do not have one. Please note that the continent, country, region and city translations are only available in the IP2Location.io Plus and Security plans.&lt;/p&gt;

&lt;h2&gt;
  
  
  Install Cerb in local machine
&lt;/h2&gt;

&lt;p&gt;1 Clone the latest release of Cerb into your machine by using git. For example, if the latest release is v10.4, you can close the release by running this command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone -b v10.4 https://github.com/cerb/cerb-release.git v10.4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2 Navigate to the cloned release just now by&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd v10.4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3 Navigate to the docker file directory in the release by&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd install/docker
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;4 Run docker compose up –build to build and start the container for Cerb. The initial run will take a few minutes to complete the build of the container image. Subsequent runs will start the container almost immediately. Once the build process is complete and it starts running, you can then open your browser and navigate to the &lt;a href="http://localhost/"&gt;http://localhost/&lt;/a&gt;. The cerb guided installer will prompt you for all necessary information to complete the installation. &lt;/p&gt;

&lt;h2&gt;
  
  
  Step-by-step guide to use the IP2Location.io API in Cerb
&lt;/h2&gt;

&lt;p&gt;1 Login to your Cerb dashboard if haven’t, and then click on the search icon as shown in the screenshot.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fftekmciivwigjm82k8wu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fftekmciivwigjm82k8wu.png" alt="Cerb dashboard" width="800" height="384"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;2 Click on the “(show all record types)”, look for the “Connected Services” and click on it.&lt;/p&gt;

&lt;p&gt;3 Click on the + icon to add the IP2Location.io API.&lt;/p&gt;

&lt;p&gt;4 Enter the following information to the form, and click the “Save Changes” button:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Field&lt;/th&gt;
&lt;th&gt;Value&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Name&lt;/td&gt;
&lt;td&gt;ip2location&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;URI&lt;/td&gt;
&lt;td&gt;ip2location&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Type&lt;/td&gt;
&lt;td&gt;API key&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Base URL&lt;/td&gt;
&lt;td&gt;&lt;a href="https://api.ip2location.io/"&gt;https://api.ip2location.io/&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;API Key Name&lt;/td&gt;
&lt;td&gt;key&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;API Key Location&lt;/td&gt;
&lt;td&gt;URL parameter&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;5 After that, go back to the dashboard, and click the search icon showed in the step 1. Click on the “(show all record types)”, this time look for the “Connected Accounts” and click on it. Click on the + icon to add your IP2Location.io API key into Cerb.&lt;/p&gt;

&lt;p&gt;6 Click “ip2location” from the selection, enter the following information to the form, and click the “Save Changes” button:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Field&lt;/th&gt;
&lt;th&gt;Value&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Name&lt;/td&gt;
&lt;td&gt;ip2location&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;URI&lt;/td&gt;
&lt;td&gt;ip2location&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;API key&lt;/td&gt;
&lt;td&gt;(copy from IP2Location.io dashboard)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Base URL&lt;/td&gt;
&lt;td&gt;&lt;a href="https://api.ip2location.io/"&gt;https://api.ip2location.io/&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;7 Now you can use IP2Location.io API to get the geolocation information. To do so, first click the search icon showed in the step 1. Click on the “(show all record types)”, this time look for the “Automations” and click on it. Click on the + icon to add new automation in Cerb.&lt;/p&gt;

&lt;p&gt;8 A popup form will be appear on the screen. Enter “ip2location” in the Name field. Set the trigger type as "cerb.trigger.automation.function”. After that, paste the following code into the text field as shown here:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq7t2kmgqdlusl9k5wxbg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq7t2kmgqdlusl9k5wxbg.png" alt="Configuration" width="800" height="342"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;inputs:
  text/ip:
    type: ip
    required@bool: yes

start:
  http.request:
    output: http_response
    inputs:
      method: GET
      url: https://api.ip2location.io/{{inputs.ip|url_encode}}
      authentication: cerb:connected_account:ip2location
    on_success:
      return:
        data@json: {{http_response.body}}
    on_error:
      error: {{http_response.error}}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;9 You will also need to add a policy for the automation as recommended by Cerb. Click on the “Policy” tab, and paste the following content into the text field after the line “commands:”&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;http.request:
    deny/url@bool: {{inputs.url is not prefixed ('https://api.ip2location.io/')}}
    deny/account@bool: {{inputs.authentication not in ['cerb:connected_account:ip2location']}}
    allow@bool: yes
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;10 That’s all. Now you can try by using the following code. Click on the “Run” tab, and paste the code at the text field in the Input section:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;inputs:
  ip: 1.2.3.4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;11 Click on the triangle button to run the automation. If the run is success, you will see the output being shown in the Output section as shown in the screenshot. Click the “Save Changes” button to save the automation if you are satisfied with it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn7nb4h45oezu47cqh02h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn7nb4h45oezu47cqh02h.png" alt="Output" width="800" height="481"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;This article demonstrates a basic usage of the IP2Location.io API in Cerb, along with the installation of Cerb using Docker. At the completion of this article, you will be able to perform an IP geolocation lookup by using the IP2Location.io API. This will give you more information on an IP address such as geolocation and proxy. These information can be helpful in later analysis, or security enhancement.&lt;/p&gt;




&lt;p&gt;For more tutorials, please visit &lt;a href="https://blog.ip2location.com/#devto"&gt;IP2Location IP Gelocation&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Where can I find &lt;a href="https://www.ip2location.io/#devto"&gt;free IP Geolocation API&lt;/a&gt;?&lt;/p&gt;

&lt;p&gt;Where can I get &lt;a href="https://lite.ip2location.com/#devto"&gt;free IP Geolocation database&lt;/a&gt;?&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>tutorial</category>
      <category>programming</category>
      <category>api</category>
    </item>
    <item>
      <title>Proxy and VPN detection in Ruby with IP2Location.io geolocation API</title>
      <dc:creator>IP2Location</dc:creator>
      <pubDate>Fri, 08 Dec 2023 08:12:07 +0000</pubDate>
      <link>https://dev.to/ip2location/proxy-and-vpn-detection-in-ruby-with-ip2locationio-geolocation-api-4oja</link>
      <guid>https://dev.to/ip2location/proxy-and-vpn-detection-in-ruby-with-ip2locationio-geolocation-api-4oja</guid>
      <description>&lt;p&gt;In the realm of web development and security, the need to identify and manage incoming requests from residential proxies and Virtual Private Networks (VPNs) is becoming increasingly crucial. Ruby, a dynamic and versatile programming language, offers an elegant solution to tackle this challenge. This article will explore the capabilities of Ruby in conjunction with the IP2Location.io Geolocation API, showing how this combination can be employed to detect residential proxies and VPNs effectively.&lt;/p&gt;

&lt;h2&gt;
  
  
  History of Ruby
&lt;/h2&gt;

&lt;p&gt;Ruby, often referred to as an object-oriented scripting language, was created by Yukihiro Matsumoto also known as "Matz" in the mid-1990s. At its core, Ruby emphasizes simplicity and readability, aiming to optimize developer happiness. The language's syntax is designed to be human-readable and expressive, allowing developers to write clean and concise code.&lt;br&gt;
One of Ruby's distinguishing features is its dynamic nature. Unlike statically typed languages, Ruby does not require explicit variable type declarations, enabling developers to focus on solving problems rather than dealing with complex type systems. This dynamism also contributes to the language's flexibility, allowing for the creation of dynamic and highly modular applications.&lt;/p&gt;

&lt;p&gt;What sets Ruby apart from other programming languages is its vibrant community, which is known for its inclusivity and collaboration. It has contributed to the development of a rich ecosystem of libraries and frameworks. The availability of gems, which are Ruby's packaged libraries, facilitates rapid application development by providing pre-built solutions to common problems.&lt;/p&gt;

&lt;p&gt;Now, provided with a deeper understanding of Ruby's style and versatility, it’s time to explore the challenges posed by residential proxies and VPNs and how Ruby can be employed to address them.&lt;/p&gt;
&lt;h2&gt;
  
  
  Understanding Residential Proxies and VPNs
&lt;/h2&gt;
&lt;h2&gt;
  
  
  Residential Proxies:
&lt;/h2&gt;

&lt;p&gt;Residential proxies involve routing internet traffic through IP addresses assigned by Internet Service Providers (ISPs) to homeowners. The use of residential proxies provides a layer of authenticity to web requests, making it appear as if they originate from genuine residential users. This authenticity is valuable in scenarios such as web scraping, market research and other applications where genuine user behavior is crucial.&lt;/p&gt;
&lt;h2&gt;
  
  
  Virtual Private Networks (VPNs):
&lt;/h2&gt;

&lt;p&gt;VPNs, on the other hand, create a secure tunnel between the user's device and the internet. They encrypt the user's internet connection, providing anonymity and security by masking the user's IP address. While VPNs are commonly used for privacy and bypassing regional restrictions, they can also be employed to mask the origin of web requests.&lt;/p&gt;
&lt;h2&gt;
  
  
  Checking for Residential Proxies and VPNs using Ruby
&lt;/h2&gt;

&lt;p&gt;Ruby's flexibility comes into play when developers need to identify whether incoming requests are from regular users, residential proxies, or VPNs. The IP2Location.io Geolocation API proves to be a valuable ally in this attempt. This API provides comprehensive information about the geographical location, connection type and proxy details associated with an IP address.&lt;br&gt;
IP2Location.io provides a Ruby SDK that simplifies the integration of their geolocation API into Ruby applications. This SDK allows developers to easily retrieve information about the location and type of IP addresses, making it an invaluable tool for identifying residential proxies and VPNs.&lt;/p&gt;

&lt;p&gt;To begin using the IP2Location.io Ruby SDK, developers need to obtain an &lt;a href="https://www.ip2location.io/pricing#devto"&gt;API key from the IP2Location.io&lt;/a&gt; website. This key serves as an authentication token for accessing the geolocation data. It is necessary to have a Security Plan subscription to obtain access to information regarding residential proxies and VPNs. After completing the subscription procedure, you can locate the API key on the dashboard page. With the intention of gaining a better understanding of the raw data received from the API, an example of an IP Geolocation API query is presented on the dashboard page.&lt;/p&gt;

&lt;p&gt;Once armed with the API key, developers can proceed to install the IP2Location.io SDK Ruby gem using the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gem install ip2location_io_ruby
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With the ip2location_io_ruby gem installed, developers can now use the IP2Location.io Ruby SDK to perform geolocation lookups. The following demonstration is a basic example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;require 'ip2location_io_ruby'

IP2LocationIORuby::Configuration.api_key = 'YOUR_API_KEY'

begin
    result = IP2LocationIORuby::Api::IPGeolocation.lookup('IP_ADDRESS')
rescue Exception =&amp;gt; e
    puts e.message
else
    if JSON[result.body]['proxy']['is_residential_proxy']
        puts 'Residential proxy detected.'
    elsif JSON[result.body]['proxy']['is_vpn']
        puts 'VPN detected.'
    else
        puts 'No residential proxy or VPN detected.'
    end
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, the ip2location_io_ruby gem file is included. The API key that is obtained from the IP2Location.io dashboard page is configured. Then, the lookup method is utilized to retrieve comprehensive geolocation information for a specific IP address. The analysis of the API response that follows is employed to ascertain whether the user is using a residential proxy or a VPN.&lt;br&gt;
In a nutshell, Ruby's elegance, readability, and dynamic nature make it an excellent choice for handling the details of identifying residential proxies and VPNs. By seamlessly integrating the IP2Location.io Ruby SDK, developers can tap into a wealth of geolocation data to strengthen the security and authenticity of their applications.&lt;/p&gt;

&lt;p&gt;As the digital landscape continues to evolve, the combination of Ruby and the IP2Location.io Geolocation API remains a potent tool in the hands of developers seeking to navigate the complexities of web security. Whether developing a web scraper, enhancing user experience or fortifying applications against potential threats, the grouping of Ruby and IP2Location.io provides a robust solution in the ever-changing landscape of online security.&lt;/p&gt;




&lt;p&gt;For more tutorials, please visit &lt;a href="https://blog.ip2location.com/#devto"&gt;IP2Location IP Gelocation&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Where can I find &lt;a href="https://www.ip2location.io/#devto"&gt;free IP Geolocation API&lt;/a&gt;?&lt;/p&gt;

&lt;p&gt;Where can I get &lt;a href="https://lite.ip2location.com/#devto"&gt;free IP Geolocation database&lt;/a&gt;?&lt;/p&gt;

</description>
      <category>ruby</category>
      <category>programming</category>
      <category>webdev</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Using Go to check for proxy and VPN with IP2Location.io geolocation API</title>
      <dc:creator>IP2Location</dc:creator>
      <pubDate>Wed, 06 Dec 2023 05:00:05 +0000</pubDate>
      <link>https://dev.to/ip2location/using-go-to-check-for-proxy-and-vpn-with-ip2locationio-geolocation-api-222i</link>
      <guid>https://dev.to/ip2location/using-go-to-check-for-proxy-and-vpn-with-ip2locationio-geolocation-api-222i</guid>
      <description>&lt;h2&gt;
  
  
  Intro
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Go&lt;/strong&gt; or &lt;strong&gt;Golang&lt;/strong&gt;, is an open-source programming language created by Google. If you are familiar with the C programming language syntax, then you’ll feel right at home using Go. It has garbage collection and memory safety, in addition to being fast. In addition, it is very useful for concurrency programming.&lt;/p&gt;

&lt;p&gt;Developers use Go for a variety of programs like microservices, networking services, web applications, command line interfaces and more. Go developers have a huge variety of packages at their disposal to perform just about any task. Among them is the IP2Location.io Go SDK that provides a wrapper for the IP2Location.io API. The IP2Location.io API enables developers to easily check if an IP address belongs to a Virtual Private Network (VPN) or a residential proxy.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a VPN?
&lt;/h2&gt;

&lt;p&gt;So, &lt;a href="https://blog.ip2location.com/knowledge-base/what-is-a-vpn/#devto"&gt;what is a VPN&lt;/a&gt;, you may ask? Well, a VPN server is essentially a proxy server that makes web requests on your behalf like a middleman. It hides your actual IP address from websites so that they are unable to track you. When a user is using a VPN server to browse a website, the user’s request is passed to the VPN server which then makes the request at the website. The response from the website is passed back along the same path. The traffic between the VPN server and the user is encrypted. That means the user’s ISP or other parties are unable to intercept any meaningful data from the network packets. It’s great for privacy reasons.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a residential proxy?
&lt;/h2&gt;

&lt;p&gt;Another type of proxy called a residential proxy, performs similarly to the above VPN server. The only difference is that the residential proxy server is usually a home user’s computer vs. the data center machine used in VPN. People usually use residential proxies whenever they wish to hide the fact that they’re using a proxy server.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why do we need to detect VPN or residential proxy?
&lt;/h2&gt;

&lt;p&gt;As mentioned above, proxy servers serve to obscure the identities of the users. This means that they could be up to no good. Fraudsters frequently use VPN or residential proxy to fool online stores and bypass their fraud checks when buying stuff. People also use proxies to circumvent geofencing to get access to streaming video or music. Operators of such websites definitely need to be able to detect VPN and residential proxies, in order to block them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using IP2Location.io to detect VPN and residential proxy
&lt;/h2&gt;

&lt;p&gt;Let’s take a look at how to use the IP2Location.io Go SDK to query the IP2Location.io API to determine if an IP address belongs to a VPN or a residential proxy.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sign up for the IP2Location.io API key&lt;/strong&gt;&lt;br&gt;
But, before we can proceed, please make sure to &lt;a href="https://www.ip2location.io/pricing#devto"&gt;sign up for the API key&lt;/a&gt;. You’ll need to subscribe to the Plus plan to be able to have access to the VPN and residential proxy data.&lt;/p&gt;

&lt;p&gt;Once you’ve subscribed, you can login to the website and retrieve your API key. We’ll need that to query the API.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--maGXmVvn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x2fmsug2bx83t5n4yt8e.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--maGXmVvn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x2fmsug2bx83t5n4yt8e.jpg" alt="Image description" width="800" height="351"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see in the screenshot above, there is an example API query which you can copy &amp;amp; paste into your browser to see the JSON result. This will give you an idea of the raw data returned by the API. You can try out the URL below with your API key and any IP address you wish to query.&lt;/p&gt;

&lt;p&gt;E.g., &lt;code&gt;https://api.ip2location.io/?key=&amp;lt;YOUR _API_KEY&amp;gt;&amp;amp;ip=&amp;lt;IP_TO_QUERY&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;But in our case, we’ll be using the &lt;a href="https://github.com/ip2location/ip2location-io-go"&gt;IP2Location.io Go SDK&lt;/a&gt; to parse the raw JSON into a struct for us to easily use. We are going to create a command line program to query the API for a particular IP address and show the results.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Create your testing Go project first if you don’t have one&lt;/strong&gt;&lt;br&gt;
1)  Create a folder and call it &lt;strong&gt;test_project&lt;/strong&gt;.&lt;br&gt;
2)  In the command prompt, navigate into that folder.&lt;br&gt;
3)  Run &lt;strong&gt;go mod init test&lt;/strong&gt; to initialize the &lt;strong&gt;go.mod&lt;/strong&gt; file.&lt;br&gt;
4)  Next, run &lt;strong&gt;go get github.com/ip2location/ip2location-io-go&lt;/strong&gt; to add IP2Location.io Go SDK into the project.&lt;br&gt;
5)  After that, create a sub-folder called &lt;strong&gt;test&lt;/strong&gt; inside the &lt;strong&gt;test_project&lt;/strong&gt; folder where we’ll store our test code.&lt;br&gt;
6)  Navigate into the &lt;strong&gt;test&lt;/strong&gt; folder.&lt;br&gt;
7)  Create a blank text file called &lt;strong&gt;test.go&lt;/strong&gt; which will contain our code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Basic usage code for the IP2Location.io Go SDK&lt;/strong&gt;&lt;br&gt;
Head on over to the quick start page below:&lt;br&gt;
&lt;a href="https://ip2location-io-go.readthedocs.io/en/latest/quickstart.html"&gt;https://ip2location-io-go.readthedocs.io/en/latest/quickstart.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Copy the code and paste into the &lt;strong&gt;test.go&lt;/strong&gt; file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package main

import (
    "github.com/ip2location/ip2location-io-go/ip2locationio"
    "fmt"
)

func main() {
    apikey := "YOUR_API_KEY"

    config, err := ip2locationio.OpenConfiguration(apikey)

    if err != nil {
        fmt.Print(err)
        return
    }
    ipl, err := ip2locationio.OpenIPGeolocation(config)

    if err != nil {
        fmt.Print(err)
        return
    }

    ip := "8.8.8.8"
    lang := "en" // set to blank string if not applicable
    res, err := ipl.LookUp(ip, lang) // language parameter only available with Plus and Security plans

    if err != nil {
        fmt.Print(err)
        return
    }

    fmt.Printf("IP =&amp;gt; %+v\n", res.IP)
    fmt.Printf("CountryCode =&amp;gt; %+v\n", res.CountryCode)
    fmt.Printf("CountryName =&amp;gt; %+v\n", res.CountryName)
    fmt.Printf("RegionName =&amp;gt; %+v\n", res.RegionName)
    fmt.Printf("CityName =&amp;gt; %+v\n", res.CityName)
    fmt.Printf("Latitude =&amp;gt; %+v\n", res.Latitude)
    fmt.Printf("Longitude =&amp;gt; %+v\n", res.Longitude)
    fmt.Printf("ZipCode =&amp;gt; %+v\n", res.ZipCode)
    fmt.Printf("TimeZone =&amp;gt; %+v\n", res.TimeZone)
    fmt.Printf("Asn =&amp;gt; %+v\n", res.Asn)
    fmt.Printf("AS =&amp;gt; %+v\n", res.AS)
    fmt.Printf("Isp =&amp;gt; %+v\n", res.Isp)
    fmt.Printf("Domain =&amp;gt; %+v\n", res.Domain)
    fmt.Printf("NetSpeed =&amp;gt; %+v\n", res.NetSpeed)
    fmt.Printf("IddCode =&amp;gt; %+v\n", res.IddCode)
    fmt.Printf("AreaCode =&amp;gt; %+v\n", res.AreaCode)
    fmt.Printf("WeatherStationCode =&amp;gt; %+v\n", res.WeatherStationCode)
    fmt.Printf("WeatherStationName =&amp;gt; %+v\n", res.WeatherStationName)
    fmt.Printf("Mcc =&amp;gt; %+v\n", res.Mcc)
    fmt.Printf("Mnc =&amp;gt; %+v\n", res.Mnc)
    fmt.Printf("MobileBrand =&amp;gt; %+v\n", res.MobileBrand)
    fmt.Printf("Elevation =&amp;gt; %+v\n", res.Elevation)
    fmt.Printf("UsageType =&amp;gt; %+v\n", res.UsageType)
    fmt.Printf("AddressType =&amp;gt; %+v\n", res.AddressType)
    fmt.Printf("District =&amp;gt; %+v\n", res.District)
    fmt.Printf("AdsCategory =&amp;gt; %+v\n", res.AdsCategory)
    fmt.Printf("AdsCategoryName =&amp;gt; %+v\n", res.AdsCategoryName)
    fmt.Printf("IsProxy =&amp;gt; %+v\n", res.IsProxy)

    fmt.Printf("Continent.Name =&amp;gt; %+v\n", res.Continent.Name)
    fmt.Printf("Continent.Code =&amp;gt; %+v\n", res.Continent.Code)
    fmt.Printf("Continent.Hemisphere =&amp;gt; %+v\n", res.Continent.Hemisphere)
    fmt.Printf("Continent.Translation.Lang =&amp;gt; %+v\n", res.Continent.Translation.Lang)
    fmt.Printf("Continent.Translation.Value =&amp;gt; %+v\n", res.Continent.Translation.Value)

    fmt.Printf("Country.Name =&amp;gt; %+v\n", res.Country.Name)
    fmt.Printf("Country.Alpha3Code =&amp;gt; %+v\n", res.Country.Alpha3Code)
    fmt.Printf("Country.NumericCode =&amp;gt; %+v\n", res.Country.NumericCode)
    fmt.Printf("Country.Demonym =&amp;gt; %+v\n", res.Country.Demonym)
    fmt.Printf("Country.Flag =&amp;gt; %+v\n", res.Country.Flag)
    fmt.Printf("Country.Capital =&amp;gt; %+v\n", res.Country.Capital)
    fmt.Printf("Country.TotalArea =&amp;gt; %+v\n", res.Country.TotalArea)
    fmt.Printf("Country.Population =&amp;gt; %+v\n", res.Country.Population)
    fmt.Printf("Country.Currency.Code =&amp;gt; %+v\n", res.Country.Currency.Code)
    fmt.Printf("Country.Currency.Name =&amp;gt; %+v\n", res.Country.Currency.Name)
    fmt.Printf("Country.Currency.Symbol =&amp;gt; %+v\n", res.Country.Currency.Symbol)
    fmt.Printf("Country.Language.Code =&amp;gt; %+v\n", res.Country.Language.Code)
    fmt.Printf("Country.Language.Name =&amp;gt; %+v\n", res.Country.Language.Name)
    fmt.Printf("Country.Tld =&amp;gt; %+v\n", res.Country.Tld)
    fmt.Printf("Country.Translation.Lang =&amp;gt; %+v\n", res.Country.Translation.Lang)
    fmt.Printf("Country.Translation.Value =&amp;gt; %+v\n", res.Country.Translation.Value)

    fmt.Printf("Region.Name =&amp;gt; %+v\n", res.Region.Name)
    fmt.Printf("Region.Code =&amp;gt; %+v\n", res.Region.Code)
    fmt.Printf("Region.Translation.Lang =&amp;gt; %+v\n", res.Region.Translation.Lang)
    fmt.Printf("Region.Translation.Value =&amp;gt; %+v\n", res.Region.Translation.Value)

    fmt.Printf("City.Name =&amp;gt; %+v\n", res.City.Name)
    fmt.Printf("City.Translation.Lang =&amp;gt; %+v\n", res.City.Translation.Lang)
    fmt.Printf("City.Translation.Value =&amp;gt; %+v\n", res.City.Translation.Value)

    fmt.Printf("TimeZoneInfo.Olson =&amp;gt; %+v\n", res.TimeZoneInfo.Olson)
    fmt.Printf("TimeZoneInfo.CurrentTime =&amp;gt; %+v\n", res.TimeZoneInfo.CurrentTime)
    fmt.Printf("TimeZoneInfo.GmtOffset =&amp;gt; %+v\n", res.TimeZoneInfo.GmtOffset)
    fmt.Printf("TimeZoneInfo.IsDst =&amp;gt; %+v\n", res.TimeZoneInfo.IsDst)
    fmt.Printf("TimeZoneInfo.Sunrise =&amp;gt; %+v\n", res.TimeZoneInfo.Sunrise)
    fmt.Printf("TimeZoneInfo.Sunset =&amp;gt; %+v\n", res.TimeZoneInfo.Sunset)

    fmt.Printf("Geotargeting.Metro =&amp;gt; %+v\n", res.Geotargeting.Metro)

    fmt.Printf("Proxy.LastSeen =&amp;gt; %+v\n", res.Proxy.LastSeen)
    fmt.Printf("Proxy.ProxyType =&amp;gt; %+v\n", res.Proxy.ProxyType)
    fmt.Printf("Proxy.Threat =&amp;gt; %+v\n", res.Proxy.Threat)
    fmt.Printf("Proxy.Provider =&amp;gt; %+v\n", res.Proxy.Provider)
    fmt.Printf("Proxy.IsVpn =&amp;gt; %+v\n", res.Proxy.IsVpn)
    fmt.Printf("Proxy.IsTor =&amp;gt; %+v\n", res.Proxy.IsTor)
    fmt.Printf("Proxy.IsDataCenter =&amp;gt; %+v\n", res.Proxy.IsDataCenter)
    fmt.Printf("Proxy.IsPublicProxy =&amp;gt; %+v\n", res.Proxy.IsPublicProxy)
    fmt.Printf("Proxy.IsWebProxy =&amp;gt; %+v\n", res.Proxy.IsWebProxy)
    fmt.Printf("Proxy.IsWebCrawler =&amp;gt; %+v\n", res.Proxy.IsWebCrawler)
    fmt.Printf("Proxy.IsResidentialProxy =&amp;gt; %+v\n", res.Proxy.IsResidentialProxy)
    fmt.Printf("Proxy.IsSpammer =&amp;gt; %+v\n", res.Proxy.IsSpammer)
    fmt.Printf("Proxy.IsScanner =&amp;gt; %+v\n", res.Proxy.IsScanner)
    fmt.Printf("Proxy.IsBotnet =&amp;gt; %+v\n", res.Proxy.IsBotnet)
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Remember to modify the above code to include your own IP2Location.io API key.&lt;br&gt;
Then navigate to the &lt;strong&gt;test&lt;/strong&gt; folder and run the below command to test the code.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;go run test.go&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If all goes well, you should see the output like below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;IP =&amp;gt; 8.8.8.8
CountryCode =&amp;gt; US
CountryName =&amp;gt; United States of America
RegionName =&amp;gt; California
CityName =&amp;gt; Mountain View
Latitude =&amp;gt; 37.38605
Longitude =&amp;gt; -122.08385
ZipCode =&amp;gt; 94035
TimeZone =&amp;gt; -08:00
Asn =&amp;gt; 15169
AS =&amp;gt; Google LLC
Isp =&amp;gt; Google LLC
Domain =&amp;gt; google.com
NetSpeed =&amp;gt; T1
IddCode =&amp;gt; 1
AreaCode =&amp;gt; 650
WeatherStationCode =&amp;gt; USCA0746
WeatherStationName =&amp;gt; Mountain View
Mcc =&amp;gt; -
Mnc =&amp;gt; -
MobileBrand =&amp;gt; -
Elevation =&amp;gt; 32
UsageType =&amp;gt; DCH
AddressType =&amp;gt; Anycast
District =&amp;gt;
AdsCategory =&amp;gt;
AdsCategoryName =&amp;gt;
IsProxy =&amp;gt; false
Continent.Name =&amp;gt; North America
Continent.Code =&amp;gt; NA
Continent.Hemisphere =&amp;gt; [north west]
Continent.Translation.Lang =&amp;gt; en
Continent.Translation.Value =&amp;gt; North America
Country.Name =&amp;gt; United States of America
Country.Alpha3Code =&amp;gt; USA
Country.NumericCode =&amp;gt; 840
Country.Demonym =&amp;gt; Americans
Country.Flag =&amp;gt; https://cdn.ip2location.io/assets/img/flags/us.png
Country.Capital =&amp;gt; Washington, D.C.
Country.TotalArea =&amp;gt; 9826675
Country.Population =&amp;gt; 331002651
Country.Currency.Code =&amp;gt; USD
Country.Currency.Name =&amp;gt; United States Dollar
Country.Currency.Symbol =&amp;gt; $
Country.Language.Code =&amp;gt; EN
Country.Language.Name =&amp;gt; English
Country.Tld =&amp;gt; us
Country.Translation.Lang =&amp;gt; en
Country.Translation.Value =&amp;gt; United States of America
Region.Name =&amp;gt; California
Region.Code =&amp;gt; US-CA
Region.Translation.Lang =&amp;gt; en
Region.Translation.Value =&amp;gt; California
City.Name =&amp;gt; Mountain View
City.Translation.Lang =&amp;gt; en
City.Translation.Value =&amp;gt; Mountain View
TimeZoneInfo.Olson =&amp;gt; America/Los_Angeles
TimeZoneInfo.CurrentTime =&amp;gt; 2023-11-20T23:52:20-08:00
TimeZoneInfo.GmtOffset =&amp;gt; -28800
TimeZoneInfo.IsDst =&amp;gt; false
TimeZoneInfo.Sunrise =&amp;gt; 06:54
TimeZoneInfo.Sunset =&amp;gt; 16:54
Geotargeting.Metro =&amp;gt; 807
Proxy.LastSeen =&amp;gt; 0
Proxy.ProxyType =&amp;gt;
Proxy.Threat =&amp;gt;
Proxy.Provider =&amp;gt;
Proxy.IsVpn =&amp;gt; false
Proxy.IsTor =&amp;gt; false
Proxy.IsDataCenter =&amp;gt; false
Proxy.IsPublicProxy =&amp;gt; false
Proxy.IsWebProxy =&amp;gt; false
Proxy.IsWebCrawler =&amp;gt; false
Proxy.IsResidentialProxy =&amp;gt; false
Proxy.IsSpammer =&amp;gt; false
Proxy.IsScanner =&amp;gt; false
Proxy.IsBotnet =&amp;gt; false
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For the purpose of checking if the IP belongs to a VPN or a residential proxy, all you need to do is check the &lt;strong&gt;Proxy.IsVPN&lt;/strong&gt; or the &lt;strong&gt;Proxy.IsResidentialProxy&lt;/strong&gt; inside the result struct. After that, if either is true, then you can decide if you want to block that IP if you’re interested in geofencing. Or if you’re running an online store, you can choose to block them to prevent possible fraudulent transactions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;As you can see from the extensive amount of data returned, you can do a whole lot with the IP2Location.io Go SDK. For instance, you can audit your network security, screen website visitors, prevent fraudsters from making purchases or block online attackers. If you’re curious about what the &lt;a href="https://www.ip2location.io/pricing#devto"&gt;IP2Location.io API&lt;/a&gt; has to offer, you can sign up for the free API plan to start with.&lt;/p&gt;




&lt;p&gt;For more tutorials, please visit &lt;a href="https://blog.ip2location.com/#devto"&gt;IP2Location IP Gelocation&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Where can I find &lt;a href="https://www.ip2location.io/#devto"&gt;free IP Geolocation API&lt;/a&gt;?&lt;/p&gt;

&lt;p&gt;Where can I get &lt;a href="https://lite.ip2location.com/#devto"&gt;free IP Geolocation database&lt;/a&gt;?&lt;/p&gt;

</description>
      <category>go</category>
      <category>api</category>
      <category>github</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Using C# to check for proxy and VPN with IP2Location.io geolocation API</title>
      <dc:creator>IP2Location</dc:creator>
      <pubDate>Fri, 24 Nov 2023 08:22:11 +0000</pubDate>
      <link>https://dev.to/ip2location/using-c-to-check-for-proxy-and-vpn-with-ip2locationio-geolocation-api-3ec1</link>
      <guid>https://dev.to/ip2location/using-c-to-check-for-proxy-and-vpn-with-ip2locationio-geolocation-api-3ec1</guid>
      <description>&lt;h2&gt;
  
  
  Intro
&lt;/h2&gt;

&lt;p&gt;The IP2Location.io API is a great way to query an IP address to find its geolocation and proxy data. For C# developers, there is the IP2Location.io .NET SDK which is a wrapper for the API. By using this SDK, there is no need to manually parse and deserialize the JSON result into a usable form. In this article, we’ll explore why you need geolocation and proxy detection. We’ll also show a sample code for using the IP2Location.io .NET SDK to query the IP and get the resulting data.&lt;/p&gt;

&lt;h2&gt;
  
  
  IP geolocation usage scenarios
&lt;/h2&gt;

&lt;p&gt;If you’re not familiar with IP geolocation, it’s basically the process of mapping an IP address to physical locations. Developers can use geolocation databases or API to check what is the country, region, city, ISP, time zone and so much more just based on the IP address. Common usage scenarios involving geolocation would be showing localized contents on websites, targeted advertising, multilingual websites, auto-filling forms with basic location details, etc. Modern websites heavily rely on IP geolocation to perform most of their functionalities.&lt;/p&gt;

&lt;h2&gt;
  
  
  Detect proxy usage like VPN and residential proxy
&lt;/h2&gt;

&lt;p&gt;The benefit of using the IP2Location.io API is that the data also includes whether the IP belongs to a proxy server. Being able to tell if the user browsing a website is using a proxy server is a necessity, especially for e-commerce websites. Fraudsters commonly hide their IP geolocation using proxy servers like VPN or residential proxy servers when making online purchases with stolen cards. This makes it harder for online stores to check whether the order is a fraudulent one. Fraud detection normally checks IP geolocation countries vs. the shipping or billing address. By using a proxy that is located in the same country as the address, fraudsters can potentially slip through the fraud checking mechanism. Hence, it’s vital for websites to have proxy server detection.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites for running the code
&lt;/h2&gt;

&lt;p&gt;There are some requirements before you can run the example code that we’ll show below.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Sign up for an IP2Location.io API key at &lt;a href="https://www.ip2location.io/pricing#devto" rel="noopener noreferrer"&gt;https://www.ip2location.io/pricing&lt;/a&gt; if you don’t have one. The free plan comes with basic geolocation data which can be useful to get started.&lt;/li&gt;
&lt;li&gt;You’ll need Visual Studio 2022 or later to compile and run our code.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Let’s create a new C# project for our demo
&lt;/h2&gt;

&lt;p&gt;Open up your Visual Studio and click on Create a new project.&lt;br&gt;
Then select Console App as in the screenshot below and click Next.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foha76hsm5gxqbkjw86vt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foha76hsm5gxqbkjw86vt.png" alt="IP2Location.io geolocation API"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, we’ll call our project DemoIP2LocationIO as below and click Next.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdpk4pszngm0qcw3dai8w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdpk4pszngm0qcw3dai8w.png" alt="IP2Location.io geolocation API"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After that, we’ll select .NET 7.0 as our framework and click Create.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faira4kfpzdfm6baj1uhh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faira4kfpzdfm6baj1uhh.png" alt="IP2Location.io geolocation API"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, we should see the editor like below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjdsb84hza0ud2utwdrnx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjdsb84hza0ud2utwdrnx.png" alt="IP2Location.io geolocation API"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Before we edit the code, install the &lt;a href="https://www.nuget.org/packages/IP2Location.io" rel="noopener noreferrer"&gt;NuGet package&lt;/a&gt; which contains the IP2Location.io .NET SDK that will allow us to use the IP2Location.io API. We’ll also need to install the &lt;a href="https://www.nuget.org/packages/Newtonsoft.Json" rel="noopener noreferrer"&gt;JSON parser&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In the Visual Studio menu, click on Tools -&amp;gt; NuGet Package Manager -&amp;gt; Manage NuGet Packages for Solution, then click on the Newtonsoft.Json package to install it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkqal7kuzmx7r27nwvxm5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkqal7kuzmx7r27nwvxm5.png" alt="IP2Location.io geolocation API"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Do the same for the IP2Location.io package. You may need to search “IP2Location.io” to find it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb1vzbao0nce6amg64sh5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb1vzbao0nce6amg64sh5.png" alt="IP2Location.io geolocation API"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Now, let’s modify the existing code with our code
&lt;/h2&gt;

&lt;p&gt;Let’s replace the code in Program.cs with the below code. Remember to edit the code to use your IP2Location.io API key that you’ve signed up for above.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;using Newtonsoft.Json;
using IP2LocationIOComponent;

// Configures IP2Location.io API key
Configuration Config = new()
{
    ApiKey = "YOUR_API_KEY"
};

IPGeolocation IPL = new(Config);
string IP = "8.8.8.8";
string Lang = "en"; // the language param is only available with Plus and Security plans

// Lookup ip address geolocation data
var MyTask = IPL.Lookup(IP, Lang); // async API call

try
{
    var MyObj = MyTask.Result;

    // pretty-print JSON
    Console.WriteLine(JsonConvert.SerializeObject(MyObj, Formatting.Indented));

    // individual fields
    Console.WriteLine("ip: {0}", MyObj["ip"]);
    Console.WriteLine("country_code: {0}", MyObj["country_code"]);
    Console.WriteLine("country_name: {0}", MyObj["country_name"]);
    Console.WriteLine("region_name: {0}", MyObj["region_name"]);
    Console.WriteLine("city_name: {0}", MyObj["city_name"]);
    Console.WriteLine("latitude: {0}", MyObj["latitude"]);
    Console.WriteLine("longitude: {0}", MyObj["longitude"]);
    Console.WriteLine("zip_code: {0}", MyObj["zip_code"]);
    Console.WriteLine("time_zone: {0}", MyObj["time_zone"]);
    Console.WriteLine("asn: {0}", MyObj["asn"]);
    Console.WriteLine("as: {0}", MyObj["as"]);
    if (MyObj["isp"] != null) Console.WriteLine("isp: {0}", MyObj["isp"]);
    if (MyObj["domain"] != null) Console.WriteLine("domain: {0}", MyObj["domain"]);
    if (MyObj["net_speed"] != null) Console.WriteLine("net_speed: {0}", MyObj["net_speed"]);
    if (MyObj["idd_code"] != null) Console.WriteLine("idd_code: {0}", MyObj["idd_code"]);
    if (MyObj["area_code"] != null) Console.WriteLine("area_code: {0}", MyObj["area_code"]);
    if (MyObj["weather_station_code"] != null) Console.WriteLine("weather_station_code: {0}", MyObj["weather_station_code"]);
    if (MyObj["weather_station_name"] != null) Console.WriteLine("weather_station_name: {0}", MyObj["weather_station_name"]);
    if (MyObj["mcc"] != null) Console.WriteLine("mcc: {0}", MyObj["mcc"]);
    if (MyObj["mnc"] != null) Console.WriteLine("mnc: {0}", MyObj["mnc"]);
    if (MyObj["mobile_brand"] != null) Console.WriteLine("mobile_brand: {0}", MyObj["mobile_brand"]);
    if (MyObj["elevation"] != null) Console.WriteLine("elevation: {0}", MyObj["elevation"]);
    if (MyObj["usage_type"] != null) Console.WriteLine("usage_type: {0}", MyObj["usage_type"]);
    if (MyObj["address_type"] != null) Console.WriteLine("address_type: {0}", MyObj["address_type"]);
    if (MyObj["district"] != null) Console.WriteLine("district: {0}", MyObj["district"]);
    if (MyObj["ads_category"] != null) Console.WriteLine("ads_category: {0}", MyObj["ads_category"]);
    if (MyObj["ads_category_name"] != null) Console.WriteLine("ads_category_name: {0}", MyObj["ads_category_name"]);
    Console.WriteLine("is_proxy: {0}", MyObj["is_proxy"]);

    if (MyObj["continent"] != null)
    {
        var Continent = MyObj["continent"];
        Console.WriteLine("continent =&amp;gt; name: {0}", Continent["name"]);
        Console.WriteLine("continent =&amp;gt; code: {0}", Continent["code"]);
        Console.WriteLine("continent =&amp;gt; hemisphere: {0}", Continent["hemisphere"]);
        Console.WriteLine("continent =&amp;gt; translation =&amp;gt; lang: {0}", Continent["translation"]["lang"]);
        Console.WriteLine("continent =&amp;gt; translation =&amp;gt; value: {0}", Continent["translation"]["value"]);
    }

    if (MyObj["country"] != null)
    {
        var Country = MyObj["country"];
        Console.WriteLine("country =&amp;gt; name: {0}", Country["name"]);
        Console.WriteLine("country =&amp;gt; alpha3_code: {0}", Country["alpha3_code"]);
        Console.WriteLine("country =&amp;gt; numeric_code: {0}", Country["numeric_code"]);
        Console.WriteLine("country =&amp;gt; demonym: {0}", Country["demonym"]);
        Console.WriteLine("country =&amp;gt; flag: {0}", Country["flag"]);
        Console.WriteLine("country =&amp;gt; capital: {0}", Country["capital"]);
        Console.WriteLine("country =&amp;gt; total_area: {0}", Country["total_area"]);
        Console.WriteLine("country =&amp;gt; population: {0}", Country["population"]);
        Console.WriteLine("country =&amp;gt; tld: {0}", Country["tld"]);

        Console.WriteLine("country =&amp;gt; currency =&amp;gt; code: {0}", Country["currency"]["code"]);
        Console.WriteLine("country =&amp;gt; currency =&amp;gt; name: {0}", Country["currency"]["name"]);
        Console.WriteLine("country =&amp;gt; currency =&amp;gt; symbol: {0}", Country["currency"]["symbol"]);

        Console.WriteLine("country =&amp;gt; language =&amp;gt; code: {0}", Country["language"]["code"]);
        Console.WriteLine("country =&amp;gt; language =&amp;gt; name: {0}", Country["language"]["name"]);

        Console.WriteLine("country =&amp;gt; translation =&amp;gt; lang: {0}", Country["translation"]["lang"]);
        Console.WriteLine("country =&amp;gt; translation =&amp;gt; value: {0}", Country["translation"]["value"]);
    }

    if (MyObj["region"] != null)
    {
        var Region = MyObj["region"];
        Console.WriteLine("region =&amp;gt; name: {0}", Region["name"]);
        Console.WriteLine("region =&amp;gt; code: {0}", Region["code"]);

        Console.WriteLine("region =&amp;gt; translation =&amp;gt; lang: {0}", Region["translation"]["lang"]);
        Console.WriteLine("region =&amp;gt; translation =&amp;gt; value: {0}", Region["translation"]["value"]);
    }

    if (MyObj["city"] != null)
    {
        var City = MyObj["city"];
        Console.WriteLine("city =&amp;gt; name: {0}", City["name"]);

        Console.WriteLine("city =&amp;gt; translation =&amp;gt; lang: {0}", City["translation"]["lang"]);
        Console.WriteLine("city =&amp;gt; translation =&amp;gt; value: {0}", City["translation"]["value"]);
    }

    if (MyObj["time_zone_info"] != null)
    {
        var TimeZone = MyObj["time_zone_info"];
        Console.WriteLine("time_zone_info =&amp;gt; olson: {0}", TimeZone["time_zone_info"]);
        Console.WriteLine("time_zone_info =&amp;gt; current_time: {0}", TimeZone["current_time"]);
        Console.WriteLine("time_zone_info =&amp;gt; gmt_offset: {0}", TimeZone["gmt_offset"]);
        Console.WriteLine("time_zone_info =&amp;gt; is_dst: {0}", TimeZone["is_dst"]);
        Console.WriteLine("time_zone_info =&amp;gt; sunrise: {0}", TimeZone["sunrise"]);
        Console.WriteLine("time_zone_info =&amp;gt; sunset: {0}", TimeZone["sunset"]);
    }

    if (MyObj["geotargeting"] != null)
    {
        var GeoTarget = MyObj["geotargeting"];
        Console.WriteLine("geotargeting =&amp;gt; metro: {0}", GeoTarget["metro"]);
    }

    if (MyObj["proxy"] != null)
    {
        var Proxy = MyObj["proxy"];
        Console.WriteLine("proxy =&amp;gt; last_seen: {0}", Proxy["last_seen"]);
        Console.WriteLine("proxy =&amp;gt; proxy_type: {0}", Proxy["proxy_type"]);
        Console.WriteLine("proxy =&amp;gt; threat: {0}", Proxy["threat"]);
        Console.WriteLine("proxy =&amp;gt; provider: {0}", Proxy["provider"]);
        Console.WriteLine("proxy =&amp;gt; is_vpn: {0}", Proxy["is_vpn"]);
        Console.WriteLine("proxy =&amp;gt; is_tor: {0}", Proxy["is_tor"]);
        Console.WriteLine("proxy =&amp;gt; is_data_center: {0}", Proxy["is_data_center"]);
        Console.WriteLine("proxy =&amp;gt; is_public_proxy: {0}", Proxy["is_public_proxy"]);
        Console.WriteLine("proxy =&amp;gt; is_web_proxy: {0}", Proxy["is_web_proxy"]);
        Console.WriteLine("proxy =&amp;gt; is_web_crawler: {0}", Proxy["is_web_crawler"]);
        Console.WriteLine("proxy =&amp;gt; is_residential_proxy: {0}", Proxy["is_residential_proxy"]);
        Console.WriteLine("proxy =&amp;gt; is_spammer: {0}", Proxy["is_spammer"]);
        Console.WriteLine("proxy =&amp;gt; is_scanner: {0}", Proxy["is_scanner"]);
        Console.WriteLine("proxy =&amp;gt; is_botnet: {0}", Proxy["is_botnet"]);
    }
}
catch (Exception ex)
{
    Console.WriteLine(ex.Message);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run the code to query geolocation and proxy data for the 8.8.8.8 IP address. You should see the below output. There are 2 sections in the output. In our code, we will output the raw JSON result in pretty-print format. This is so you can see what is actually returned by the API. Then we will output the individual fields if they exist. For the individual fields, any that is shown with “=&amp;gt;” means it’s a nested field.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NOTE&lt;/strong&gt;: Our example is using the Security plan so we have access to all the fields. If you’re not subscribed to the Security plan, you will see less data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "ip": "8.8.8.8",
  "country_code": "US",
  "country_name": "United States of America",
  "region_name": "California",
  "city_name": "Mountain View",
  "latitude": 37.38605,
  "longitude": -122.08385,
  "zip_code": "94035",
  "time_zone": "-08:00",
  "asn": "15169",
  "as": "Google LLC",
  "isp": "Google LLC",
  "domain": "google.com",
  "net_speed": "T1",
  "idd_code": "1",
  "area_code": "650",
  "weather_station_code": "USCA0746",
  "weather_station_name": "Mountain View",
  "mcc": "-",
  "mnc": "-",
  "mobile_brand": "-",
  "elevation": 32,
  "usage_type": "DCH",
  "address_type": "Anycast",
  "continent": {
    "name": "North America",
    "code": "NA",
    "hemisphere": [
      "north",
      "west"
    ],
    "translation": {
      "lang": "en",
      "value": "North America"
    }
  },
  "district": "Santa Clara County",
  "country": {
    "name": "United States of America",
    "alpha3_code": "USA",
    "numeric_code": 840,
    "demonym": "Americans",
    "flag": "https://cdn.ip2location.io/assets/img/flags/us.png",
    "capital": "Washington, D.C.",
    "total_area": 9826675,
    "population": 331002651,
    "currency": {
      "code": "USD",
      "name": "United States Dollar",
      "symbol": "$"
    },
    "language": {
      "code": "EN",
      "name": "English"
    },
    "tld": "us",
    "translation": {
      "lang": "en",
      "value": "United States of America"
    }
  },
  "region": {
    "name": "California",
    "code": "US-CA",
    "translation": {
      "lang": "en",
      "value": "California"
    }
  },
  "city": {
    "name": "Mountain View",
    "translation": {
      "lang": "en",
      "value": "Mountain View"
    }
  },
  "time_zone_info": {
    "olson": "America/Los_Angeles",
    "current_time": "2023-11-23T09:32:39+08:00",
    "gmt_offset": -28800,
    "is_dst": false,
    "sunrise": "06:56",
    "sunset": "16:53"
  },
  "geotargeting": {
    "metro": "807"
  },
  "ads_category": "IAB19-11",
  "ads_category_name": "Data Centers",
  "is_proxy": false,
  "proxy": {
    "last_seen": 22,
    "proxy_type": "DCH",
    "threat": "-",
    "provider": "-",
    "is_vpn": false,
    "is_tor": false,
    "is_data_center": true,
    "is_public_proxy": false,
    "is_web_proxy": false,
    "is_web_crawler": false,
    "is_residential_proxy": false,
    "is_spammer": false,
    "is_scanner": false,
    "is_botnet": false
  }
}
ip: 8.8.8.8
country_code: US
country_name: United States of America
region_name: California
city_name: Mountain View
latitude: 37.38605
longitude: -122.08385
zip_code: 94035
time_zone: -08:00
asn: 15169
as: Google LLC
isp: Google LLC
domain: google.com
net_speed: T1
idd_code: 1
area_code: 650
weather_station_code: USCA0746
weather_station_name: Mountain View
mcc: -
mnc: -
mobile_brand: -
elevation: 32
usage_type: DCH
address_type: Anycast
district: Santa Clara County
ads_category: IAB19-11
ads_category_name: Data Centers
is_proxy: False
continent =&amp;gt; name: North America
continent =&amp;gt; code: NA
continent =&amp;gt; hemisphere: [
  "north",
  "west"
]
continent =&amp;gt; translation =&amp;gt; lang: en
continent =&amp;gt; translation =&amp;gt; value: North America
country =&amp;gt; name: United States of America
country =&amp;gt; alpha3_code: USA
country =&amp;gt; numeric_code: 840
country =&amp;gt; demonym: Americans
country =&amp;gt; flag: https://cdn.ip2location.io/assets/img/flags/us.png
country =&amp;gt; capital: Washington, D.C.
country =&amp;gt; total_area: 9826675
country =&amp;gt; population: 331002651
country =&amp;gt; tld: us
country =&amp;gt; currency =&amp;gt; code: USD
country =&amp;gt; currency =&amp;gt; name: United States Dollar
country =&amp;gt; currency =&amp;gt; symbol: $
country =&amp;gt; language =&amp;gt; code: EN
country =&amp;gt; language =&amp;gt; name: English
country =&amp;gt; translation =&amp;gt; lang: en
country =&amp;gt; translation =&amp;gt; value: United States of America
region =&amp;gt; name: California
region =&amp;gt; code: US-CA
region =&amp;gt; translation =&amp;gt; lang: en
region =&amp;gt; translation =&amp;gt; value: California
city =&amp;gt; name: Mountain View
city =&amp;gt; translation =&amp;gt; lang: en
city =&amp;gt; translation =&amp;gt; value: Mountain View
time_zone_info =&amp;gt; olson:
time_zone_info =&amp;gt; current_time: 23/11/2023 9:32:39 AM
time_zone_info =&amp;gt; gmt_offset: -28800
time_zone_info =&amp;gt; is_dst: False
time_zone_info =&amp;gt; sunrise: 06:56
time_zone_info =&amp;gt; sunset: 16:53
geotargeting =&amp;gt; metro: 807
proxy =&amp;gt; last_seen: 22
proxy =&amp;gt; proxy_type: DCH
proxy =&amp;gt; threat: -
proxy =&amp;gt; provider: -
proxy =&amp;gt; is_vpn: False
proxy =&amp;gt; is_tor: False
proxy =&amp;gt; is_data_center: True
proxy =&amp;gt; is_public_proxy: False
proxy =&amp;gt; is_web_proxy: False
proxy =&amp;gt; is_web_crawler: False
proxy =&amp;gt; is_residential_proxy: False
proxy =&amp;gt; is_spammer: False
proxy =&amp;gt; is_scanner: False
proxy =&amp;gt; is_botnet: False
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With such an extensive amount of data returned by the IP2Location.io API, C# developers can easily determine what country, region and city the website visitor is from. In addition, IP addresses from logs can be checked against the geolocation and proxy data to make sure that there is no unauthorized access to networks or servers. Marketing analytics can also be enriched with such detailed geolocation to enable better use of the marketing resources.&lt;/p&gt;

&lt;p&gt;As for online merchants, it is very important to check whether the &lt;strong&gt;is_vpn&lt;/strong&gt; or &lt;strong&gt;is_residential_proxy&lt;/strong&gt; nested field is true. If either is true, merchants need to decide if they wish to block such IP addresses from accessing the services or making purchases.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;It is that easy to integrate the IP2Location.io API and its comprehensive data into any C# projects. The benefits reaped from such data can help to boost revenue, block frauds and strengthen organizational security posture.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
