如何判断IP地址属于哪家公司?

发布于 2024-07-25 04:26:42 字数 881 浏览 5 评论 0原文

我正在尝试以编程方式确定与给定 IP 地址关联的公司*。

我的第一个猜测是:

  string hostname = Dns.GetHostEntry(IPAddress.Parse(ip)).HostName;

但是如果反向 DNS 设置不正确,这将不起作用,这似乎 90% 的情况都会发生。

然而,即使反向 DNS 失败,某些网站仍然能够成功确定与特定 IP 关联的公司。 例如,在此网站上,ISP 提供商字段有时包含有价值的信息(即公司名称),即使主机名未设置。

使用 .net 实现相同目标的最简单方法是什么?


注意:

  • 我不需要规范的名称。 即MS或Microsoft都可以。
  • 我的目标是大公司,它们可能“拥有”自己的 IP 地址范围。
  • 我在Windows上运行,所以默认情况下没有安装unix的whois工具。

关于 whois 的使用进行编辑:有时,没有与 IP 关联的 whois 信息

I'm trying to programmaticaly determine the company* associated with a given IP address.

My first guess was this :

  string hostname = Dns.GetHostEntry(IPAddress.Parse(ip)).HostName;

but this won't work if the reverse DNS isn't set correctly, which seems to happen 90% of the time.

However some websites are still able to successfully determine the company associated with a specific IP even if the reverse dns fails. For example, on this site, the ISP Provider field sometimes contains valuable information (ie the name of the company) even if the hostname isn't set.

What's the easiest way to achieve the same thing using .net ?


Notes :

  • I don't need a canonical name. ie MS or Microsoft are both ok.
  • I'm targeting big companies, which are likely to "own" their IP address ranges.
  • I'm running on Windows, so unix's whois tools are not installed by default.

Edit regarding the use of whois : Sometimes, there's no whois information associated with an IP

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

擦肩而过的背影 2024-08-01 04:26:42

您可以从 microsoft edit 安装适用于 Windows 的 whois 命令行工具

:那么您要寻找什么信息?

>whois bbc.co.uk
Domain name:
    bbc.co.uk

Registrant:
    British Broadcasting Corporation

Registrant type:
    UK Limited Company, (Company number: 000057)

Registrant's address:
    Research & Development
    Kingswood Warren
    Tadworth
    Surrey
    KT20 6NP
    United Kingdom

Registrar:
    British Broadcasting Corporation [Tag = BBC]

You can install the whois command line tool for windows from microsoft

edit: then what information are you looking for ?

>whois bbc.co.uk
Domain name:
    bbc.co.uk

Registrant:
    British Broadcasting Corporation

Registrant type:
    UK Limited Company, (Company number: 000057)

Registrant's address:
    Research & Development
    Kingswood Warren
    Tadworth
    Surrey
    KT20 6NP
    United Kingdom

Registrar:
    British Broadcasting Corporation [Tag = BBC]
み零 2024-08-01 04:26:42

您可以在 https://ws.arin.net/whois 网站上进行 whois 查找并解析出您正在寻找的信息。

You can do a whois lookup on the https://ws.arin.net/whois website and parse out the information you are looking for.

冬天的雪花 2024-08-01 04:26:42

大多数情况下,我赞同“whois”答案。 过去,公司拥有整个地址块,因此人们编写自己的“whois”相当容易,但随着 IP(v4) 地址变得越来越稀缺,这变得不再容易。 我现在根本就不想尝试。 使用真正的 whois。

Mostly I'm seconding the "whois" answers. Back in the day companies owned whole blocks of addresses, so it used to be fairly easy for people to write their own "whois", but as IP(v4) addresses got more scarce, it quit being easy. I wouldn't even think of trying it now. Use a real whois.

末骤雨初歇 2024-08-01 04:26:42

检查此 http://ws.arin.net/whois/ 它应该提供您所需的信息

您可以尝试请求

http://ws.arin.net/whois/?queryinput={ipaddress} 使用 WebClient 或 WebRequest,然后尝试解析返回的字符串。

一个简单的 string.IndexOf("OrgName:") 查找应该可以让您接近。

示例网址 http://ws.arin.net/whois/?queryinput=207.46。 193.254

HTH

OneSHOT

Check this http://ws.arin.net/whois/ it should provide the info you require

You could try requesting

http://ws.arin.net/whois/?queryinput={ipaddress} using a WebClient or WebRequest and then try parsing the returned string.

A simple string.IndexOf("OrgName:") lookup should get you close.

example url http://ws.arin.net/whois/?queryinput=207.46.193.254

HTH

OneSHOT

站稳脚跟 2024-08-01 04:26:42

与许多程序问题一样,您所要求的并不像您想象的那么简单。

首先问题...您希望解析的 IP 地址的来源是什么 - 网站“访问者”、网络服务器还是未知来源? 出于此回复的目的,我将假设您希望“转换”网站访问者,因为这是解析 IP-> 公司的最常见/最有价值的原因。

问题一...
使用 WHOIS,您可以解析与相关 IP 地址关联的网络块(IP 地址范围)的“所有者”。 网络块的“所有者”(通常)是为您希望识别的公司提供服务的 ISP,而不是使用 IP 地址的公司。

第二期...
对于 IP->domain.tld 或 domain.tld->ip 类型解析之外的任何内容,DNS 都不是可靠的来源。 除此之外,它不是强制执行的(不是真正的),也不完全可靠。

第三期...
这对您来说可能不是问题。 根据解析您的 WHOIS 查询的 NIC(ARIN、RIPE 等),您会发现生成的格式并不总是易于解析 - 可读...是的,可解析...否。

As with many programatic concerns, what you are asking is not as simple as you might expect.

Question(s) first... what is the source of the IP address you wish to resolve - a website "visitor", a web server or an unknown source? For the purpose of this response, I'll make the presumption that you are wish to "convert" a website visitor as this is the most common/valuable reason to resolve IP->Company.

Issue One...
Using WHOIS you can resolve the "owner" of the netblock (IP Address range) associated with an IP address in question. The "owner" of the netblock is (usually) the ISP serving the company you're wishing to identify - not the company utilizing the IP address.

Issue Two...
DNS is not a reliable source for anything beyond IP->domain.tld or domain.tld->ip type resolution. Beyond that it's not enforced (not really) and not completely reliable.

Issue Three...
This may not be an issue for you. Depending on the NIC (ARIN, RIPE, et.al.) who resolved your WHOIS query, you'll find that the resultant format is not always easy to parse - readable... yes, parsable... no.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文