Website to IP lookup

Since the python script relies on the ip.csv input csv file continuing IP addresses, this file must be present in the same path as the script. Open a text editor file and create four IP entries.

How to Find the IP Address of a Website

Every website has at least one associated IP address that it uses to communicate with devices on a network. Because remembering these random strings of numbers would be difficult, developers created the domain name system (DNS). DNS resolves domain names (like WhatIsMyIP.com) to numerical IP addresses, which computers then use to communicate. However, as a user, you may want to find the IP address of a website in addition to knowing the domain name. By using either the ping command, the nslookup command, or the DNS lookup tool, you can easily find the IP address of a website in just a few steps.

Using the ping command

You can find the IP address of any website through the command prompt by using the ping command. The ping command checks the response time for a connection, which indicates the connection’s reliability, but it also returns the IP address of a website.

To find the IP address of a website with the ping command, open the command prompt and type:

ping examplewebsite.com

Below, you can see the pinging results for Google.com’s IP address.

ping command for dos results

For Mac users, the same command can be performed in Terminal. Open terminal and enter the same command as above (ping examplewebsite.com). The results are shown below.

Ping Command for Mac

As seen in this example, the IPv4 address of the Google.com website is 108.177.122.139. The IPv6 address is 2607:f8b0:4004:815::200e.

Using the nslookup command

Another way to check the IP address of a website using a command line tool is with the nslookup command. Most operating systems, whether they be Microsoft Windows, MacOS, Linux, or another system, provide the nslookup tool as it’s specifically intended for looking up IP addresses.

The nslookup tool provides more information to users than the ping command, though both work to find a website’s IP address. To find the IP address of a website with the nslookup command, open the command prompt and type:

nslookup examplewebsite.com

Below is an example of the command run on Google.com in the Microsoft Windows system.

How to find out the IP address of a website with NSLookup Command

The line immediately below the Server line is the IP address of the DNS server that provided the information for Google.com, which is 2001:578:3f::30. The Addresses line shows an IPv6 address for Google.com, which is 2607.f8b0:4004:815::200e.

Mac users can open Terminal to run the same command. Below, you can see the nslookup results for Google.com through Terminal.

nslookup for mac with results

With this command, we can see that an IPv4 address is shown below the Addresses line for Google.com – 172.217.15.110.

Using the DNS lookup tool

Both the ping command and nslookup command are options for finding the IP address of a website. However, the simplest way to determine the IP address of a website is through the DNS lookup tool.

Go to the DNS lookup tool, type the website URL into the text entry, and click Lookup. Below, you can see the results for Google.com.

screenshot of DNS lookup tool with results

Note that the search yielded a list of IPv4 addresses that differ from the IPs shown using other methods. This is because many large companies have more than one IP address associated with a Fully Qualified Domain Name (FQDN), which Google.com is. When a system on the Internet looks up Google.com, the IP address returned by Google’s DNS servers may not be the same each time because there are several equally valid IP addresses for the same domain.

Many companies with publicly accessible websites use a round-robin DNS technique for associating IP addresses with their web servers. If a high volume of users are accessing their servers simultaneously, they won’t all be accessing the same server. Therefore, the DNS servers cycle through a list of IP addresses that are returned for DNS queries for an IP address for a web server in order to accurately determine how to find a server’s IP address.

Understanding the difference in IPv4 and IPv6 results

When receiving results for an IP address search, it’s possible to receive one of two kinds of IP addresses: IPv4 addresses or IPv6 addresses. It doesn’t matter what IP you’re searching. Whether it’s a Windows computer, a Mac, or some other device altogether like an iPhone. In some cases, both are available; for example, on the WhatIsMyIP.com homepage, you can check public IPv4 and IPv6 addresses as they are both displayed when available.

But why are there two different IP addresses displayed for the same search, like in the Google.com queries above? What is Google’s IP address?

In truth, there is no difference between the two in terms of how they function for a website. IPv6 is a newer version of the Internet Protocol, created to avoid IP exhaustion with IPv4 addresses. Because the original IPv4 address system lacked enough IP address combinations for all the devices accessing the Internet, the Internet Engineering Task Force (IETF) created the longer, more expansive IPv6 address system. Therefore, both are Google’s IP address. Once you know how to get the IP address of a server, you can test this with various sites and servers to see what results you retrieve.

