• December 21, 2024

Ip Addresses By Country

Identifying country by IP address - Stack Overflow

Identifying country by IP address – Stack Overflow

Here is my solution in Python 3. x to return geo-location info given a dataframe containing IP Address(s); efficient parallelized application of function on vectorized is the way to go.
Will contrast performance of two popular libraries to return location.
TLDR: use geolite2 method.
1. geolite2 package from geolite2 library
Input
#! pip install maxminddb-geolite2
import time
from geolite2 import geolite2
geo = ()
df_1 = [:50, [‘IP_Address’]]
def IP_info_1(ip):
try:
x = (ip)
except ValueError: #Faulty IP value
return
return x[‘country’][‘names’][‘en’] if x is not None else
except KeyError: #Faulty Key value
s_time = ()
# map IP –> country
#apply(fn) applies fn. on all elements
df_1[‘country’] = [:, ‘IP_Address’](IP_info_1)
print((), ‘\n’)
print(‘Time:’, str(()-s_time)+’s \n’)
print(type((’48. 151. 136. 76′)))
Output
IP_Address country
0 48. 76 United States
1 94. 9. 145. 169 United Kingdom
2 58. 94. 157. 121 Japan
3 193. 187. 41. 186 Austria
4 125. 96. 20. 172 China
Time: 0. 09906983375549316s

2. DbIpCity package from ip2geotools library
#! pip install ip2geotools
from ncommercial import DbIpCity
df_2 = [:50, [‘IP_Address’]]
def IP_info_2(ip):
return (ip, api_key = ‘free’). country
except:
df_2[‘country’] = [:, ‘IP_Address’](IP_info_2)
print(())
print(‘Time:’, str(()-s_time)+’s’)
print(type((’48. 76′, api_key = ‘free’)))
0 48. 76 US
1 94. 169 GB
2 58. 121 JP
3 193. 186 AT
4 125. 172 CN
Time: 80. 53318452835083s

A reason why the huge time difference could be due to the Data structure of the output, i. e direct subsetting from dictionaries seems way more efficient than indexing from the specicialized object.
Also, the output of the 1st method is dictionary containing geo-location data, subset respecitively to obtain needed info:
x = ()(’48. 76′)
print(x)
>>>
{‘city’: {‘geoname_id’: 5101798, ‘names’: {‘de’: ‘Newark’, ‘en’: ‘Newark’, ‘es’: ‘Newark’, ‘fr’: ‘Newark’, ‘ja’: ‘ニューアーク’, ‘pt-BR’: ‘Newark’, ‘ru’: ‘Ньюарк’}},
‘continent’: {‘code’: ‘NA’, ‘geoname_id’: 6255149, ‘names’: {‘de’: ‘Nordamerika’, ‘en’: ‘North America’, ‘es’: ‘Norteamérica’, ‘fr’: ‘Amérique du Nord’, ‘ja’: ‘北アメリカ’, ‘pt-BR’: ‘América do Norte’, ‘ru’: ‘Северная Америка’, ‘zh-CN’: ‘北美洲’}},
‘country’: {‘geoname_id’: 6252001, ‘iso_code’: ‘US’, ‘names’: {‘de’: ‘USA’, ‘en’: ‘United States’, ‘es’: ‘Estados Unidos’, ‘fr’: ‘États-Unis’, ‘ja’: ‘アメリカ合衆国’, ‘pt-BR’: ‘Estados Unidos’, ‘ru’: ‘США’, ‘zh-CN’: ‘美国’}},
‘location’: {‘accuracy_radius’: 1000, ‘latitude’: 40. 7355, ‘longitude’: -74. 1741, ‘metro_code’: 501, ‘time_zone’: ‘America/New_York’},
‘postal’: {‘code’: ‘07102’},
‘registered_country’: {‘geoname_id’: 6252001, ‘iso_code’: ‘US’, ‘names’: {‘de’: ‘USA’, ‘en’: ‘United States’, ‘es’: ‘Estados Unidos’, ‘fr’: ‘États-Unis’, ‘ja’: ‘アメリカ合衆国’, ‘pt-BR’: ‘Estados Unidos’, ‘ru’: ‘США’, ‘zh-CN’: ‘美国’}},
‘subdivisions’: [{‘geoname_id’: 5101760, ‘iso_code’: ‘NJ’, ‘names’: {‘en’: ‘New Jersey’, ‘es’: ‘Nueva Jersey’, ‘fr’: ‘New Jersey’, ‘ja’: ‘ニュージャージー州’, ‘pt-BR’: ‘Nova Jérsia’, ‘ru’: ‘Нью-Джерси’, ‘zh-CN’: ‘新泽西州’}}]}
List of countries by IPv4 address allocation - Wikipedia

