大型网站一般都会有多台主机,
比如新浪网,通过 NSLOOKUP 就可以看出,它指向了多个IP。
Z:\>nslookup www.sina.com.cn
Server: c.center-dns.jsinfo.net
Address: 61.177.7.1
Name: newsnj.sina.com.cn
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
Aliases: www.sina.com.cn, jupiter.sina.com.cn
使用 curl -I http://www.sina.com.cn/ 可以得到 HTTP 头信息,
但是curl获取的主机是从DNS服务器随机取到的,
怎么样才能查看指定IP上的HTTP信息呢?
使用IP访问,并使用 -H 参数添加 HTTP 头“Host:www.sina.com.cn”,就可以了!
D:\>curl -I http://www.sina.com.cn/
HTTP/1.1 200 OK
Via: 1.0 nanjing75-162.HP08040106.sina.com.cn:80 (squid/2.6.STABLE13), 1.0 TRFW
Connection: Keep-Alive
Proxy-Connection: Keep-Alive
Content-Length: 390160
Expires: Fri, 26 Sep 2008 05:22:11 GMT
Date: Fri, 26 Sep 2008 05:21:11 GMT
Content-Type: text/html
ETag: "5c2d7-457c5a8340d40"
Server: Apache
Last-Modified: Fri, 26 Sep 2008 05:19:09 GMT
Accept-Ranges: bytes
X-Powered-By: mod_xlayout_jh/0.0.1vhs.markIII.remix
Cache-Control: max-age=60
Vary: Accept-Encoding
X-Cache: HIT from nanjing75-162.HP08040106.sina.com.cn
从 DNS 解析到 202.102.75.162 主机
D:\>curl -I -H "Host:www.sina.com.cn" http://202.102.75.169/
HTTP/1.1 200 OK
Via: 1.0 nanjing75-169.HP08040113.sina.com.cn:80 (squid/2.6.STABLE13), 1.0 TRFW
Connection: Keep-Alive
Proxy-Connection: Keep-Alive
Content-Length: 390160
Age: 3
Expires: Fri, 26 Sep 2008 05:21:07 GMT
Date: Fri, 26 Sep 2008 05:20:07 GMT
Content-Type: text/html
ETag: "5c2d7-457c5a8340d40"
Server: Apache
Last-Modified: Fri, 26 Sep 2008 05:19:09 GMT
Accept-Ranges: bytes
X-Powered-By: mod_xlayout_jh/0.0.1vhs.markIII.remix
Cache-Control: max-age=60
Vary: Accept-Encoding
X-Cache: HIT from nanjing75-169.HP08040113.sina.com.cn
指定 202.102.75.169 主机