Many websites’ IPs are now accessible using IPv6, though IPv4 continues to be widely used. Most people are more familiar with the IPv4 addresses. However, many networking devices are configured with both IPv4 and IPv6 connectivity capabilities. Internet service providers can process IPv4 and IPv6 data traffic simultaneously.

If you go to find the IP of a website or find server IP addresses, and you get an IPv4 address with an IP address lookup but then get an IPv6 address, neither result is wrong. They are both IP addresses assigned to the particular site you’re querying.

  • Do Not Sell My Personal Information
  • Change Consent

Website track ip address

Every website has at least one IP address connected to its domain name. For example, the website Facebook has, among others, the IP address 157.240.214.35 connected to the domain name www.facebook.com .

When you enter a URL in your browser, it will first determine the domain name of that URL. It then looks up the IP address and connects to the server with this IP. Once connected, it fetches the website’s source code to display the page.

These IP addresses are configured in the Domain Name System (DNS) as A and AAAA records. But how can you look up those IP addresses? That depends on the operating system you are using. Windows, Linux and Mac all have a different way of finding the IPv4 and IPv6 addresses. The sections below list the instructions for each operating system.

Example output of an IPv4 address lookup

How to lookup a website’s IP address on Windows

To check the server IP addresses for a domain name on Windows, follow these steps:

    Open a command prompt by navigating to

‘Type here to search’ →

Open a command prompt in Windows

Open.
Type

nslookup -q=A example.com and hit

IPv4 address lookup in Windows

