Free IP Locator API - Convert IP Addresses to Zip Codes with PHP

If you just want a free site to use:
IP Address Locator with Map


If you want a quick PHP solution, try this:

$ip = 'xxx.xxx.xxx.xxx';
var_dump(json_decode(file_get_contents("https://freegeoip.net/json/$ip"),true));



If you want quick responses, you can install the freegeoip server on ubuntu. This will give you your own personal IP locator service to use privately (or publicly if you are a nice guy):

Install golang 1.1.1
--------------------

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:duh/golang
sudo apt-get update
sudo apt-get install golang
go version

Set your go environment variables
---------------------------------

export GOROOT=/usr/lib/go

Install freegeoip
-----------------

git clone https://github.com/fiorix/freegeoip.git
cd freegeoip
go build

Download the database
---------------------

cd db
./updatedb
file ipdb.sqlite

Run it
------

cd ..
./freegeoip

cron script to keep the server running (replace $FREEGEOIP_PATH)
----------------------------------------------------------------

#!/bin/bash
ps cax | grep -v grep | grep freegeoip > /dev/null
result=$?
echo "${result}"
if [ "${result}" -eq "0" ] ; then
        echo "freegeoip is already running" #>>/home/work/cgcron
else
        cd $FREEGEOIP_PATH
        ./freegeoip &
fi

cron script to update the database regularly (replace $FREEGEOIP_PATH)
----------------------------------------------------------------------

#!/bin/bash
cd $FREEGEOIP_PATH/db
./updatedb &



8 comments:

  1. This comment has been removed by the author.

    ReplyDelete
    Replies
    1. That site is terrible. It says I live in Virginia. Please use the site in my post for more accurate IP locating.

      Delete
  2. Nice blog useful for those who are looking for some codes or sites to trace the location of any ip address ...I usually trace the location of an ip address just by doing whois search for that ip address through sites like WhoisXY.com here they will display details like ip location ,country ,ISP address ,name and so on but i can't trace exact home address of any person from ip address only the isp details can be found from ip address ...

    ReplyDelete
  3. Find IP address location. Enter an IP address and detect city, state, country and more. IP Address Locator service is free of use.

    ReplyDelete
  4. This IP address is the sole identifying factor of a computer's Internet activity. hide your IP address

    ReplyDelete
  5. For example if two organizations join and give new email addresses to their staffs, the auxiliary addresses can be utilized for workers to get messages at both their new and old email addresses. myip location

    ReplyDelete
  6. In the correct hands, an IP area database can be utilized to produce great and precise outcomes. Windows USA Arkansas

    ReplyDelete
  7. Numerous individuals worried about quick associations may then ask "how quick can a VPN go?" The least difficult answer is that; a VPN can go as quick as different sorts of association and can be quicker if there is quick web association at the two closures of the system. how to do a dns flush

    ReplyDelete