curl怎样获取指定IP主机的信息

2017年10月30日19:25:12系统教程来源:博客园评论377

使用CDN后,网站域名对应的是N台CDN主题,例如新浪网,通过 NSLOOKUP 就可以看出,它指向了多个IP。文章源自堕落的鱼-https://www.duoluodeyu.com/2482.html

Z:\>nslookup www.sina.com.cn文章源自堕落的鱼-https://www.duoluodeyu.com/2482.html

Server: c.center-dns.jsinfo.net文章源自堕落的鱼-https://www.duoluodeyu.com/2482.html

Address: 61.177.7.1文章源自堕落的鱼-https://www.duoluodeyu.com/2482.html

Name: newsnj.sina.com.cn文章源自堕落的鱼-https://www.duoluodeyu.com/2482.html

Addresses: 202.102.75.169, 202.102.75.170, 202.102.75.161, 202.102.75.162 202.102.75.163, 202.102.75.164, 202.102.75.165, 202.102.75.166, 202.10 2.75.167 202.102.75.168文章源自堕落的鱼-https://www.duoluodeyu.com/2482.html

Aliases: www.sina.com.cn, jupiter.sina.com.cn文章源自堕落的鱼-https://www.duoluodeyu.com/2482.html

使用 curl -I http://www.sina.com.cn/ 可以得到 HTTP 头信息,文章源自堕落的鱼-https://www.duoluodeyu.com/2482.html

但是curl获取的主机是从DNS服务器随机取到的,文章源自堕落的鱼-https://www.duoluodeyu.com/2482.html

怎么样才能查看指定IP上的HTTP信息呢?文章源自堕落的鱼-https://www.duoluodeyu.com/2482.html

使用IP访问,并使用 -H 参数添加 HTTP 头“Host:www.sina.com.cn”,就可以了!文章源自堕落的鱼-https://www.duoluodeyu.com/2482.html

D:\>curl -I http://www.sina.com.cn/文章源自堕落的鱼-https://www.duoluodeyu.com/2482.html

HTTP/1.1 200 OK文章源自堕落的鱼-https://www.duoluodeyu.com/2482.html

Via: 1.0 nanjing75-162.HP08040106.sina.com.cn:80 (squid/2.6.STABLE13), 1.0 TRFW文章源自堕落的鱼-https://www.duoluodeyu.com/2482.html

Connection: Keep-Alive文章源自堕落的鱼-https://www.duoluodeyu.com/2482.html

Proxy-Connection: Keep-Alive文章源自堕落的鱼-https://www.duoluodeyu.com/2482.html

Content-Length: 390160文章源自堕落的鱼-https://www.duoluodeyu.com/2482.html

Expires: Fri, 26 Sep 2008 05:22:11 GMT文章源自堕落的鱼-https://www.duoluodeyu.com/2482.html

Date: Fri, 26 Sep 2008 05:21:11 GMT文章源自堕落的鱼-https://www.duoluodeyu.com/2482.html

Content-Type: text/html文章源自堕落的鱼-https://www.duoluodeyu.com/2482.html

ETag: "5c2d7-457c5a8340d40"文章源自堕落的鱼-https://www.duoluodeyu.com/2482.html

Server: Apache文章源自堕落的鱼-https://www.duoluodeyu.com/2482.html

Last-Modified: Fri, 26 Sep 2008 05:19:09 GMT文章源自堕落的鱼-https://www.duoluodeyu.com/2482.html

Accept-Ranges: bytes文章源自堕落的鱼-https://www.duoluodeyu.com/2482.html

X-Powered-By: mod_xlayout_jh/0.0.1vhs.markIII.remix文章源自堕落的鱼-https://www.duoluodeyu.com/2482.html

Cache-Control: max-age=60文章源自堕落的鱼-https://www.duoluodeyu.com/2482.html

Vary: Accept-Encoding文章源自堕落的鱼-https://www.duoluodeyu.com/2482.html

X-Cache: HIT from nanjing75-162.HP08040106.sina.com.cn文章源自堕落的鱼-https://www.duoluodeyu.com/2482.html

从 DNS 解析到 202.102.75.162 主机文章源自堕落的鱼-https://www.duoluodeyu.com/2482.html

D:\>curl -I -H "Host:www.sina.com.cn" http://202.102.75.169/文章源自堕落的鱼-https://www.duoluodeyu.com/2482.html

HTTP/1.1 200 OK文章源自堕落的鱼-https://www.duoluodeyu.com/2482.html

Via: 1.0 nanjing75-169.HP08040113.sina.com.cn:80 (squid/2.6.STABLE13), 1.0 TRFW文章源自堕落的鱼-https://www.duoluodeyu.com/2482.html

Connection: Keep-Alive文章源自堕落的鱼-https://www.duoluodeyu.com/2482.html

Proxy-Connection: Keep-Alive文章源自堕落的鱼-https://www.duoluodeyu.com/2482.html

Content-Length: 390160文章源自堕落的鱼-https://www.duoluodeyu.com/2482.html

Age: 3文章源自堕落的鱼-https://www.duoluodeyu.com/2482.html

Expires: Fri, 26 Sep 2008 05:21:07 GMT文章源自堕落的鱼-https://www.duoluodeyu.com/2482.html

Date: Fri, 26 Sep 2008 05:20:07 GMT文章源自堕落的鱼-https://www.duoluodeyu.com/2482.html

Content-Type: text/html文章源自堕落的鱼-https://www.duoluodeyu.com/2482.html

ETag: "5c2d7-457c5a8340d40"文章源自堕落的鱼-https://www.duoluodeyu.com/2482.html

Server: Apache文章源自堕落的鱼-https://www.duoluodeyu.com/2482.html

Last-Modified: Fri, 26 Sep 2008 05:19:09 GMT文章源自堕落的鱼-https://www.duoluodeyu.com/2482.html

Accept-Ranges: bytes文章源自堕落的鱼-https://www.duoluodeyu.com/2482.html

X-Powered-By: mod_xlayout_jh/0.0.1vhs.markIII.remix文章源自堕落的鱼-https://www.duoluodeyu.com/2482.html

Cache-Control: max-age=60文章源自堕落的鱼-https://www.duoluodeyu.com/2482.html

Vary: Accept-Encoding文章源自堕落的鱼-https://www.duoluodeyu.com/2482.html

X-Cache: HIT from nanjing75-169.HP08040113.sina.com.cn文章源自堕落的鱼-https://www.duoluodeyu.com/2482.html

CURL通过设定 -H 参数添加 HTTP 头“Host:www.sina.com.cn”,就可以了实现获取指定IP主机的信息。文章源自堕落的鱼-https://www.duoluodeyu.com/2482.html

匿名

发表评论

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定