php反向解析ip,IP反向解析查询的方法

上午在查看网站的访问日志时,发现很多来自搜索引擎蜘蛛的访问记录,但有些记录显示这些蜘蛛索引了一些与前端不相关的文件,甚至有的文件根本不存在。为了验证这些蜘蛛的真假,就用IP反向解析查询的方法来检查一下它们IP被解析过的域名。

linux系统IP反向解析查询的方法

liunx 系统下可以使用 host 命令来查询IP的反解析域名。

例:host 123.125.66.120

查询结果:120.66.125.123.in-addr.arpa domain name pointer baiduspider-123-125-66-120.crawl.baidu.com.

e5b83d1bc9668d0105a142768260f042.png

ps:由于作者是在 centos 7.4 环境下测试的 host 命令,出现了错误

8d2e2907dafdae6cbad2463c2fde81c1.png-bash: host: command not found

解决此错误的方法:yum install bind-utils

安装 bind-utils 即可

windows 系统IP反向解析查询的方法

在windows系统中,可以使用 nslookup ip 命令反查IP,以来判断是否来自真正的搜索引擎。

命令代码:nslookup 123.125.66.120

查询结果:120.66.125.123.in-addr.arpa domain name pointer baiduspider-123-125-66-120.crawl.baidu.com.

f94f19b5d38e7d5dfab321c8cc39c383.png

mac os 系统IP反向解析查询的方法

网上说在 mac os系统中,可以 dig 命令来反查IP地址的反解析域名,可在作者实际测试中,发现并不行,可能我是用的虚拟机的问题,所以改用了 host 命令

例:host 123.125.66.120

查询结果:

120.66.125.123.in-addr.arpa domain name pointer baiduspider-123-125-66-120.crawl.baidu.com.

94a552c570b1d9cd5a2d7cd58e522e40.png