[enter] to get the IPv4 addresses for example.com .

  • The IP addresses are listed below the Non-authoritative answer heading.
  • (Optional) To also see the IPv6 addresses, repeat these steps with AAAA instead of A .
  • How to lookup a website’s IP address on Mac OS

    To check the IP addresses for a domain name on a Mac, follow these steps:

      Open a terminal by entering

    Open a terminal on a Mac

    [enter].
    Type

    dig example.com A and hit

    IPv4 lookup on a Mac

    [enter] to get the IPv4 addresses for example.com .

  • The IP addresses are listed below the ANSWER SECTION heading.
  • (Optional) To also see the IPv6 addresses, repeat these steps with AAAA instead of A .
  • How to lookup a website’s IP address on Linux

    To check the IP addresses for a domain name on Linux, follow these steps:

      Open a terminal by entering

    Open a terminal in Linux

    [enter].
    Type

    dig example.com A and hit

    IPv4 lookup in Linux

    [enter] to get the IPv4 addresses for example.com .

  • The IP addresses are listed below the ANSWER SECTION heading.
  • (Optional) To also see the IPv6 addresses, repeat these steps with AAAA instead of A .
  • How to find a website’s IP address

    To check the IP addresses of a domain, follow these steps:

    Open the website to IP lookup tool

    1. Open the website to IP lookup tool.
    2. Enter the URL or domain name and hit

    Example IP addresses

    [enter].

  • The tool will query the IPv4 and IPv6 addresses and shown them at the top of the page.
  • DNS tools
    • Reverse IP lookup
    • DNS checker
    • Website to IP lookup
    • CNAME lookup
    • TXT lookup

    How to Track IP Address of Website Visitors

    Shyam is the Founder of Radiostud.io, a content-lead innovation studio, focusing on showcasing use cases of emerging technologies. He’s an entrepreneur, a technology evangelist, author, and mentor with a deep passion for nurturing ideas and building things around emerging and futuristic trends in Computing, Information Technology, and Telecommunications.

    Table of Contents:

    Heading

    For a layperson, an IP address is a cryptic sequence of numbers placed within dots. But if you are a trained network engineer, you would understand the nuances of those numbers and how that map onto the underlying network topology. But IP addresses have a meaning beyond those numbers that represent them.

    IP addresses are based on geography, similar to phone number area codes. Therefore, an app or website can track its visitor’s IP addresses to estimate the general area they are in. In this blog post, we introduce the Abstract’s IP Geolocation API to extract location-based information from any IP address. We cover the basic usage of the API, its use cases, and a quick developer preview of how to automate IP address tracking using Python.

    Don’t reinvent the wheel.
    Abstract’s APIs are production-ready now.

    Abstract’s suite of API’s are built to save you time. You don’t need to be an expert in email validation, IP geolocation, etc. Just focus on writing code that’s actually valuable for your app or business, and we’ll handle the rest.

    Why Do You Need to Track Your Website Visitors’ IP Addresses?

    If you are running an eCommerce business, your website’s hosting server would generate logs of visitors’ IP addresses. This is a goldmine of location data extracted from each IP address.

    By extracting the location information of the IP address you can track visitors in various ways:

    • Visitor Categorization from Specific Locations: Location information lets you categorize visitors based on cities, countries, and continents. This information is useful to understand the geographical outreach of your business.
    • Profiling Visitors: This results from visitor categorization. Knowing the locations of the visitor lets you build localization features on your portal. This can be as simple as displaying the content in the local language or offering custom deals based on the regional holidays and festivals of the location.
    • Security Threat Analysis: We often hear websites being attacked by malicious hackers or bots. Knowing the IP address of such visitors lets you track the locations where the attacks originate to build a location map. Based on that, you can program your website to take some steps, such as blocking the visitors from specific locations, or additional validation to deflect bots.

    Overview of AbstractAPI’s IP Geolocation API

    No matter whatever be your primary intent behind tracking IP addresses, the Abstract IP Geolocation API provides a full-featured IP location service through a REST API interface.

    Some of the salient features of the IP Geolocation API are as follows:

    • Granular Location Information: The IP geolocation API provides location information with high granularity, right down to the city names, with over 225,000+ cities mapped.
    • GeoPolitical Information: It also provides geopolitical information, such as the country’s flag images and currency.
    • Additional Useful Information: It provides useful information such as time zone and ISP details. These are useful for special cases of IP address tracking for visitor profiling or security threat analysis.
    • Support for Ipv6: It supports IP addresses in Ipv6 format as well.

    Check out the IP Geolocation API page to know more about its features, API docs, and samples.

    How To Track IP Addresses Of Your Website Visitors

    Let’s take the IP geolocation API for a test drive and learn how to find someone’s IP address.

    Try the IP Geolocation API

    Sign up for AbstractAPI and log into the main dashboard. You can locate the IP geolocation API under the listings for the Lookup category.

    Follow along the steps below to test the API.

    Step 1: Access the IP Geolocation API dashboard

    Click on the “IP geolocation” in the “Lookup” category. You can now see the API dashboard with a live test console.

    By default, you get a free plan that gives you 20000 requests to the API per month.

    Step 2: Access Your IP Geolocation API Key

    On the IP Geolocation API’s dashboard, you can see the API key generated for your account. This is a unique key assigned to your account. Make a note of this API key.

    Step 3: Test The IP Geolocation API On Your IP Address

    Clicking on the “Make test request” you can try out the API on your IP address.

    You get the API response in the JSON format, containing the location details as per your current physical location.

    Check out the “Documentation” sub-menu to get a full list of all the request and response parameters along with their explanations.

    Track IP Address Programmatically using Python

    APIs are best leveraged through a programmable interface that automates tasks. With IP Geolocation API, you can achieve the same to build a program that prepares a report of a user’s location based on their IP addresses.

    In the “Try it out” submenu, you can see quite a few options to invoke the IP Geolocation API through various programming languages. If you take Python, the code snippet for invoking the API looks like this.

    It uses the requests library for making API calls.

    Let’s build a real quick Python script to generate a geolocation report for IP addresses. This would be a great utility script for a website owner, who wants to track the physical location name of the website visitors.

    Here is how you can make it possible. Let’s consider that you want to capture the cities from where visitors are coming to your website. Your website is hosted on a web server platform that generates logs of the visitor IP addresses. If these IP addresses are collected in a tabular format, you can feed it to the Python script. This script leverages the IP Geolocations API to generate a CSV formatted report containing the cities of the visitors against each IP address.

    Start with the prerequisites to set up your Python programming environment and follow the steps below to build and test this script. It is assumed that you have a beginner to intermediate level proficiency in Python.

    Step 1: Setup the Python development environment

    You can use the latest version of Python3 environment downloaded from the official Python website. Choose the installation package as per your OS and platform.

    Step 2: Create a virtual environment

    Create a separate Python virtual environment to run the program. To create this environment open a terminal and run the following command

    This will create a project directory named ipgeo-script under the current directory where the command is executed.

    Activate the virtual environment and change into the project directory.

     ipgeo-script\Scripts\activatecd ipgeo-script 

    Install the Python library dependency. In this case, you will need the requests library for making REST API calls to the Abstract IP Geolocation API.

     python -m pip install requests 

    Step 3: Create the Python script program.

    Open your favorite code editor and copy the following code snippet:

     import requests import csv import time with open('ip-city.csv', 'w', newline='') as csvout: ipgeowriter = csv.writer(csvout, delimiter=',', quotechar='|', quoting=csv.QUOTE_MINIMAL) with open('ip.csv', newline='') as csvin: ipreader = csv.reader(csvin, delimiter=',') for row in ipreader: print("IP Address: " + row[0]) response = requests.get("https://ipgeolocation.abstractapi.com/v1/?fields=city&api_key="+"&ip_address="+row[0]) data = response.json() print("City: " + data['city']) ipgeowriter.writerow([row[0],data['city']]) time.sleep(1) 

    This program reads an input CSV file (ip.csv) containing IP addresses. It loops over each of them and calls the IP Geolocation API to get their city names. The IP address and the city are stored in another CSV file called ip-city.csv.

    Make sure to replace the placeholder with the actual key obtained from AbstractAPI dashboard. Save this file as ipgeo.py within the project folder.

    Step 4: Create the input IP address file

    Since the python script relies on the ip.csv input csv file continuing IP addresses, this file must be present in the same path as the script. Open a text editor file and create four IP entries.

    Save this file as ip.csv. This file serves as the web server log file containing the IP addresses of visitors.

    Step 5: Run the Python script

    Now your Python script is ready and the input IP addresses are available. Run the script with the Python interpreter.

     python ipgeo.py 

    If all goes well, the script will run and display the city names for each of the IP addresses in the ip.csv.

    At the end, you can also check the file ip-city.csv. This is the output CSV file generated by the script that contains the city names against IP addresses, as you wanted. You can open this file in a spreadsheet to check the city’s names.

    You have found a way to build a city profile for your website visitors.

    Conquer the World with IP Geolocation API

    You just saw how easy it is to track the cities of your website visitors. The same logic applies to regions, states, countries, time zones, and more. A detailed look at the documentation will give you the pointers to extract each of these information pieces from the API response.

    You can leverage the output data from the API to possibly build heat maps and other forms of visualizations to get a high-level view of your website’s standing from visitors around the world.

    So go ahead and customize the Python script as per your needs and take charge of your online business. In case you need a higher quota for API usage, check out the pricing for IP Geolocation API.

    FAQ

    What is the IP Geolocation API?

    The IP Geolocation API from AbstractAPI provides a REST-based service to locate the physical location of an IP address. It provides geopolitical information, including city, region, country, along with time zone and other information. It has comprehensive coverage for both IPv4 and IPv6 addresses with 1.75+ million locations across 225,000+ cities around the world, so you always have the most accurate results.

    Where can we use the IP Geolocation API?

    The IP Geolocation API from AbstractAPI can be used to get the geographical locations of the visitors connecting to a website. Since all Internet traffic is routed based on IP addresses, this API is useful for building the geolocation profiles of website visitors based on their IP addresses, for better-localized targeting and profiling. Similarly, any online property, be it a website, a portal, or an application server hosting apps, can track the geographical locations of visitors accessing the service.

    What are the Advantages of tracking IP Addresses?

    An IP address represents an endpoint on the Internet. Any user connecting to the Internet is allocated an IP address by the local ISP based on the region assigned by the IANA (Internet Assigned Numbers Authority). By tracking IP addresses, it is possible to know geographical information about a user. This is imperative for localized marketing campaigns based on the user’s location. Additionally, this is also useful for law enforcement agencies to track down malicious users on the Internet. With IP Geolocation API from Abstract API you get all the information related to the geographical location, time zones, and ISP details of an IP address.