如何确定是否一个IP地址属于一个国 [英] How to determine if an IP address belongs to a country

查看:168
本文介绍了如何确定是否一个IP地址属于一个国的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何将决定该国一个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:

<一个href="http://ipinfodb.com/ip_query_country.php?ip=74.125.45.100">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>

这篇关于如何确定是否一个IP地址属于一个国的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