如何确定IP地址属于哪个公司?

时间:2022-06-29 07:17:45

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

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

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.

但如果没有正确设置反向DNS,这将无效,这似乎在90%的时间内发生。

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.

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

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

使用.net实现同样功能的最简单方法是什么?


Notes :

  • I don't need a canonical name. ie MS or Microsoft are both ok.
  • 我不需要规范名称。即MS或Microsoft都可以。

  • I'm targeting big companies, which are likely to "own" their IP address ranges.
  • 我的目标是那些可能“拥有”其IP地址范围的大公司。

  • I'm running on Windows, so unix's whois tools are not installed by default.
  • 我在Windows上运行,因此默认情况下不安装unix的whois工具。


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

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

5 个解决方案

#1


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

您可以从microsoft安装Windows的whois命令行工具

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]

#2


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

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

#3


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.

大多数情况下,我都在支持“whois”的答案。回到当天公司拥有整个地址块,所以过去人们很容易写出自己的“whois”,但随着IP(v4)地址越来越稀缺,它就不再容易了。我甚至都不想现在尝试一下。使用真正的whois。

#4


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

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

You could try requesting

你可以尝试请求

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

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

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

一个简单的string.IndexOf(“OrgName:”)查找应该让你关闭。

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

示例网址http://ws.arin.net/whois/?queryinput=207.46.193.254

HTH

OneSHOT

#5


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.

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

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.

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

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.

问题二...除了IP-> domain.tld或domain.tld-> ip type resolution之外,DNS不是可靠的来源。除此之外,它没有强制执行(不是真的)并且不完全可靠。

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.

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

#1


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

您可以从microsoft安装Windows的whois命令行工具

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]

#2


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

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

#3


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.

大多数情况下,我都在支持“whois”的答案。回到当天公司拥有整个地址块,所以过去人们很容易写出自己的“whois”,但随着IP(v4)地址越来越稀缺,它就不再容易了。我甚至都不想现在尝试一下。使用真正的whois。

#4


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

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

You could try requesting

你可以尝试请求

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

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

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

一个简单的string.IndexOf(“OrgName:”)查找应该让你关闭。

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

示例网址http://ws.arin.net/whois/?queryinput=207.46.193.254

HTH

OneSHOT

#5


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.

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

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.

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

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.

问题二...除了IP-> domain.tld或domain.tld-> ip type resolution之外,DNS不是可靠的来源。除此之外,它没有强制执行(不是真的)并且不完全可靠。

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.

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