There's a lot of software out there which provides approximate location information based on IP. I've read that this is possible because the IPs are assigned in blocks to particular locations, and organizations like the American Registry for Internet Numbers manage information about where they are distributed. The geolocation software queries their tables.
I'm trying to go the other way though. I'd like to know if there's any available method of providing a location (via zip code or DMA code) and generating a sample IP address that is located within that location. My search online has proved fruitless: is there an online service that does this, or is the method of distributing IPs done with a process that can be deconstructed to render an IP given this location information?
I have a solution for you. First, I'll highlight the high level steps.
(1) Download free data that links an IP address block to a zipcode. (the reverse of what you want).
(2) Simply query that database for a zipcode, and pick any IP in the "valid range" for that zipcode in the table you downloaded.
So for example, you wanted a valid ip address for Chicago, IL 60657, you'd look up the valid range of IP's for 60657 and pick one!
Down to specifics now... go to http://dev.maxmind.com/geoip/legacy/geolite/ scroll to the bottom and download Geolite City. This comes with two CSV's that you'll probably want to import into some sort of relational database. One table maps a location ID to a zipcode. The second table matches a location id to a valid IP range.
So when you want to come up with a valid IP for zipcode 60657, look up the location ID for 60657, then use the second table to lookup the valid IP range for that location ID.
One thing to keep in mind is that whenever you are dealing with IP address ranges, the nubmers are in decimal, I.E 16777471 instead of 103.412.411.22 (fake example). In order to convert between decimal notation and IP address notation, and visa versa, use the formulas on this site https://sites.google.com/site/followyourheart10/technical-section/ip-address-notations-conversion.
Good luck!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With