如何确定是否一个IP地址属于一个国地址、IP

2023-09-02 01:53:01 作者:幼稚少年シメミ

我如何将决定该国一个spcific IP地址使用C#起源。我需要用它来检查,​​如果连接来自特定国家的起源。

How would i determine the country that a spcific IP address is originating from using c#. I need to use this to check if connections originate from a specific country.

推荐答案

您可以使用此SQL数据在您的项目来确定: IP地址地理位置SQL数据库。下载数据并将其导入到你的数据库在本地运行检查。

You can use this SQL data in your project to determine that: IP address geolocation SQL database. Download that data and import it into your database to run checks locally.

或者你也可以使用他们的免费的API,它返回一个包含该国code和国名的XML。你会成为一个请求的IP地址,你想检查下面的网址,在这个例子中看到的:

Or you can use their free API that returns XML containing the country code and country name. You'd make a request to the following URL with the IP address you wanted to check, as seen in this example:

http://ipinfodb.com/ip_query_country.php?ip=74.125.45.100

返回:

<Response>
<Ip>74.125.45.100</Ip>
<Status>OK</Status>
<CountryCode>US</CountryCode>
<CountryName>United States</CountryName>
</Response>
 
精彩推荐
图片推荐