List of countries by IPv4 address allocation – Wikipedia

This article needs to be updated. Please help update this article to reflect recent events or newly available information. (July 2021)
This is a list of countries by IPv4 address allocation, as of 2 April 2012. It includes 252 areas, including all United Nations member states, plus the Holy See, Kosovo and Taiwan.
There are 232 (over four billion) IP addresses in the IPv4 protocol. Of these, almost 600 million are reserved and cannot be used for public routing. [1] The rest are allocated to countries by the Internet Assigned Numbers Authority (IANA) via the regional Internet registries (RIRs). [2]
Rank
Country or entity
IP addresses%
Population(mostly 2012)[3]
IP addressesper 1000
World
4, 294, 967, 296
100. 0
7, 021, 836, 029
611
1
United States
1, 541, 605, 760
35. 9
313, 847, 465
4, 911
2
People’s Republic of China
330, 321, 408
7. 7
1, 343, 239, 923
245
3
Japan
202, 183, 168
4. 7
127, 368, 088
1, 587
4
United Kingdom
123, 500, 144
2. 9
63, 047, 162
1, 958
5
Germany
118, 132, 104
2. 8
81, 305, 856
1, 452
6
South Korea
112, 239, 104
2. 6
48, 860, 500
2, 297
7
France
95, 078, 032
2. 2
65, 630, 692
1, 448
8
Canada
79, 989, 760
1. 9
34, 300, 083
2, 332
9
Italy
50, 999, 712
1. 2
61, 261, 254
832
10
Brazil
48, 572, 160
1. 1
205, 716, 890
236
11
Australia
47, 573, 248
22, 015, 576
2, 160
12
Netherlands
46, 379, 784
16, 730, 632
2, 772
13
Russia
42, 762, 784
1. 0
138, 082, 178
309
14
Taiwan
35, 383, 040
0. 8
23, 113, 901
1, 530
15
India
34, 685, 952
1, 205, 073, 612
28
16
Sweden
30, 373, 544
0. 7
9, 103, 788
3, 336
17
Spain
28, 421, 760
47, 042, 984
604
18
Mexico
25, 862, 912
0. 6
114, 975, 406
224
19
Switzerland
20, 872, 696
0. 5
7, 655, 628
2, 726
20
South Africa
20, 386, 560
48, 810, 427
417
21
Poland
19, 433, 192
38, 415, 284
505
22
Indonesia
17, 360, 640
0. 4
248, 216, 193
69
23
Vietnam
15, 530, 496
91, 519, 289
169
24
Turkey
15, 393, 728
79, 749, 461
193
25
Norway
15, 259, 312
4, 707, 270
3, 241
26
Argentina
14, 547, 968
0. 3
42, 192, 494
344
27
Finland
13, 553, 856
5, 262, 930
2, 575
Romania
12, 718, 592
21, 848, 504
582
29
Denmark
12, 280, 304
5, 543, 453
2, 215
Hong Kong
11, 777, 024
7, 153, 519
1, 646
30
Austria
11, 312, 096
8, 219, 743
1, 376
31
Ukraine
11, 242, 816
44, 854, 065
250
32
Belgium
11, 148, 992
10, 438, 353
1, 068
33
Colombia
8, 834, 816
0. 2
45, 239, 079
195
34
Thailand
8, 547, 840
67, 091, 089
127
European Union
8, 493, 568
503, 824, 373
16. 86
35
Egypt
8, 454, 144
83, 688, 164
101. 02
36
Czech Republic
8, 044, 160
10, 177, 300
790. 40
37
Israel
7, 573, 824
7, 590, 758
997. 77
38
Chile
7, 390, 464
17, 067, 369
433. 02
39
New Zealand
6, 954, 496
4, 327, 944
1, 606. 88
40
Malaysia
6, 322, 432
0. 1
29, 179, 952
216. 67
41
Ireland
5, 963, 280
4, 722, 028
1, 262. 86
42
Portugal
5, 833, 504
10, 781, 459
541. 07
43
Singapore
5, 719, 552
5, 353, 494
1, 068. 38
44
Greece
5, 549, 568
10, 767, 827
515. 38
45
Saudi Arabia
5, 504, 256
26, 534, 504
207. 44
46
Hungary
5, 485, 568
9, 958, 453
550. 85
47
Philippines
5, 404, 672
103, 775, 002
52. 08
48
Iran
5, 260, 800
78, 868, 711
66. 70
49
Pakistan
5, 179, 904
190, 291, 129
27. 22
50
Venezuela
5, 045, 248
28, 047, 938
179. 88
51
Bulgaria
4, 374, 032
7, 053, 747
621. 49
52
Morocco
3, 457, 792
32, 309, 239
107. 02
53
United Arab Emirates
2, 838, 400
5, 314, 317
534. 10
54
Tunisia
2, 729, 216
10, 732, 900
254. 29
55
Algeria
2, 616, 832
35, 406, 303
73. 91
56
Slovakia
2, 555, 392
5, 483, 088
466. 05
57
Slovenia
2, 525, 056
1, 996, 617
1, 264. 67
58
Kazakhstan
2, 514, 944
17, 522, 010
143. 53
59
Peru
2, 437, 120
29, 549, 517
82. 48
60
Lithuania
2, 240, 256
3, 525, 761
635. 40
61
Croatia
2, 042, 432
0. 0
4, 480, 043
455. 90
62
Serbia
2, 022, 144
7, 276, 604
277. 90
63
Costa Rica
1, 944, 832
4, 636, 348
419. 47
64
Kuwait
1, 885, 184
2, 646, 314
712. 38
65
Ecuador
1, 857, 280
15, 223, 680
122. 00
66
Belarus
1, 776, 640
9, 542, 883
186. 17
67
Latvia
1, 659, 328
2, 191, 580
757. 14
68
Kenya
1, 655, 040
43, 013, 341
38. 48
Panama
1, 573, 376
3, 510, 045
448. 25
70
Luxembourg
1, 299, 456
509, 074
2, 552. 59
71
Estonia
1, 205, 560
1, 274, 709
945. 75
72
Uruguay
1, 180, 416
3, 316, 328
355. 94
73
Cyprus
1, 136, 896
1, 138, 071
998. 97
74
Georgia
1, 014, 784
4, 570, 934
222. 01
75
Nigeria
1, 005, 312
170, 123, 740
5. 91
Puerto Rico
1, 000, 704
3, 998, 905
250. 24
76
Bangladesh
924, 160
161, 083, 804
5. 74
77
Dominican Republic
857, 600
10, 088, 598
85. 01
78
Syria
824, 320
22, 530, 746
36. 59
79
Iceland
814, 592
313, 183
2, 601. 01
80
Qatar
808, 960
1, 951, 591
414. 51
81
Moldova
733, 440
3, 656, 843
200. 57
82
Bosnia and Herzegovina
728, 832
4, 622, 292
157. 68
83
Jordan
663, 936
6, 508, 887
102. 00
84
North Macedonia
657, 664
2, 082, 370
315. 82
85
Oman
619, 520
3, 090, 150
200. 48
86
El Salvador
575, 744
6, 090, 646
94. 53
87
Bolivia
561, 920
10, 290, 003
54. 61
88
Malta
556, 544
409, 836
1, 357. 97
89
Guatemala
552, 192
14, 099, 032
39. 17
90
Sri Lanka
534, 272
21, 481, 334
24. 87
91
Armenia
525, 088
2, 970, 495
176. 77
92
Azerbaijan
517, 120
9, 493, 600
54. 47
Palestine
510, 720
4, 332, 801
117. 87
93
Mauritius
496, 640
1, 313, 095
378. 22
94
Nepal
475, 904
29, 890, 686
15. 92
95
Trinidad and Tobago
470, 016
1, 226, 383
383. 25
96
Bahrain
465, 920
1, 248, 348
373. 23
97
Lebanon
457, 728
4, 140, 289
110. 55
98
Nicaragua
369, 408
5, 727, 707
64. 49
99
Paraguay
365, 312
6, 541, 591
55. 84
100
Mozambique
343, 296
23, 515, 934
14. 60
101
Tanzania
339, 712
43, 601, 796
7. 79
102
Ghana
332, 544
25, 241, 998
13. 17
Macau
324, 864
578, 025
562. 02
103
Albania
323, 840
3, 002, 859
107. 84
104
Angola
311, 808
18, 056, 072
17. 27
Netherlands Antilles[a]
308, 992
287, 244
1, 075. 71
105
Libya
299, 008
6, 733, 620
44. 41
106
Senegal
293, 248
12, 969, 606
22. 61
107
Sudan & South Sudan
283, 904
44, 831, 886
6. 33
108
Iraq
243, 712
31, 129, 225
7. 83
109
Uzbekistan
231, 424
28, 394, 180
8. 15
110
Kyrgyzstan
231, 168
5, 496, 737
42. 06
111
Cambodia
225, 536
14, 952, 665
15. 08
Guam
213, 504
185, 674
1, 149. 89
112
Uganda
208, 640
35, 873, 253
5. 82
113
Kosovo
205, 056
1, 836, 529
111. 65
114
Jamaica
202, 752
2, 889, 187
70. 18
115
Mongolia
201, 984
3, 179, 997
63. 52
116
Namibia
199, 168
2, 165, 828
91. 96
117
Rwanda
195, 840
11, 689, 696
16. 75
118
Brunei
192, 512
408, 786
470. 94
119
Montenegro
171, 520
657, 394
260. 91
120
Gabon
169, 472
1, 608, 321
105. 37
121
Zambia
162, 816
14, 309, 466
11. 38
New Caledonia
150, 528
260, 166
578. 58
122
Honduras
143, 616
8, 296, 693
17. 31
123
Barbados
140, 032
287, 733
486. 67
124
Cameroon
137, 728
20, 129, 878
6. 84
125
Fiji
134, 656
890, 057
151. 29
126
Côte d’Ivoire
133, 632
21, 952, 093
6. 09
Haiti
124, 160
9, 801, 664
12. 67
128
Bahamas
121, 856
316, 182
385. 40
129
Cuba
113, 664
11, 075, 244
10. 26
130
Afghanistan
103, 744
30, 419, 928
3. 41
131
Botswana
100, 096
2, 098, 018
47. 71
Bermuda
91, 648
69, 080
1, 326. 69
United States Virgin Islands
87, 040
109, 574
794. 35
132
Zimbabwe
86, 016
12, 619, 600
6. 82
133
Malawi
79, 616
16, 323, 044
4. 88
134
Liechtenstein
69, 408
36, 713
1, 890. 56
135
Tajikistan
67, 328
7, 768, 385
8. 67
Gibraltar
62, 976
29, 034
2, 169. 04
136
Saint Kitts and Nevis
62, 464
50, 726
1, 231. 40
137
Madagascar
62, 208
22, 585, 517
2. 75
138
Belize
61, 952
327, 719
189. 04
139
Monaco
57, 856
30, 510
1, 896. 30
140
Antigua and Barbuda
57, 344
89, 018
644. 18
141
Laos
54, 784
6, 586, 266
8. 32
142
Maldives
53, 760
394, 451
136. 29
143
Yemen
51, 200
24, 771, 809
2. 07
144
Papua New Guinea
49, 920
6, 310, 129
7. 91
145
Suriname
44, 032
560, 157
78. 61
French Polynesia
41, 472
274, 512
151. 08
146
Lesotho
40, 448
1, 930, 493
20. 95
147
Benin
39, 936
9, 598, 787
4. 16
Faroe Islands
49, 483
807. 07
Aruba
38, 912
107, 635
361. 52
148
Guyana
741, 908
52. 45
149
Mali
36, 864
14, 533, 511
2. 54
150
Seychelles
36, 352
90, 024
403. 80
Cayman Islands
35, 840
52, 560
681. 89
151
Eswatini
34, 560
1, 386, 914
24. 92
152
Andorra
32, 768
85, 082
385. 13
153
Ethiopia
93, 815, 992
0. 35
154
Mauritania
3, 359, 185
9. 75
Réunion
155
Burkina Faso
32, 512
17, 275, 115
1. 88
Åland Islands
28, 928
156
San Marino
26, 880
32, 140
836. 34
157
Myanmar
25, 600
54, 584, 650
0. 47
158
Bhutan
23, 552
716, 896
32. 85
159
Gambia
21, 504
1, 840, 454
11. 68
160
Democratic Republic of the Congo
21, 248
73, 599, 190
0. 29
161
Niger
20, 480
17, 078, 839
1. 20
162
Vatican City
17, 920
836
21, 435. 41
163
Sierra Leone
5, 485, 998
3. 27
164
Cape Verde
17, 408
523, 568
33. 25
165
Saint Vincent and the Grenadines
103, 537
168. 13
166
Samoa
16, 640
194, 320
85. 63
Greenland
16, 384
57, 695
283. 98
British Virgin Islands
14, 336
31, 148
460. 25
167
Liberia
13, 312
3, 887, 886
3. 42
Northern Mariana Islands
44, 582
298. 60
168
Togo
6, 961, 049
1. 91
Republic of the Congo
12, 288
4, 366, 266
2. 81
170
Djibouti
774, 389
15. 87
171
Vanuatu
10, 752
227, 574
47. 25
172
Somalia
10, 240
10, 085, 638
1. 02
173
Solomon Islands
9, 728
584, 578
16. 64
174
Turkmenistan
8, 704
5, 054, 828
1. 72
175
Grenada
8, 448
109, 011
77. 50
176
São Tomé and Príncipe
183, 176
46. 12
Cook Islands
8, 192
10, 777
760. 14
177
Nauru
9, 378
873. 53
Turks and Caicos Islands
46, 335
176. 80
178
Tuvalu
10, 619
771. 45
Saint Martin
7, 168
30, 959
231. 53
Jersey
6, 144
94, 949
64. 71
179
Federated States of Micronesia
106, 487
57. 70
180
Tonga
106, 146
57. 88
181
Burundi
5, 376
10, 557, 259
0. 51
182
Guinea-Bissau
5, 120
1, 628, 603
3. 14
Isle of Man
4, 608
85, 421
53. 94
183
Central African Republic
4, 352
5, 057, 208
0. 86
American Samoa
4, 096
68, 061
60. 18
Anguilla
15, 423
265. 58
184
Chad
10, 975, 648
0. 37
185
Comoros
737, 284
5. 56
186
Eritrea
6, 086, 495
0. 67
Guadeloupe
187
Guinea
10, 884, 958
0. 38
188
Palau
21, 032
194. 75
Saint Pierre and Miquelon
5, 831
702. 45
189
Timor-Leste
1, 201, 255
British Indian Ocean Territory
3, 072
190
Equatorial Guinea
685, 991
4. 48
191
Kiribati
101, 998
30. 12
Wallis and Futuna
15, 453
198. 80
French Guiana
2, 048
Guernsey
65, 345
31. 34
192
Marshall Islands
68, 480
29. 91
Niue
1, 269
1, 613. 87
Tokelau
1, 368
1, 497. 08
Norfolk Island
1, 536
2, 182
703. 94
Montserrat
1, 280
5, 164
247. 87
Dominica
1, 024
73, 126
14. 00
194
North Korea
24, 589, 122
0. 04
Saint Lucia
256
162, 178
1. 58
Antarctica
0
0. 00
Asia Pacific
Bonaire, Saint Eustatius and Saba
Bouvet Island
Christmas Island
1, 496
Cocos (Keeling) Islands
596
Curaçao
142, 180
Falkland Islands
3, 140
French Southern and Antarctic Lands
Heard Island and McDonald Islands
Martinique
Mayotte
Pitcairn Islands
Saint Barthélemy
7, 332
Saint Helena, Ascension and Tristan da Cunha
7, 728
Sint Maarten
37, 429
South Georgia and the South Sandwich Islands
Svalbard & Jan Mayen[b]
1, 970
United States Minor Outlying Islands
Western Sahara
522, 928
^ Includes the population of Aruba, Curaçao and Sint Maarten.
^ Population of Jan Mayen not included.
Charts and graphs[edit]
List of countries by IPv4 address allocation per 1000 population
See also[edit]
IP address
IPv4 address exhaustion
Internet Census of 2012 (Carna Botnet)
List of assigned /8 IPv4 address blocks
References[edit]
^ “IANA IPv4 Address Space Registry”, Internet Assigned Numbers Authority (IANA). Retrieved 12 July 2014.
^ “Number Resources”, Internet Assigned Numbers Authority (IANA). Retrieved 12 July 2014.
^ Population, The World Factbook, United States Central Intelligence Agency. Accessed on 2 April 2012. Note: Data are mostly for 1 July 2012.
Ip Address By Country 2021 - World Population Review

