Find My IP Address location assignment and DHCP allocation

Implemented tool to find my IP Address and location

You can try the tool at – Find my IP Address with location tool

How is my IP Address assigned ?

Regional internet registries ( RIRs ) are responsible for IP address allocation to Internet Service Providers. Internet service providers ( ISPs ) in turn allocate IP addresses to enterprises, other service providers, and any organization requiring IP address space. In order to find my IP Address or information on any other IP address I use the tool below. This tool can find my IP address from the PHP variable $_SERVER[‘REMOTE_ADDR’].

To find my IP address location the code calls the API to gather the location coordinates. These coordinates are then used to find my IP address location on Google Maps. I have included the PHP code below that could be used to find any IP location and plot it on Google map.

Code for find my IP Address and location tool

function find_my_ip_address()

$ip = '';
 $ip = $_POST['ipAddress'];
else {
$xml = simplexml_load_file('' . $ip);

$ip = $xml->ipAddress;
$status = $xml->statusCode;
$country = $xml->countryName;
$region = $xml->regionName;
$city = $xml->cityName;
$latitude = $xml->latitude;
$longitude = $xml->longitude;
$timezone = $xml->timeZone;
$zipcode = $xml->zipCode;

$details = '
<div align="center"><form action="" method="post"><label><b>Submit your IP :</b></label><input id="ipAddress" style="margin-left: 10px;" type="text" name="ipAddress" value="' . $ip . '" /> <input type="submit" name="ipSubmit" value="lookup" /></form>
<td style="padding-right: 10px;">
<div align="left"><b>Your Ip Address :</b></div></td>
<td>' . $ip . '</td>
<td style="padding-right: 10px;">
<div align="left"><b>Country :</b></div></td>
<td>' . $country . '</td>
<td style="padding-right: 10px;">
<div align="left"><b>Region :</b></div></td>
<td>' . $region . '</td>
<td style="padding-right: 10px;">
<div align="left"><b>City :</b></div></td>
<td>' . $city . '</td>
<td style="padding-right: 10px;">
<div align="left"><b>Zip Code :</b></div></td>
<td>' . $zipcode . '</td>
<td style="padding-right: 10px;">
<div align="left"><b>Timezone :</b></div></td>
<td>' . $timezone . '</td>
<td style="padding-right: 10px;">
<div align="left"><b>Last page visited :</b></div></td>
<td>' . (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : "You came to this page directly") . '</td>
<td style="padding-right: 10px;">
<div align="left"><b>Your browser and OS information :</b></div></td>
<td>' . $_SERVER['HTTP_USER_AGENT'] . '</td>

<script type="text/javascript" src=";v=3&amp;sensor=false&amp;key=YOUR_KEY"></script>

<div id="map_canvas" style="width: 600px; height: 300px;"></div>
<script type="text/javascript">// <![CDATA[
 if (GBrowserIsCompatible()) {
 var map = new GMap2(document.getElementById("map_canvas"));
 var point = new GLatLng(' . $latitude . ',' . $longitude . ')
 map.addOverlay(new GMarker(point));
// ]]></script>
return $details; }

Now just call the function as to find my IP address and location on Google maps.
Find my ip address

How to find my IP Address version 4 ( IPv4 )

The IP address found by find my IP address tool above is an IPv4 IP address. IPv4 is Internet Protocol version 4. IPv4 IP addresses are represented in dotted decimal format where the 32-bit address is divided into four 8-bit segments, each of which are converted to decimal, and then separated with dots.

How to find my IP Address version 6 ( IPv6 )

With tool above I cannot find my IP address version 6. In future I need to be able to find my IPv6 IP address. IPv6 IP address is considered an evolution of IPv4 IP address and still needs to be deployed widely. IPv6 IP addresses are 128 bit and consist of up to eight hexadecimal values (16 bit each), each between 0 and FFFF, separated by colons. Each address digit represents four bits as per the mapping of each hex digit (0–F).

For example: 2001 : DB8 : 5F62 : AB41 : 0 : 0 : 0 : 801 represents an IPv6 IP address. Looking at each digit, 2 = 0010, 0=0000, 0=0000, 1=0001, 0=0000, D=1101 and so on.

Main IPv6 IP address features

Expanded Addressing

128 bits hierarchically assigned with address scoping (e.g., local link versus global) to improve scalability.


Supports flexible extension headers and provide extensibility for new header types. It also has more efficient routing mechanism.


Quality of service (QoS) support.


Replaces broadcast.


It supports hierarchical routing and route aggregation.


Includes datagram service.


Has support for encryption and authentication

Auto configuration

Stateless and stateful address self-configuration by IP devices.


Support for Mobile IPv6.

What is DHCP

The Dynamic Host Configuration Protocol ( DHCP ) is a client–server protocol for devices connecting to an IP network to automatically obtain an IP address. The IP address found for a device on this page could have been assigned via an DHCP server. This protocol allows a device to broadcast its request for an IP address and one or more than one DHCP servers service that request transparently. For most devices such as laptops, desktops or phones with data services the DHCP process happens during boot-up without any intervention. DHCP allows IP addresses to be reused by different devices as it dynamically allocates the addresses based on demand. DHCP is supported as part of both IPv4 and IPv6.

Types of IP address allocation in DHCP

Manual or Static Allocation

In this case the DHCP server assigns a fixed IP address based on MAC address.

Dynamic Allocation

Here the DHCP server assigns an IP address to a device for a limited time period. The same IP address could be later reassigned to another device if its lease is over and not renewed on initial device. DHCP server allocates IP addresses from a configured range assigned to it.

Automatic Allocation

Here the DHCP server assigns a permanent IP address to the client. The idea is similar to dynamic mode however in this case DHCP server assigns same IP Addresses from list of ones used previously for that particular device. The DHCP server maintains a list of IP addresses and MAC addresses pairs which it uses for assignment.

For those devices that obtain IPv6 addresses dynamically, a client based or a network server based approach could be used. In client-based or stateless address assignment (address auto configuration) a client can determine its location based on router advertisements using ICMPv6 and automatically calculate its interface identifier to derive an address. However it might need manual intervention in case of duplicate addresses being detected. In case of DHCP for IPv6 (which is called DHCPv6), which is a network server based or stateful approach, the DHCPv6 server would assign the 128-bit IPv6 address to the device in a manner similar to DHCP for IPv4 operation.

Related Posts