如何通过PHP获取ISP?

时间:2017-02-07 22:36:33

标签: php ip

如何通过PHP从IP获取ISP?例如,如何获得字符串" Zappie Host LLC"来自IP http://www.ip2location.com/demo/185.121.170.242

2 个答案:

答案 0 :(得分:0)

如果你有适当的权限,你可以使用php的exec()运行traceroute,它将以这种格式为你提供所有'跳':

MY isp在第4跳。

  

CRON01-C11.asr01.mtl1080.fibrenoire.ca(173.231.103.209)

自从我为google public dns 8.8.8.8做了一个traceroute后,最终(第12跳)谷歌和谷歌

  

google-public-dns-a.google.com(8.8.8.8)43.820 ms 31.992 ms 74.833   MS

完整的解释可以在SO上找到: Get list of traceroute hops with php 请参阅有关循环'hops'的注释并将结果存储在php数组中。

这可能会让你看得出你想要的东西,但它可以是你'问题'的简单解决方案

<小时/> 编辑: 使用linux的whois代替并用php中的exec()调用它。它会给你所有你想要的东西:

[llt@lltHomeBox ~]$ whois 185.121.170.242
[Querying whois.ripe.net]
[whois.ripe.net]
% This is the RIPE Database query service.
% The objects are in RPSL format.
%
% The RIPE Database is subject to Terms and Conditions.
% See http://www.ripe.net/db/support/db-terms-conditions.pdf

% Note: this output has been filtered.
%       To receive output for a database update, use the "-B" flag.

% Information related to '185.121.170.0 - 185.121.170.255'

% Abuse contact for '185.121.170.0 - 185.121.170.255' is 'abuse@zappiehost.com'

inetnum:        185.121.170.0 - 185.121.170.255
netname:        GESTION-DBI-NET
descr:          Gestion DBI
country:        NL
admin-c:        GDA107
tech-c:         VA31968-RIPE
status:         SUB-ALLOCATED PA
geoloc:         52.396348 4.851082
mnt-lower:      GestionDBI
mnt-routes:     GestionDBI
mnt-domains:    GestionDBI
mnt-routes:     MNT-NFORCE
remarks:        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
remarks:        Abuse repots to: abuse@vmpanel.net
remarks:        Please report all ABUSE here with the following information:
remarks:        - Source and Destination IP and Ports
remarks:        - Accurate Timestamp
remarks:        - Full logs about the issue
remarks:        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
mnt-by:         ADAMBB-MNT
created:        2015-12-20T04:38:14Z
last-modified:  2015-12-20T04:38:14Z
source:         RIPE

role:           Gestion DBI Administrators
address:        490 Place Donato
address:        St-Lin, QC, CANADA, J5M2K8
nic-hdl:        GDA107
mnt-by:         GestionDBI
created:        2015-12-15T15:41:45Z
last-modified:  2015-12-19T19:41:09Z
source:         RIPE # Filtered
remarks:        !========================================== !
remarks:        Administrative requests only. No ABUSE, TECH inquiries will be answered here.
remarks:        !========================================== !
phone:          +18772044324

role:           VMPanel Tech
address:        490 Place Donato
address:        St-Lin, QC, CANADA, J5M2K8
nic-hdl:        VA31968-RIPE
remarks:        !========================================== !
remarks:        Please report any TECHNICAL issues about Routing, IP, DNS here.
remarks:        For issue with your service, please contact your provider.
remarks:        - We do not answer ABUSE request here.
remarks:        !========================================== !
phone:          +18772044324
mnt-by:         GestionDBI
created:        2015-12-15T15:57:30Z
last-modified:  2015-12-19T19:42:29Z
source:         RIPE # Filtered

% Information related to '185.121.170.0/24AS43350'

route:          185.121.170.0/24
descr:          NFOrce Entertainment BV - 185.121.170.0/24 route
origin:         AS43350
mnt-by:         MNT-NFORCE
created:        2015-12-20T10:55:04Z
last-modified:  2015-12-20T10:55:04Z
source:         RIPE

% This query was served by the RIPE Database Query Service version 1.88 (ANGUS)

答案 1 :(得分:0)

您可以尝试使用gethostbyaddr:

children=[toggle, check]