Ip Address By Country 2021 – World Population Review

Every machine on a network has a unique identifier. Most computers and networks use the TCP/IP protocol as the standard for communicating on a network, which uses an IP address to identify a computer. An Internet Protocol address, or an IP address, is a numerical label assigned to each device connected to a computer network that uses the Internet Protocol for communication.
There are two standards for IP addresses. IP Version 4 (IPv4) and IP Version 6 (IPv6). IPv4 uses 32 binary bits to create a single unique address on the network. An IPv4 address is expressed by four numbers separated by decimals. IPv6 uses 128 binary bits to create a single unique address that is expressed by eight groups of hexadecimal numbers separated by colons. All computers with IP addresses have an IPv4 address and many are starting to incorporate the newer IPv6 addresses.
There are about 4. 294 billion IP addresses the IPv4 protocol, 600 million of which are reserved and cannot be used for public routing. The Internet Assigned Numbers Authority (IANA) allocates the rest of the IP addresses to countries. Allocation does not necessarily correlate with population numbers.
Of the over 4 billion IP addresses, 1, 541, 605, 760 are allocated to the United States, the highest number of any country. This comes out to about 4, 911 IP addresses per 1, 000 people. These comprise about 35. 9% of the total number of IP addresses.
China has the second-highest number of IP addresses of 330, 321, 408, about 7. 7% of the total number of IP addresses. China is followed by Japan with 202, 183, 168 and the United Kingdom with 123, 500, 144. Germany has the fifth-highest number of IP addresses with 118, 132, 104.
Vatican City, which has the smallest population of any sovereign state of fewer than 1, 000 people, has 17, 920 IP addresses. This equates to 21, 435 IP addresses per 1, 000 people.
Factored into the 4. 294 million IP addresses are over 875 million bogons, which are bogus (or fake) IP addresses on a computer network. Bogons include IP packets with addresses that are not in any range allocated or delegated by the IANA. Most Internet service providers and firewalls filter out bogons as they have no use and are usually the result of accidental or malicious misconfiguration.
Below is the number of IP addresses in every country, as well as the number of IP addresses 1, 000 people in the population and the percentage of total IP addresses each country possesses.

Frequently Asked Questions about ip addresses by country

Can you tell country from IP address?

No you can’t – IP addresses get reallocated and reassigned from time to time, so the mapping of IP to location will also change over time.Mar 21, 2012

How are IP addresses assigned by country?

There are 232 (over four billion) IP addresses in the IPv4 protocol. Of these, almost 600 million are reserved and cannot be used for public routing. The rest are allocated to countries by the Internet Assigned Numbers Authority (IANA) via the regional Internet registries (RIRs).

What country is an IP address from?

IP Address InformationIP Address:66.249.65.199Country:United States of AmericaState:CaliforniaLatitude:37.405992Longitude:-122.0785159 more rows

Leave a Reply