I want to show country flag depending on ip address I receive at server side. Are fixed ip addresses are assigned to countries ? Where can I get database for ip address to country mapping ?
Asked
Active
Viewed 2.3k times
10
-
1Quite straight forward. Get [country flag icons](http://365icon.com/icon-styles/ethnic/classic2/) & map [IP address to country](https://ipapi.co/api/?shell#specific-field-for-an-ip) name. The icon & country names are linked via country [codes](https://en.wikipedia.org/wiki/ISO_3166-1). – Ken Jun 16 '16 at 17:55
5 Answers
13
Take a look at the following:
- IP address geolocation SQL database
- Geo Locate IP Address XML API Whois Map Country Provider
- How to Geolocate Visitors Using an IP-to-Country Database
- Free IP to Country Database
- My IP Address Lookup and Geotarget IP Project
- MaxMind - Open Source IP Address to Country Database
- IP address geolocation SQL database
Also on Stack Overflow:
- What is the most applicable solution to detect which country an ip belongs to?
- Is there any possible way to find the name of the country using IP with scripting language PHP?
- IP to Country?
- code for finding the state,country,city from the IP Adress in php
Once you have the country code, then you can display the flag with these free icon sets which use ISO country codes:
PHP Advent also just published a whole article on a very similar process:

Community
- 1
- 1

Philip Morton
- 129,733
- 38
- 88
- 97
-
1It would be nice to know which resource/link you used to solve your problem. – Sam ツ Feb 20 '17 at 06:37
3
You're looking for an IP geolocation service such as MaxMind.

Rob
- 47,999
- 5
- 74
- 91
-
Or GeoBytes (http://www.geobytes.com/IpLocator.htm?GetLocation), or... We should all probably just edit this answer (which is, generically, use a reference site) with a list of them. :-) – T.J. Crowder Dec 20 '09 at 12:01
-
@T.J.Crowder it is not showing exact location. Shown some other. – UdayKiran Pulipati Jan 28 '14 at 09:36
-
1
ip2location.com provides an IP range database which can be used to tag IP addresses
they provide it in different formats as well so you can choose which one is useful to you

Kristina
- 15,859
- 29
- 111
- 181