﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-小默-随笔分类-Network</title><link>http://www.cppblog.com/momoxiao/category/12537.html</link><description /><language>zh-cn</language><lastBuildDate>Sat, 24 Sep 2011 15:32:54 GMT</lastBuildDate><pubDate>Sat, 24 Sep 2011 15:32:54 GMT</pubDate><ttl>60</ttl><item><title>zz 反向代理</title><link>http://www.cppblog.com/momoxiao/archive/2011/09/18/156104.html</link><dc:creator>小默</dc:creator><author>小默</author><pubDate>Sun, 18 Sep 2011 04:09:00 GMT</pubDate><guid>http://www.cppblog.com/momoxiao/archive/2011/09/18/156104.html</guid><wfw:comment>http://www.cppblog.com/momoxiao/comments/156104.html</wfw:comment><comments>http://www.cppblog.com/momoxiao/archive/2011/09/18/156104.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/momoxiao/comments/commentRss/156104.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/momoxiao/services/trackbacks/156104.html</trackback:ping><description><![CDATA[<span class="Apple-style-span" style="font-family: sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; "><div><a href="http://en.wikipedia.org/wiki/Reverse_proxy">http://en.wikipedia.org/wiki/Reverse_proxy</a></div>In&nbsp;<a href="http://en.wikipedia.org/wiki/Computer_network" title="Computer network" style="text-decoration: none; color: #0645ad; background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">computer networks</a>, a&nbsp;<strong>reverse proxy</strong>&nbsp;is a type of&nbsp;<a href="http://en.wikipedia.org/wiki/Proxy_server" title="Proxy server" style="text-decoration: none; color: #0645ad; background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">proxy server</a>&nbsp;that retrieves resources on behalf of a<a href="http://en.wikipedia.org/wiki/Client_(computing)" title="Client (computing)" style="text-decoration: none; color: #0645ad; background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">client</a>&nbsp;from one or more&nbsp;<a href="http://en.wikipedia.org/wiki/Server_(computing)" title="Server (computing)" style="text-decoration: none; color: #0645ad; background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">servers</a>. These resources are then returned to the client as though it originated from the reverse proxy itself.<sup id="cite_ref-apache-forward-reverse_0-0" class="reference" style="line-height: 1em; font-style: normal; "><a href="http://en.wikipedia.org/wiki/Reverse_proxy#cite_note-apache-forward-reverse-0" style="text-decoration: none; color: #0645ad; background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; white-space: nowrap; background-position: initial initial; background-repeat: initial initial; "><span>[</span>1<span>]</span></a></sup>&nbsp;While a&nbsp;<a href="http://en.wikipedia.org/wiki/Proxy_server#Forward_proxies" title="Proxy server" style="text-decoration: none; color: #0645ad; background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">forward proxy</a>&nbsp;is usually situated between the client application (such as a&nbsp;<a href="http://en.wikipedia.org/wiki/Web_browser" title="Web browser" style="text-decoration: none; color: #0645ad; background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">web browser</a>) and the server(s) hosting the desired resources, a reverse proxy is usually situated </span><span class="Apple-style-span" style="font-family: sans-serif; font-size: 13px; line-height: 19px; background-color: yellow; "><strong><em>closer to the server(s)</em></strong></span><span class="Apple-style-span" style="font-family: sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; "> and will only return </span><span class="Apple-style-span" style="font-family: sans-serif; font-size: 13px; line-height: 19px; background-color: yellow; "><strong><em>a configured set</em></strong></span><span class="Apple-style-span" style="font-family: sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; "> of resources.<br /><br /></span>---<br /><div><a href="http://www.hackbase.com/tech/2011-02-24/62751.html">http://www.hackbase.com/tech/2011-02-24/62751.html</a></div><br /><span class="Apple-style-span" style="color: #444444; font-family: Arial, Helvetica, 宋体; line-height: 24px; background-color: #f5faff; ">　　通常的代理服务器，只用于<em><strong>代理内部网络对 Internet 的连接请求</strong></em>，客户机必须指定代理服务器，并将本来要直接发送到 Web 服务器上的 http 请求发送到代理服务器中。由于外部网络上的主机并不会配置并使用这个代理服务器，普通代理服务器也被设计为在 Internet 上搜寻多个不确定的服务器，而不是针对 Internet 上多个客户机的请求访问某一个固定的服务器，因此普通的 Web 代理服务器不支持外部对内部网络的访问请求。当一个代理服务器能够<strong><em>代理外部网络上的主机，访问内部网络</em></strong>时，这种代理服务的方式称为反向代理服务（也称为逆向代理）。<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 12px; font-family: Arial, Helvetica, 宋体; " />　　通过反向代理服务器，可以记录用户所有的访问行为，但这也会带来系统资源相当大的额外开销。但对于不同的服务器来说，其保护的资源类型是有限的，我们只需要记录、控制用户对我们所关心的资源的访问即可。比如对一个 mp3 服务提供商来说，只需要控制用户对 .mp3 文件的请求次数即可。<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 12px; font-family: Arial, Helvetica, 宋体; " />　　从用户访问的角度来分，非法访问主要有以下两个方面：瞬间恶意多次请求和长时间持续攻击。针对这两种情况我们制定了以下控制策略：<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 12px; font-family: Arial, Helvetica, 宋体; " />　　1) 对抗瞬间恶意攻击<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 12px; font-family: Arial, Helvetica, 宋体; " />　　这种情况是恶意的网上用户使用多线程访问同一资源，或者是在短时间内访问多个资源。对于第一种情况，可以定义一个参数 m ，即同一用户同时访问的线程数量，若超过这个数量，则将他的请求暂缓发出或者废除他的请求。为了对付第二种情况，访问控制系统应定义两个参数，一个是时间 t ，以秒为单位。第二个是资源个数 g 。用这两个参数确定一个规则 r ，即 r=F(g, t) 。 r 的含义就是最多允许网上用户在 t 秒内访问 g 个资源。同时，规则 r 可以有多条，这样为精确控制带来方便。<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 12px; font-family: Arial, Helvetica, 宋体; " />　　2) 对抗长时间持续攻击<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 12px; font-family: Arial, Helvetica, 宋体; " />　　用上面提到的规则 r=F(g, t) 也可以对抗长时间持续下载。这里再定义一种规则 k=F(t1,t2) 。 t1 、 t2 都是时间长度，以秒为单位。 t1 是最长持续时间。 t2 是判断用户是否连续访问的间隔时间。例如可以规定网上用户连续访问一类资源 3 小时（参数 t1 ），若有 8 小时（参数 t2 ）未访问此类资源，则可认为用户是重新开始访问。<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 12px; font-family: Arial, Helvetica, 宋体; " />　　将 t1 、 t2 定义的比较长并不能防止恶意用户定时攻击。比如他为了不违反上面的规则，就每隔 8 小时下载 3 个小时。对付这种情况，可以定义多条 k 规则，例如用户每访问 3 分钟就必须休息 1 分钟；每访问 10 分钟必须休息 3 分钟等。<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 12px; font-family: Arial, Helvetica, 宋体; " />　　反向代理是访问控制系统最核心的部分，其核心技术就是地址转换。通过它可以保证使用者对客户端计算机不进行任何设置的情况下就使用访问控制系统。从外观看来，也就是从普通用户看来，反向代理就像普通的 Web 服务器一样。而反向代理所代理的每一个 Web 服务器都好像是反向代理服务器中的一个目录。例如反向代理服务器本身的 URL 是&nbsp;<a href="http://reverse-proxy/" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 12px; font-family: Arial, Helvetica, 宋体; color: #444444; text-decoration: none; ">http://reverse-proxy</a>&nbsp;，它可以代理清华主页服务器（<a href="http://www.tsinghua.edu.cn/index.html" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 12px; font-family: Arial, Helvetica, 宋体; color: #444444; text-decoration: none; ">http://www.tsinghua.edu.cn/index.html</a>&nbsp;），普通的用户想通过反向代理服务器来访问清华主页服务器就只需要访问&nbsp;<a href="http://reverse-proxy/www.tsinghua.edu.cn/index.html" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 12px; font-family: Arial, Helvetica, 宋体; color: #444444; text-decoration: none; ">http://reverse-proxy/www.tsinghua.edu.cn/index.html</a>&nbsp;就行了。<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 12px; font-family: Arial, Helvetica, 宋体; " />　　反向代理的实现<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 12px; font-family: Arial, Helvetica, 宋体; " />　　在反向代理中，等于把反向代理服务器中的目录映射到其它需要被代理的服务器上。这样做只能解决用户的一次访问问题，不能做到让用户通过反向代理连续访问。因为被代理的服务器上的信息是未知的，对于 HTTP 协议来讲，很有可能出现绝对地址或者绝对链接，这样的话，普通用户的下一次访问将会跳过反向代理而直接访问真实的服务器。这是我们不希望看到的。因此，必须对服务器返回给用户的信息进行过滤，将所有的绝对 URL 更改成为通过反向代理的相对 URL 。为此，我们使用了正则表达式对所有的链接进行检测、替换。于是就实现了通过反向代理连续访问的功能。<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 12px; font-family: Arial, Helvetica, 宋体; " />　　当用户的请求到达反向代理服务器之后，反向代理通过一定的规则将 URL 中的目录信息解析成服务器以及端口的信息，从而进行 socket 链接，即反向代理服务器模拟一个客户端向真正的 Web 服务器发出 http 请求。当得到回应信息的时候，通过 HTTP 头中的 Content-Type 和文件的扩展名来判断得到的信息的类别。若是非 HTML 信息（如 jpg, gif, zip 等），则将其原样照发还给用户，若是 HTML(html, htm, shtml 等），则用先用正则表达式建立字符串识别自动机，查找 html 文本中所有的链接信息。例如， &lt;a href="......"&gt; 、 &lt;img src="......"&gt; 等。然后判定链接的类型，对于在代理范围之内（代理范围之外不予理会）的绝对 URL （以&#8220; http:// &#8221;打头），则把它改写成通过反向代理的格式。例如<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 12px; font-family: Arial, Helvetica, 宋体; " />　　&lt;a href="<a href="http://www.test.org/" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 12px; font-family: Arial, Helvetica, 宋体; color: #444444; text-decoration: none; ">http://www.test.org</a>"&gt;<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 12px; font-family: Arial, Helvetica, 宋体; " />　　就会被改成<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 12px; font-family: Arial, Helvetica, 宋体; " />　　&lt;a href="<a href="http://reverse-proxy/www.test.org" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 12px; font-family: Arial, Helvetica, 宋体; color: #444444; text-decoration: none; ">http://reverse-proxy/www.test.org</a>"&gt;<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 12px; font-family: Arial, Helvetica, 宋体; " />　　对于绝对 URI （以&#8220; / &#8221;打头的），也需要更改，例如<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 12px; font-family: Arial, Helvetica, 宋体; " />　　&lt;img src="/img/1.jpg"&gt;<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 12px; font-family: Arial, Helvetica, 宋体; " />　　就要被改成<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 12px; font-family: Arial, Helvetica, 宋体; " />　　&lt;img src="/www.test.org/img/1.jpg"&gt; 。<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 12px; font-family: Arial, Helvetica, 宋体; " />　　对于相对链接，则不需要改动。除了对 HTML 本身进行更改之外，对 HTTP 的头信息也要解析。其中最关键的就是对 Cookie 路径的改写。例如收到&nbsp;<a href="http://www.test.org/" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 12px; font-family: Arial, Helvetica, 宋体; color: #444444; text-decoration: none; ">www.test.org</a>&nbsp;的 cookie 为<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 12px; font-family: Arial, Helvetica, 宋体; " />　　Set-Cookie: PART_NUMBER=ROCKET_LAUNCHER_0001; path=/<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 12px; font-family: Arial, Helvetica, 宋体; " />　　就要改写成<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 12px; font-family: Arial, Helvetica, 宋体; " />　　Set-Cookie: PART_NUMBER=ROCKET_LAUNCHER_0001; path=/www.test.org/<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 12px; font-family: Arial, Helvetica, 宋体; " />　　此外，不仅是收到服务器的信息需要改写，用户发给服务器的请求信息也要改写，其情形与上面所说的类似，这里不再举例。</span><img src ="http://www.cppblog.com/momoxiao/aggbug/156104.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/momoxiao/" target="_blank">小默</a> 2011-09-18 12:09 <a href="http://www.cppblog.com/momoxiao/archive/2011/09/18/156104.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>httpget</title><link>http://www.cppblog.com/momoxiao/archive/2011/03/26/142763.html</link><dc:creator>小默</dc:creator><author>小默</author><pubDate>Sat, 26 Mar 2011 10:26:00 GMT</pubDate><guid>http://www.cppblog.com/momoxiao/archive/2011/03/26/142763.html</guid><wfw:comment>http://www.cppblog.com/momoxiao/comments/142763.html</wfw:comment><comments>http://www.cppblog.com/momoxiao/archive/2011/03/26/142763.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/momoxiao/comments/commentRss/142763.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/momoxiao/services/trackbacks/142763.html</trackback:ping><description><![CDATA[<div style="background-color: rgb(238, 238, 238); font-size: 13px; border-left-color: rgb(204, 204, 204); padding-right: 5px; padding-bottom: 4px; padding-left: 4px; padding-top: 4px; width: 98%; word-break: break-all; "><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000; "><br>#include&nbsp;</span><span style="color: #000000; ">&lt;</span><span style="color: #000000; ">stdio.h</span><span style="color: #000000; ">&gt;</span><span style="color: #000000; "><br>#include&nbsp;</span><span style="color: #000000; ">&lt;</span><span style="color: #0000FF; ">string</span><span style="color: #000000; ">.h</span><span style="color: #000000; ">&gt;</span><span style="color: #000000; "><br>#include&nbsp;</span><span style="color: #000000; ">&lt;</span><span style="color: #000000; ">sys</span><span style="color: #000000; ">/</span><span style="color: #000000; ">socket.h</span><span style="color: #000000; ">&gt;</span><span style="color: #000000; "><br>#include&nbsp;</span><span style="color: #000000; ">&lt;</span><span style="color: #000000; ">netinet</span><span style="color: #000000; ">/</span><span style="color: #0000FF; ">in</span><span style="color: #000000; ">.h</span><span style="color: #000000; ">&gt;</span><span style="color: #000000; "><br>#include&nbsp;</span><span style="color: #000000; ">&lt;</span><span style="color: #000000; ">netdb.h</span><span style="color: #000000; ">&gt;</span><span style="color: #000000; "><br><br></span><span style="color: #0000FF; ">int</span><span style="color: #000000; ">&nbsp;main(</span><span style="color: #0000FF; ">int</span><span style="color: #000000; ">&nbsp;argc,&nbsp;</span><span style="color: #0000FF; ">char</span><span style="color: #000000; ">&nbsp;</span><span style="color: #000000; ">**</span><span style="color: #000000; ">argv)<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">int</span><span style="color: #000000; ">&nbsp;sockfd;<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">int</span><span style="color: #000000; ">&nbsp;result;<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">char</span><span style="color: #000000; ">&nbsp;httpstring[</span><span style="color: #000000; ">100</span><span style="color: #000000; ">];<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">struct</span><span style="color: #000000; ">&nbsp;sockaddr_in&nbsp;servaddr;<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">char</span><span style="color: #000000; ">&nbsp;ch;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">struct</span><span style="color: #000000; ">&nbsp;hostent&nbsp;</span><span style="color: #000000; ">*</span><span style="color: #000000; ">hptr;<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">char</span><span style="color: #000000; ">&nbsp;hostip[</span><span style="color: #000000; ">16</span><span style="color: #000000; ">];<br><br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">if</span><span style="color: #000000; ">(argc&nbsp;</span><span style="color: #000000; ">!=</span><span style="color: #000000; ">&nbsp;</span><span style="color: #000000; ">2</span><span style="color: #000000; ">){<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">error&nbsp;usage:&nbsp;%s&nbsp;ip\n</span><span style="color: #000000; ">"</span><span style="color: #000000; ">,&nbsp;argv[</span><span style="color: #000000; ">0</span><span style="color: #000000; ">]);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">return</span><span style="color: #000000; ">&nbsp;</span><span style="color: #000000; ">1</span><span style="color: #000000; ">;<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br><br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">if</span><span style="color: #000000; ">((hptr&nbsp;</span><span style="color: #000000; ">=</span><span style="color: #000000; ">&nbsp;gethostbyname(argv[</span><span style="color: #000000; ">1</span><span style="color: #000000; ">]))&nbsp;</span><span style="color: #000000; ">==</span><span style="color: #000000; ">&nbsp;NULL){<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;herror(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">gethostbyname&nbsp;error</span><span style="color: #000000; ">"</span><span style="color: #000000; ">);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">return</span><span style="color: #000000; ">&nbsp;</span><span style="color: #000000; ">1</span><span style="color: #000000; ">;<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br><br>&nbsp;&nbsp;&nbsp;&nbsp;inet_ntop(hptr</span><span style="color: #000000; ">-&gt;</span><span style="color: #000000; ">h_addrtype,&nbsp;</span><span style="color: #000000; ">*</span><span style="color: #000000; ">hptr</span><span style="color: #000000; ">-&gt;</span><span style="color: #000000; ">h_addr_list,&nbsp;hostip,&nbsp;</span><span style="color: #0000FF; ">sizeof</span><span style="color: #000000; ">(hostip));<br><br>&nbsp;&nbsp;&nbsp;&nbsp;sprintf(httpstring,&nbsp;</span><span style="color: #000000; ">"</span><span style="color: #000000; ">GET&nbsp;/&nbsp;HTTP/1.1\r\n</span><span style="color: #000000; ">"</span><span style="color: #000000; "><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #000000; ">"</span><span style="color: #000000; ">Host:&nbsp;%s\r\n</span><span style="color: #000000; ">"</span><span style="color: #000000; "><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #000000; ">"</span><span style="color: #000000; ">Connection:&nbsp;close\r\n\r\n</span><span style="color: #000000; ">"</span><span style="color: #000000; ">,&nbsp;argv[</span><span style="color: #000000; ">1</span><span style="color: #000000; ">]);<br><br>&nbsp;&nbsp;&nbsp;&nbsp;sockfd&nbsp;</span><span style="color: #000000; ">=</span><span style="color: #000000; ">&nbsp;socket(AF_INET,&nbsp;SOCK_STREAM,&nbsp;</span><span style="color: #000000; ">0</span><span style="color: #000000; ">);<br><br>&nbsp;&nbsp;&nbsp;&nbsp;servaddr.sin_family&nbsp;</span><span style="color: #000000; ">=</span><span style="color: #000000; ">&nbsp;AF_INET;<br>&nbsp;&nbsp;&nbsp;&nbsp;servaddr.sin_addr.s_addr&nbsp;</span><span style="color: #000000; ">=</span><span style="color: #000000; ">&nbsp;inet_addr(hostip);<br>&nbsp;&nbsp;&nbsp;&nbsp;servaddr.sin_port&nbsp;</span><span style="color: #000000; ">=</span><span style="color: #000000; ">&nbsp;htons(</span><span style="color: #000000; ">80</span><span style="color: #000000; ">);<br><br>&nbsp;&nbsp;&nbsp;&nbsp;result&nbsp;</span><span style="color: #000000; ">=</span><span style="color: #000000; ">&nbsp;connect(sockfd,&nbsp;(</span><span style="color: #0000FF; ">struct</span><span style="color: #000000; ">&nbsp;sockaddr&nbsp;</span><span style="color: #000000; ">*</span><span style="color: #000000; ">)</span><span style="color: #000000; ">&amp;</span><span style="color: #000000; ">servaddr,&nbsp;</span><span style="color: #0000FF; ">sizeof</span><span style="color: #000000; ">(servaddr));<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">if</span><span style="color: #000000; ">(result&nbsp;</span><span style="color: #000000; ">==</span><span style="color: #000000; ">&nbsp;</span><span style="color: #000000; ">-</span><span style="color: #000000; ">1</span><span style="color: #000000; ">){<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;perror(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">connect&nbsp;error</span><span style="color: #000000; ">"</span><span style="color: #000000; ">);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">return</span><span style="color: #000000; ">&nbsp;</span><span style="color: #000000; ">1</span><span style="color: #000000; ">;<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br><br>&nbsp;&nbsp;&nbsp;&nbsp;write(sockfd,&nbsp;httpstring,&nbsp;strlen(httpstring));<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">while</span><span style="color: #000000; ">(read(sockfd,&nbsp;</span><span style="color: #000000; ">&amp;</span><span style="color: #000000; ">ch,&nbsp;</span><span style="color: #000000; ">1</span><span style="color: #000000; ">)){<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">%c</span><span style="color: #000000; ">"</span><span style="color: #000000; ">,&nbsp;ch);<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br><br>&nbsp;&nbsp;&nbsp;&nbsp;close(sockfd);</span><span style="color: #000000; "><br><br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">return</span><span style="color: #000000; ">&nbsp;</span><span style="color: #000000; ">0</span><span style="color: #000000; ">;<br>}</span></div><img src ="http://www.cppblog.com/momoxiao/aggbug/142763.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/momoxiao/" target="_blank">小默</a> 2011-03-26 18:26 <a href="http://www.cppblog.com/momoxiao/archive/2011/03/26/142763.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>CCNA</title><link>http://www.cppblog.com/momoxiao/archive/2010/12/07/135655.html</link><dc:creator>小默</dc:creator><author>小默</author><pubDate>Tue, 07 Dec 2010 01:47:00 GMT</pubDate><guid>http://www.cppblog.com/momoxiao/archive/2010/12/07/135655.html</guid><wfw:comment>http://www.cppblog.com/momoxiao/comments/135655.html</wfw:comment><comments>http://www.cppblog.com/momoxiao/archive/2010/12/07/135655.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.cppblog.com/momoxiao/comments/commentRss/135655.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/momoxiao/services/trackbacks/135655.html</trackback:ping><description><![CDATA[
<img src ="http://www.cppblog.com/momoxiao/aggbug/135655.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/momoxiao/" target="_blank">小默</a> 2010-12-07 09:47 <a href="http://www.cppblog.com/momoxiao/archive/2010/12/07/135655.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>DNS解析的疑问</title><link>http://www.cppblog.com/momoxiao/archive/2010/11/23/134346.html</link><dc:creator>小默</dc:creator><author>小默</author><pubDate>Mon, 22 Nov 2010 23:02:00 GMT</pubDate><guid>http://www.cppblog.com/momoxiao/archive/2010/11/23/134346.html</guid><wfw:comment>http://www.cppblog.com/momoxiao/comments/134346.html</wfw:comment><comments>http://www.cppblog.com/momoxiao/archive/2010/11/23/134346.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/momoxiao/comments/commentRss/134346.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/momoxiao/services/trackbacks/134346.html</trackback:ping><description><![CDATA[<img border="0" align="absmiddle" src="http://www.cppblog.com/images/cppblog_com/momoxiao/dns.png"><div>一晚上也没有搞明白为啥/(ㄒoㄒ)/~~</div><img src ="http://www.cppblog.com/momoxiao/aggbug/134346.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/momoxiao/" target="_blank">小默</a> 2010-11-23 07:02 <a href="http://www.cppblog.com/momoxiao/archive/2010/11/23/134346.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>【转】DiG HOWTO</title><link>http://www.cppblog.com/momoxiao/archive/2010/11/23/134343.html</link><dc:creator>小默</dc:creator><author>小默</author><pubDate>Mon, 22 Nov 2010 20:48:00 GMT</pubDate><guid>http://www.cppblog.com/momoxiao/archive/2010/11/23/134343.html</guid><wfw:comment>http://www.cppblog.com/momoxiao/comments/134343.html</wfw:comment><comments>http://www.cppblog.com/momoxiao/archive/2010/11/23/134343.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/momoxiao/comments/commentRss/134343.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/momoxiao/services/trackbacks/134343.html</trackback:ping><description><![CDATA[<div class="titlepage" style="font-size: 10pt; font-family: optima, utopia, georgia, 'dejavu serif', 'bitstream charter', serif; "><div><div><h2 class="title" style="color: rgb(178, 34, 34); font-family: verdana, arial, helvetica, 'dejavu sans', sans-serif; font-size: 14pt; ">DiG HOWTO</h2></div><div><div class="author" style="margin-top: 0px; margin-bottom: 0px; "><p class="author" style="margin-top: 0px; margin-bottom: 0px; "><span class="authorname" style="font-weight: bold; "><span class="firstname">Paul</span>&nbsp;<span class="surname">Heinlein</span></span>&nbsp;<em class="email">&lt;<a href="mailto:heinlein@madboa.com" style="text-decoration: none; color: rgb(0, 0, 128); ">heinlein@madboa.com</a>&gt;</em></p></div></div><div><div class="revhistory"><div class="revision" style="margin-top: 0px; margin-bottom: 0px; ">Initial publication: August 31, 2004</div><div class="revision" style="margin-top: 0px; margin-bottom: 0px; ">Most recent revision: May 11, 2006</div></div></div><div><div class="abstract"><p>How to use&nbsp;<span class="command"><strong>dig</strong></span>&nbsp;to query DNS name servers.</p></div></div></div><hr class="pageinfo" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; color: black; background-color: black; height: 1px; "></div><div class="toc" style="font-size: 10pt; font-family: optima, utopia, georgia, 'dejavu serif', 'bitstream charter', serif; "><p><strong>Table of Contents</strong></p><dl><dt><span class="sect1"><a href="http://www.madboa.com/geek/dig/#introduction" style="text-decoration: none; color: rgb(0, 0, 128); ">Introduction</a></span></dt><dt><span class="sect1"><a href="http://www.madboa.com/geek/dig/#defaultoutput" style="text-decoration: none; color: rgb(0, 0, 128); ">Understanding the default output</a></span></dt><dt><span class="sect1"><a href="http://www.madboa.com/geek/dig/#what" style="text-decoration: none; color: rgb(0, 0, 128); ">What can I discover?</a></span></dt><dt><span class="sect1"><a href="http://www.madboa.com/geek/dig/#how" style="text-decoration: none; color: rgb(0, 0, 128); ">How do I &#8230;</a></span></dt><dd><dl><dt><span class="sect2"><a href="http://www.madboa.com/geek/dig/#how-short" style="text-decoration: none; color: rgb(0, 0, 128); ">Get a short answer?</a></span></dt><dt><span class="sect2"><a href="http://www.madboa.com/geek/dig/#how-notsoshort" style="text-decoration: none; color: rgb(0, 0, 128); ">Get a not-quite-so-short answer?</a></span></dt><dt><span class="sect2"><a href="http://www.madboa.com/geek/dig/#how-long" style="text-decoration: none; color: rgb(0, 0, 128); ">Get a long answer?</a></span></dt><dt><span class="sect2"><a href="http://www.madboa.com/geek/dig/#how-reverse" style="text-decoration: none; color: rgb(0, 0, 128); ">Do a reverse lookup?</a></span></dt><dt><span class="sect2"><a href="http://www.madboa.com/geek/dig/#how-otherserver" style="text-decoration: none; color: rgb(0, 0, 128); ">Query a different nameserver?</a></span></dt><dt><span class="sect2"><a href="http://www.madboa.com/geek/dig/#how-searchlist" style="text-decoration: none; color: rgb(0, 0, 128); ">Use the&nbsp;<code class="option" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">search</code>&nbsp;list in&nbsp;<code class="filename" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">/etc/resolv.conf</code>?</a></span></dt><dt><span class="sect2"><a href="http://www.madboa.com/geek/dig/#how-bulk" style="text-decoration: none; color: rgb(0, 0, 128); ">Do bulk lookups?</a></span></dt></dl></dd><dt><span class="sect1"><a href="http://www.madboa.com/geek/dig/#verify" style="text-decoration: none; color: rgb(0, 0, 128); ">Verifying DNS mappings</a></span></dt><dt><span class="sect1"><a href="http://www.madboa.com/geek/dig/#fun" style="text-decoration: none; color: rgb(0, 0, 128); ">dig fun</a></span></dt><dd><dl><dt><span class="sect2"><a href="http://www.madboa.com/geek/dig/#fun-root" style="text-decoration: none; color: rgb(0, 0, 128); ">Roll your own&nbsp;<code class="filename" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">named.root</code>&nbsp;file</a></span></dt><dt><span class="sect2"><a href="http://www.madboa.com/geek/dig/#fun-trace" style="text-decoration: none; color: rgb(0, 0, 128); ">Tracing dig&#8217;s path</a></span></dt><dt><span class="sect2"><a href="http://www.madboa.com/geek/dig/#fun-soa" style="text-decoration: none; color: rgb(0, 0, 128); ">Grabbing SOA information</a></span></dt></dl></dd><dt><span class="sect1"><a href="http://www.madboa.com/geek/dig/#ttl" style="text-decoration: none; color: rgb(0, 0, 128); ">Interpreting TTL numbers</a></span></dt></dl></div><div class="sect1" xml:lang="en" style="font-family: optima, utopia, georgia, 'dejavu serif', 'bitstream charter', serif; font-size: 15px; "><div class="titlepage" style="font-size: 10pt; "><div><div><h2 class="title" style="color: rgb(178, 34, 34); font-family: verdana, arial, helvetica, 'dejavu sans', sans-serif; font-size: 14pt; "><a id="introduction" style="text-decoration: none; "></a>Introduction</h2></div></div></div><p><span class="command"><strong>dig</strong></span>&nbsp;is a command-line tool for querying DNS name servers for information about host addresses, mail exchanges, name servers, and related information. The&nbsp;<em class="citetitle">dig(1)</em>&nbsp;man page is somewhat lacking when it comes to examples, a shortcoming this article tries to remedy.</p><p>The source code for&nbsp;<span class="command"><strong>dig</strong></span>&nbsp;is part of the larger&nbsp;<a class="ulink" href="http://www.isc.org/sw/bind/" style="text-decoration: none; color: rgb(0, 0, 128); ">ISC BIND</a>&nbsp;distribution. Compiling and installing BIND are topics outside the scope of this document, but on Linux systems&nbsp;<span class="command"><strong>dig</strong></span>is usually part of a common package: bind-tools (Gentoo), bind-utils (Red Hat, Fedora), or dnsutils (Debian).</p><p>If you&#8217;re looking for information on configuring the BIND name server, you might find my article&nbsp;<em class="citetitle"><a class="ulink" href="http://www.madboa.com/geek/soho-bind/" style="text-decoration: none; color: rgb(0, 0, 128); ">BIND for the Small LAN</a></em>&nbsp;more to your taste.</p></div><div class="sect1" xml:lang="en" style="font-family: optima, utopia, georgia, 'dejavu serif', 'bitstream charter', serif; font-size: 15px; "><div class="titlepage" style="font-size: 10pt; "><div><div><h2 class="title" style="color: rgb(178, 34, 34); font-family: verdana, arial, helvetica, 'dejavu sans', sans-serif; font-size: 14pt; "><a id="defaultoutput" style="text-decoration: none; "></a>Understanding the default output</h2></div></div></div><p>The most typical, simplest query is for a single host. By default, however,&nbsp;<span class="command"><strong>dig</strong></span>&nbsp;is pretty verbose. You probably don&#8217;t need all the information in the default output, but it&#8217;s probably worth knowing what it is. Below is an annotated query.</p><pre class="screen" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">$ <strong class="userinput"><code style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">dig www.isc.org</code></strong>
</pre><p>That&#8217;s the command-line invocation of dig I used.</p><pre class="screen" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">; &lt;&lt;&gt;&gt; DiG 9.2.3 &lt;&lt;&gt;&gt; www.isc.org
;; global options:  printcmd
</pre><p>The opening section of dig&#8217;s output tells us a little about itself (version 9.2.3) and the global options that are set (in this case,&nbsp;<code class="option" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">printcmd</code>). This part of the output can be quelled by using the&nbsp;<code class="option" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">+nocmd</code>&nbsp;option, but only if it&#8217;s the very first argument on the command line (even preceeding the host you&#8217;re querying).</p><pre class="screen" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">;; Got answer:
;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 43071
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 3, ADDITIONAL: 3
</pre><p>Here, dig tells us some technical details about the answer received from the DNS server. This section of the output can be toggled using the&nbsp;<code class="option" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">+[no]comments</code>&nbsp;option—but beware that disabling the comments also turns off many section headers.</p><pre class="screen" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">;; QUESTION SECTION:
;www.isc.org.                   IN      A
</pre><p>In the question section, dig reminds us of our query. The default query is for an Internet address (<code class="computeroutput" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">A</code>). You can turn this output on or off using the&nbsp;<code class="option" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">+[no]question</code>&nbsp;option.</p><pre class="screen" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">;; ANSWER SECTION:
www.isc.org.            600     IN      A       204.152.184.88
</pre><p>Finally, we get our answer: the address of&nbsp;<code class="systemitem" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">www.isc.org</code>&nbsp;is&nbsp;<code class="systemitem" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">204.152.184.88</code>. I don&#8217;t know why you&#8217;d ever want to turn off the answer, but you can toggle this section of the output using the&nbsp;<code class="option" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">+[no]answer</code>&nbsp;option.</p><pre class="screen" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">;; AUTHORITY SECTION:
isc.org.                2351    IN      NS      ns-int.isc.org.
isc.org.                2351    IN      NS      ns1.gnac.com.
isc.org.                2351    IN      NS      ns-ext.isc.org.
</pre><p>The authority section tells us what DNS servers can provide an authoritative answer to our query. In this example,&nbsp;<code class="systemitem" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">isc.org</code>&nbsp;has three name servers. You can toggle this section of the output using the&nbsp;<code class="option" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">+[no]authority</code>&nbsp;option.</p><pre class="screen" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">;; ADDITIONAL SECTION:
ns1.gnac.com.           171551  IN      A       209.182.216.75
ns-int.isc.org.         2351    IN      A       204.152.184.65
ns-int.isc.org.         2351    IN      AAAA    2001:4f8:0:2::15
</pre><p>The additional section typically includes the IP addresses of the DNS servers listed in the authority section. This section of the output can be toggled with the&nbsp;<code class="option" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">+[no]additional</code>option.</p><pre class="screen" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">;; Query time: 2046 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Fri Aug 27 08:22:26 2004
;; MSG SIZE  rcvd: 173
</pre><p>The final section of the default output contains statistics about the query; it can be toggled with the&nbsp;<code class="option" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">+[no]stats</code>&nbsp;option.</p></div><div class="sect1" xml:lang="en" style="font-family: optima, utopia, georgia, 'dejavu serif', 'bitstream charter', serif; font-size: 15px; "><div class="titlepage" style="font-size: 10pt; "><div><div><h2 class="title" style="color: rgb(178, 34, 34); font-family: verdana, arial, helvetica, 'dejavu sans', sans-serif; font-size: 14pt; "><a id="what" style="text-decoration: none; "></a>What can I discover?</h2></div></div></div><p><span class="command"><strong>dig</strong></span>&nbsp;will let you perform any valid DNS query, the most common of which are&nbsp;<code class="option" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">A</code>&nbsp;(the IP address),&nbsp;<code class="option" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">TXT</code>&nbsp;(text annotations),&nbsp;<code class="option" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">MX</code>&nbsp;(mail exchanges),&nbsp;<code class="option" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">NS</code>&nbsp;name servers, or the omnibus<code class="option" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">ANY</code>.</p><pre class="programlisting" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; border-top-width: 1px; border-top-style: solid; border-top-color: rgb(102, 102, 102); border-right-width: 2px; border-right-style: solid; border-right-color: rgb(102, 102, 102); border-bottom-width: 2px; border-bottom-style: solid; border-bottom-color: rgb(102, 102, 102); border-left-width: 1px; border-left-style: solid; border-left-color: rgb(102, 102, 102); background-color: rgb(253, 223, 223); padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; "># get the address(es) for yahoo.com
dig yahoo.com A +noall +answer

# get a list of yahoo's mail servers
dig yahoo.com MX +noall +answer

# get a list of DNS servers authoritative for yahoo.com
dig yahoo.com NS +noall +answer

# get all of the above
dig yahoo.com ANY +noall +answer
</pre><p>More obscurely, for the present anyway, you can also poll for a host&#8217;s IPv6 address using the&nbsp;<code class="option" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">AAAA</code>&nbsp;option.</p><pre class="programlisting" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; border-top-width: 1px; border-top-style: solid; border-top-color: rgb(102, 102, 102); border-right-width: 2px; border-right-style: solid; border-right-color: rgb(102, 102, 102); border-bottom-width: 2px; border-bottom-style: solid; border-bottom-color: rgb(102, 102, 102); border-left-width: 1px; border-left-style: solid; border-left-color: rgb(102, 102, 102); background-color: rgb(253, 223, 223); padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; ">dig www.isc.org AAAA +short
</pre><p>If the domain you want to query allows DNS transfers, you can get those, too. The reality of life on the Internet, however, is that very few domains allow unrestricted transfers these days.</p><pre class="programlisting" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; border-top-width: 1px; border-top-style: solid; border-top-color: rgb(102, 102, 102); border-right-width: 2px; border-right-style: solid; border-right-color: rgb(102, 102, 102); border-bottom-width: 2px; border-bottom-style: solid; border-bottom-color: rgb(102, 102, 102); border-left-width: 1px; border-left-style: solid; border-left-color: rgb(102, 102, 102); background-color: rgb(253, 223, 223); padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; ">dig yourdomain.com AXFR
</pre></div><div class="sect1" xml:lang="en" style="font-family: optima, utopia, georgia, 'dejavu serif', 'bitstream charter', serif; font-size: 15px; "><div class="titlepage" style="font-size: 10pt; "><div><div><h2 class="title" style="color: rgb(178, 34, 34); font-family: verdana, arial, helvetica, 'dejavu sans', sans-serif; font-size: 14pt; "><a id="how" style="text-decoration: none; "></a>How do I &#8230;</h2></div></div></div><div class="sect2" xml:lang="en"><div class="titlepage" style="font-size: 10pt; "><div><div><h3 class="title" style="color: rgb(178, 34, 34); font-family: verdana, arial, helvetica, 'dejavu sans', sans-serif; font-size: 12pt; "><a id="how-short" style="text-decoration: none; "></a>Get a short answer?</h3></div></div></div><p>When all you want is a quick answer, the&nbsp;<code class="option" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">+short</code>&nbsp;option is your friend:</p><pre class="screen" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">$ <strong class="userinput"><code style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">dig www.isc.org +short</code></strong>
204.152.184.88
</pre></div><div class="sect2" xml:lang="en"><div class="titlepage" style="font-size: 10pt; "><div><div><h3 class="title" style="color: rgb(178, 34, 34); font-family: verdana, arial, helvetica, 'dejavu sans', sans-serif; font-size: 12pt; "><a id="how-notsoshort" style="text-decoration: none; "></a>Get a not-quite-so-short answer?</h3></div></div></div><p>Note that a short answer is different from only an answer. The way to get a detailed answer, but without any auxiliary information, is to turn off all the results (<code class="option" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">+noall</code>) and then turn on only those sections you want.</p><p>Here&#8217;s a short answer followed by only an answer; the latter includes all the configuration information, including time-to-live (TTL) data, displayed in a format compatible with BIND configuration files.</p><pre class="screen" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">$ <strong class="userinput"><code style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">dig fsf.org mx +short</code></strong>
20 mx20.gnu.org.
30 mx30.gnu.org.
10 mx10.gnu.org.

$ <strong class="userinput"><code style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">dig +nocmd fsf.org mx +noall +answer</code></strong>
fsf.org.                3583    IN      MX      30 mx30.gnu.org.
fsf.org.                3583    IN      MX      10 mx10.gnu.org.
fsf.org.                3583    IN      MX      20 mx20.gnu.org.
</pre></div><div class="sect2" xml:lang="en"><div class="titlepage" style="font-size: 10pt; "><div><div><h3 class="title" style="color: rgb(178, 34, 34); font-family: verdana, arial, helvetica, 'dejavu sans', sans-serif; font-size: 12pt; "><a id="how-long" style="text-decoration: none; "></a>Get a long answer?</h3></div></div></div><p>According to its man page, the&nbsp;<code class="option" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">+multiline</code>&nbsp;option will give you an answer with&nbsp;<span class="quote">&#8220;<span class="quote">the SOA records in a verbose multi-line format with human-readable comments.</span>&#8221;</span>&nbsp;In general, the answers retrieved using the&nbsp;<code class="option" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">+multiline</code>&nbsp;option will appear more like BIND config files than they will without it.</p><pre class="screen" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">$ <strong class="userinput"><code style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">dig +nocmd ogi.edu any +multiline +noall +answer</code></strong>
ogi.edu.   14267 IN A 129.95.59.31
ogi.edu.   14267 IN MX 5 cse.ogi.edu.
ogi.edu.   14267 IN MX 15 hermes.admin.ogi.edu.
ogi.edu.   14267 IN SOA zeal.admin.ogi.edu. hostmaster.admin.ogi.edu. (
                   200408230  ; serial
                   14400      ; refresh (4 hours)
                   900        ; retry (15 minutes)
                   3600000    ; expire (5 weeks 6 days 16 hours)
                   14400      ; minimum (4 hours)
                   )
ogi.edu.   14267 IN NS zeal.admin.ogi.edu.
ogi.edu.   14267 IN NS cse.ogi.edu.
ogi.edu.   14267 IN NS fork.admin.ogi.edu.
</pre></div><div class="sect2" xml:lang="en"><div class="titlepage" style="font-size: 10pt; "><div><div><h3 class="title" style="color: rgb(178, 34, 34); font-family: verdana, arial, helvetica, 'dejavu sans', sans-serif; font-size: 12pt; "><a id="how-reverse" style="text-decoration: none; "></a>Do a reverse lookup?</h3></div></div></div><p>Use the&nbsp;<code class="option" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">-x</code>&nbsp;option to lookup the main hostname associated with an IP address.</p><pre class="screen" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">$ <strong class="userinput"><code style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">dig -x 204.152.184.167 +short</code></strong>
mx-1.isc.org.
</pre><p>In a loop, this is a slick way to map the names in a given subnet:</p><pre class="programlisting" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; border-top-width: 1px; border-top-style: solid; border-top-color: rgb(102, 102, 102); border-right-width: 2px; border-right-style: solid; border-right-color: rgb(102, 102, 102); border-bottom-width: 2px; border-bottom-style: solid; border-bottom-color: rgb(102, 102, 102); border-left-width: 1px; border-left-style: solid; border-left-color: rgb(102, 102, 102); background-color: rgb(253, 223, 223); padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; ">#!/bin/bash
NET=18.7.22
for n in $(seq 1 254); do
  ADDR=${NET}.${n}
  echo -e "${ADDR}\t$(dig -x ${ADDR} +short)"
done
</pre></div><div class="sect2" xml:lang="en"><div class="titlepage" style="font-size: 10pt; "><div><div><h3 class="title" style="color: rgb(178, 34, 34); font-family: verdana, arial, helvetica, 'dejavu sans', sans-serif; font-size: 12pt; "><a id="how-otherserver" style="text-decoration: none; "></a>Query a different nameserver?</h3></div></div></div><p>Just specify it on the command line:</p><pre class="programlisting" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; border-top-width: 1px; border-top-style: solid; border-top-color: rgb(102, 102, 102); border-right-width: 2px; border-right-style: solid; border-right-color: rgb(102, 102, 102); border-bottom-width: 2px; border-bottom-style: solid; border-bottom-color: rgb(102, 102, 102); border-left-width: 1px; border-left-style: solid; border-left-color: rgb(102, 102, 102); background-color: rgb(253, 223, 223); padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; ">dig @ns1.google.com www.google.com
</pre></div><div class="sect2" xml:lang="en"><div class="titlepage" style="font-size: 10pt; "><div><div><h3 class="title" style="color: rgb(178, 34, 34); font-family: verdana, arial, helvetica, 'dejavu sans', sans-serif; font-size: 12pt; "><a id="how-searchlist" style="text-decoration: none; "></a>Use the&nbsp;<code class="option" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">search</code>&nbsp;list in&nbsp;<code class="filename" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">/etc/resolv.conf</code>?</h3></div></div></div><p>The&nbsp;<span class="command"><strong>host</strong></span>&nbsp;utility will automatically use the&nbsp;<code class="option" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">search</code>&nbsp;list in your&nbsp;<code class="filename" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">/etc/resolv.conf</code>&nbsp;file.</p><pre class="screen" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">$ <strong class="userinput"><code style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">host www</code></strong>
www.madboa.com has address 65.102.49.170
</pre><p>By default, however,&nbsp;<span class="command"><strong>dig</strong></span>&nbsp;doesn&#8217;t—which may produce some unexpected results. If you want to use local hostnames instead of fully qualified domain names, use the&nbsp;<code class="option" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">+search</code>option.</p><pre class="programlisting" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; border-top-width: 1px; border-top-style: solid; border-top-color: rgb(102, 102, 102); border-right-width: 2px; border-right-style: solid; border-right-color: rgb(102, 102, 102); border-bottom-width: 2px; border-bottom-style: solid; border-bottom-color: rgb(102, 102, 102); border-left-width: 1px; border-left-style: solid; border-left-color: rgb(102, 102, 102); background-color: rgb(253, 223, 223); padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; ">dig www +search
</pre></div><div class="sect2" xml:lang="en"><div class="titlepage" style="font-size: 10pt; "><div><div><h3 class="title" style="color: rgb(178, 34, 34); font-family: verdana, arial, helvetica, 'dejavu sans', sans-serif; font-size: 12pt; "><a id="how-bulk" style="text-decoration: none; "></a>Do bulk lookups?</h3></div></div></div><p>If you want to look up a large number of hostnames, you can put them in a file (one name per line) and use the&nbsp;<code class="option" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">-f</code>&nbsp;option to query each one in turn.</p><pre class="programlisting" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; border-top-width: 1px; border-top-style: solid; border-top-color: rgb(102, 102, 102); border-right-width: 2px; border-right-style: solid; border-right-color: rgb(102, 102, 102); border-bottom-width: 2px; border-bottom-style: solid; border-bottom-color: rgb(102, 102, 102); border-left-width: 1px; border-left-style: solid; border-left-color: rgb(102, 102, 102); background-color: rgb(253, 223, 223); padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; "># do full lookups for a number of hostnames
dig -f /path/to/host-list.txt

# the same, with more focused output
dig -f /path/to/host-list.txt +noall +answer
</pre><p>As far as I can tell,&nbsp;<span class="command"><strong>dig</strong></span>&nbsp;versions up to and including 9.2.3 are unable to do reverse lookups using the&nbsp;<code class="option" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">-f</code>&nbsp;option.</p></div></div><div class="sect1" xml:lang="en" style="font-family: optima, utopia, georgia, 'dejavu serif', 'bitstream charter', serif; font-size: 15px; "><div class="titlepage" style="font-size: 10pt; "><div><div><h2 class="title" style="color: rgb(178, 34, 34); font-family: verdana, arial, helvetica, 'dejavu sans', sans-serif; font-size: 14pt; "><a id="verify" style="text-decoration: none; "></a>Verifying DNS mappings</h2></div></div></div><p>An improperly configured DNS setup can be really annoying. You want to make sure that your mappings work both ways:</p><div class="orderedlist"><ol class="orderedlist"><li class="listitem"><p>Each hostname should resolve to an address, and that address ought to resolve back to the proper hostname.</p></li><li class="listitem"><p>If an address on your subnet(s) has been assigned a reverse pointer to a hostname, that hostname ought to point back to the original address.</p></li></ol></div><p>There are exceptions to those two rules, of course. A CNAME will resolve to another hostname first, and only then to an address. Sometimes multiple hostnames will point to the same address, but that address will have only one reverse pointer.</p><p>Still, it&#8217;s good to know that your basic mappings work as expected.</p><p>You can script such a test if you build a file containing your known hostnames. The example script below is pretty simple; it will break if fed a CNAME, and it&#8217;ll report a failure somewhere if multiple hostnames point to the same address. Let&#8217;s assume the file containing your hostnames is named&nbsp;<code class="filename" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">named-hosts</code>.</p><pre class="programlisting" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; border-top-width: 1px; border-top-style: solid; border-top-color: rgb(102, 102, 102); border-right-width: 2px; border-right-style: solid; border-right-color: rgb(102, 102, 102); border-bottom-width: 2px; border-bottom-style: solid; border-bottom-color: rgb(102, 102, 102); border-left-width: 1px; border-left-style: solid; border-left-color: rgb(102, 102, 102); background-color: rgb(253, 223, 223); padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; ">#!/bin/bash
#
# test DNS forward- and reverse-mapping
#

# edit this variable to reflect local class C subnet(s)
NETS="192.168.1 192.168.2"

# Test name to address to name validity
echo
echo -e "\tname -&gt; address -&gt; name"
echo '----------------------------------'
while read H; do
  ADDR=$(dig $H +short)
  if test -n "$ADDR"; then
    HOST=$(dig -x $ADDR +short)
    if test "$H" = "$HOST"; then
      echo -e "ok\t$H -&gt; $ADDR -&gt; $HOST"
    elif test -n "$HOST"; then
      echo -e "fail\t$H -&gt; $ADDR -&gt; $HOST"
    else
      echo -e "fail\t$H -&gt; $ADDR -&gt; [unassigned]"
    fi
  else
    echo -e "fail\t$H -&gt; [unassigned]"
  fi
done &lt; named-hosts

# Test address to name to address validity
echo
echo -e "\taddress -&gt; name -&gt; address"
echo '-------------------------------------'
for NET in $NETS; do
  for n in $(seq 1 254); do
    A=${NET}.${n}
    HOST=$(dig -x $A +short)
    if test -n "$HOST"; then
      ADDR=$(dig $HOST +short)
      if test "$A" = "$ADDR"; then
        echo -e "ok\t$A -&gt; $HOST -&gt; $ADDR"
      elif test -n "$ADDR"; then
        echo -e "fail\t$A -&gt; $HOST -&gt; $ADDR"
      else
        echo -e "fail\t$A -&gt; $HOST -&gt; [unassigned]"
      fi
    fi
  done
done
</pre></div><div class="sect1" xml:lang="en" style="font-family: optima, utopia, georgia, 'dejavu serif', 'bitstream charter', serif; font-size: 15px; "><div class="titlepage" style="font-size: 10pt; "><div><div><h2 class="title" style="color: rgb(178, 34, 34); font-family: verdana, arial, helvetica, 'dejavu sans', sans-serif; font-size: 14pt; "><a id="fun" style="text-decoration: none; "></a>dig fun</h2></div></div></div><div class="sect2" xml:lang="en"><div class="titlepage" style="font-size: 10pt; "><div><div><h3 class="title" style="color: rgb(178, 34, 34); font-family: verdana, arial, helvetica, 'dejavu sans', sans-serif; font-size: 12pt; "><a id="fun-root" style="text-decoration: none; "></a>Roll your own&nbsp;<code class="filename" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">named.root</code>&nbsp;file</h3></div></div></div><p>Any DNS server connected to the Internet is likely to have a copy of the InterNIC&#8217;s<code class="filename" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">named.root</code>&nbsp;file that lists the root name servers for the entire Internet. You can always download that file in the boring way from&nbsp;<a class="ulink" href="ftp://ftp.internic.net/domain/named.root" style="text-decoration: none; color: rgb(0, 0, 128); ">the InterNIC&#8217;s ftp server</a>. Or, in a true build-it-yourself fashion, you can build it with&nbsp;<span class="command"><strong>dig</strong></span>.</p><pre class="programlisting" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; border-top-width: 1px; border-top-style: solid; border-top-color: rgb(102, 102, 102); border-right-width: 2px; border-right-style: solid; border-right-color: rgb(102, 102, 102); border-bottom-width: 2px; border-bottom-style: solid; border-bottom-color: rgb(102, 102, 102); border-left-width: 1px; border-left-style: solid; border-left-color: rgb(102, 102, 102); background-color: rgb(253, 223, 223); padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; "># compare with ftp://ftp.internic.net/domain/named.root
dig +nocmd . NS +noall +answer +additional
</pre><p>Your TTL values might be a little on the short side, but otherwise, it&#8217;s as up-to-date a list as you&#8217;ll find!</p></div><div class="sect2" xml:lang="en"><div class="titlepage" style="font-size: 10pt; "><div><div><h3 class="title" style="color: rgb(178, 34, 34); font-family: verdana, arial, helvetica, 'dejavu sans', sans-serif; font-size: 12pt; "><a id="fun-trace" style="text-decoration: none; "></a>Tracing dig&#8217;s path</h3></div></div></div><p>Perhaps you&#8217;re a devotee of&nbsp;<span class="command"><strong>traceroute</strong></span>&nbsp;and like to watch how to get from point A to point B. You can do a similar thing with dig&#8217;s&nbsp;<code class="option" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">+trace</code>&nbsp;option.</p><pre class="programlisting" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; border-top-width: 1px; border-top-style: solid; border-top-color: rgb(102, 102, 102); border-right-width: 2px; border-right-style: solid; border-right-color: rgb(102, 102, 102); border-bottom-width: 2px; border-bottom-style: solid; border-bottom-color: rgb(102, 102, 102); border-left-width: 1px; border-left-style: solid; border-left-color: rgb(102, 102, 102); background-color: rgb(253, 223, 223); padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; ">dig gentoo.de +trace
</pre><p>You&#8217;ll see dig head to the root name servers, then to the servers responsible for all the *.de domains, and finally to the name servers responsible for&nbsp;<code class="systemitem" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">gentoo.de</code>.</p></div><div class="sect2" xml:lang="en"><div class="titlepage" style="font-size: 10pt; "><div><div><h3 class="title" style="color: rgb(178, 34, 34); font-family: verdana, arial, helvetica, 'dejavu sans', sans-serif; font-size: 12pt; "><a id="fun-soa" style="text-decoration: none; "></a>Grabbing SOA information</h3></div></div></div><p>As a DNS administrator, I sometimes make changes and want to see if any of my name servers are still pushing the old data. The&nbsp;<code class="option" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">+nssearch</code>&nbsp;provides a clear accounting of your public servers.</p><pre class="programlisting" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; border-top-width: 1px; border-top-style: solid; border-top-color: rgb(102, 102, 102); border-right-width: 2px; border-right-style: solid; border-right-color: rgb(102, 102, 102); border-bottom-width: 2px; border-bottom-style: solid; border-bottom-color: rgb(102, 102, 102); border-left-width: 1px; border-left-style: solid; border-left-color: rgb(102, 102, 102); background-color: rgb(253, 223, 223); padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; "># the unvarnished truth
dig cse.ogi.edu +nssearch

# the same, displaying only serial number and hostname
dig cse.ogi.edu +nssearch | cut -d' ' -f4,11
</pre></div></div><div class="sect1" xml:lang="en" style="font-family: optima, utopia, georgia, 'dejavu serif', 'bitstream charter', serif; font-size: 15px; "><div class="titlepage" style="font-size: 10pt; "><div><div><h2 class="title" style="color: rgb(178, 34, 34); font-family: verdana, arial, helvetica, 'dejavu sans', sans-serif; font-size: 14pt; "><a id="ttl" style="text-decoration: none; "></a>Interpreting TTL numbers</h2></div></div></div><p>I love&nbsp;<a class="ulink" href="http://www.google.com/" style="text-decoration: none; color: rgb(0, 0, 128); ">Google</a>&nbsp;for many reasons, one of which is that it provides referrer strings in my web logs that make it easy to figure out what sort of queries lead people to pages on this site.</p><p>Somewhat unexpectedly, I&#8217;ve seen a lot of queries asking for information about TTL (time-to-live) numbers. I would have never guessed that TTL would be a topic of interest, but you learn something new every day. So, by popular demand, here&#8217;s a brief intro to TTL.</p><p>If you ask your local DNS server for an Internet address, the server figures out where to find an authoritative answer and then asks for it. Once the server receives an answer, it will keep the answer in a local cache so that if you ask for the same address again a short time later, it can give you the answer quickly rather than searching the Internet for it all over again.</p><p>When domain administrators configure their DNS records, they decide how long the records should remain in remote caches. This is the TTL number (usually expressed in number of seconds).</p><p>Typically, a remote server will only cache those records for the length of time specified by the TTL. After that, the remote server will flush its local cache and ask again for an authoritative answer.</p><p>When you use dig to query a DNS server concerning a certain record, the server will tell dig the time (in seconds) that record will remain in cache.</p><p>For example, as of this writing, the TTL for the MX records for the&nbsp;<code class="systemitem" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">gmail.com</code>&nbsp;domain is 300 seconds. The&nbsp;<code class="systemitem" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">gmail.com</code>&nbsp;admins are asking that remote servers cache their MX records for no more than five minutes. So when you first ask for that record set, dig will report a TTL of 300.</p><pre class="screen" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">$ <strong class="userinput"><code style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">dig +nocmd gmail.com MX +noall +answer</code></strong>
gmail.com.        300     IN      MX      20 gsmtp57.google.com.
gmail.com.        300     IN      MX      10 gsmtp171.google.com.
</pre><p>If you ask a few seconds later, you&#8217;ll see the TTL number reduced by approximately the number of seconds you waited to ask again.</p><pre class="screen" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">$ <strong class="userinput"><code style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">dig +nocmd gmail.com MX +noall +answer</code></strong>
gmail.com.        280     IN      MX      10 gsmtp171.google.com.
gmail.com.        280     IN      MX      20 gsmtp57.google.com.
</pre><p>If your timing is good, you can catch the record at the very end of its life.</p><pre class="screen" style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">$ <strong class="userinput"><code style="font-family: monaco, 'dejavu sans mono', 'luxi mono', monospace; font-size: 10pt; ">dig +nocmd gmail.com MX +noall +answer</code></strong>
gmail.com.        1       IN      MX      10 gsmtp171.google.com.
gmail.com.        1       IN      MX      20 gsmtp57.google.com.
</pre><p>After that, the DNS server you&#8217;re querying will&nbsp;<span class="quote">&#8220;<span class="quote">forget</span>&#8221;</span>&nbsp;the answer to that question, so the whole cycle will start over again (in this example, at 300 seconds) the next time you perform that query.</p></div>
<img src ="http://www.cppblog.com/momoxiao/aggbug/134343.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/momoxiao/" target="_blank">小默</a> 2010-11-23 04:48 <a href="http://www.cppblog.com/momoxiao/archive/2010/11/23/134343.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>【转】网路协议</title><link>http://www.cppblog.com/momoxiao/archive/2010/11/18/133994.html</link><dc:creator>小默</dc:creator><author>小默</author><pubDate>Thu, 18 Nov 2010 08:03:00 GMT</pubDate><guid>http://www.cppblog.com/momoxiao/archive/2010/11/18/133994.html</guid><wfw:comment>http://www.cppblog.com/momoxiao/comments/133994.html</wfw:comment><comments>http://www.cppblog.com/momoxiao/archive/2010/11/18/133994.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/momoxiao/comments/commentRss/133994.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/momoxiao/services/trackbacks/133994.html</trackback:ping><description><![CDATA[<meta http-equiv="content-type" content="text/html; charset=utf-8"><span  style="font-family: sans-serif; font-size: 18px; line-height: 27px; "><table class="infobox" cellspacing="5" style="font-size: 15px; color: black; background-color: rgb(249, 249, 249); border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(170, 170, 170); border-right-color: rgb(170, 170, 170); border-bottom-color: rgb(170, 170, 170); border-left-color: rgb(170, 170, 170); margin-bottom: 0.5em; margin-left: 1em; padding-top: 0.2em; padding-right: 0.2em; padding-bottom: 0.2em; padding-left: 0.2em; clear: right; text-align: left; line-height: 1.5em; width: 20em; "><tbody><tr><th colspan="2" style="vertical-align: top; text-align: center; font-size: 18px; font-weight: bold; background-color: rgb(170, 221, 187); "><a href="http://zh.wikipedia.org/wiki/%E7%B6%B2%E7%B5%A1%E5%82%B3%E8%BC%B8%E5%8D%94%E8%AD%B0" title="網絡傳輸協議" class="mw-redirect" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">網路協議</a></th></tr><tr><th colspan="2" style="vertical-align: top; text-align: center; background-color: rgb(204, 255, 204); "><a href="http://zh.wikipedia.org/wiki/%E5%BA%94%E7%94%A8%E5%B1%82" title="应用层" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">應用層</a></th></tr><tr class=""><td colspan="2" class="" style="vertical-align: top; text-align: center; "><a href="http://zh.wikipedia.org/wiki/DHCP" title="DHCP" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">DHCP</a>&nbsp;&#183;&nbsp;<a href="http://zh.wikipedia.org/wiki/%E7%B6%B2%E5%9F%9F%E5%90%8D%E7%A8%B1%E7%B3%BB%E7%B5%B1" title="網域名稱系統" class="mw-redirect" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">DNS</a>&nbsp;&#183;&nbsp;<a href="http://zh.wikipedia.org/wiki/%E6%96%87%E4%BB%B6%E4%BC%A0%E8%BE%93%E5%8D%8F%E8%AE%AE" title="文件传输协议" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">FTP</a>&nbsp;&#183;&nbsp;<a href="http://zh.wikipedia.org/wiki/Gopher" title="Gopher" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">Gopher</a>&nbsp;&#183;&nbsp;<a href="http://zh.wikipedia.org/wiki/%E8%B6%85%E6%96%87%E6%9C%AC%E4%BC%A0%E8%BE%93%E5%8D%8F%E8%AE%AE" title="超文本传输协议" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">HTTP</a>&nbsp;&#183;<a href="http://zh.wikipedia.org/wiki/IMAP" title="IMAP" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">IMAP4</a>&nbsp;&#183;&nbsp;<a href="http://zh.wikipedia.org/wiki/IRC" title="IRC" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">IRC</a>&nbsp;&#183;&nbsp;<a href="http://zh.wikipedia.org/wiki/NNTP" title="NNTP" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">NNTP</a>&nbsp;&#183;&nbsp;<a href="http://zh.wikipedia.org/wiki/XMPP" title="XMPP" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">XMPP</a>&nbsp;&#183;&nbsp;<a href="http://zh.wikipedia.org/wiki/POP3" title="POP3" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">POP3</a>&nbsp;&#183;<a href="http://zh.wikipedia.org/wiki/%E4%BC%9A%E8%AF%9D%E5%8F%91%E8%B5%B7%E5%8D%8F%E8%AE%AE" title="会话发起协议" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">SIP</a>&nbsp;&#183;&nbsp;<a href="http://zh.wikipedia.org/wiki/%E7%AE%80%E5%8D%95%E9%82%AE%E4%BB%B6%E4%BC%A0%E8%BE%93%E5%8D%8F%E8%AE%AE" title="简单邮件传输协议" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">SMTP</a>&nbsp;&#183;&nbsp;<strong class="selflink">SNMP</strong>&nbsp;&#183;&nbsp;<a href="http://zh.wikipedia.org/wiki/SSH" title="SSH" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">SSH</a>&nbsp;&#183;&nbsp;<a href="http://zh.wikipedia.org/wiki/Telnet" title="Telnet" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">TELNET</a>&nbsp;&#183;<a href="http://zh.wikipedia.org/wiki/%E9%81%A0%E7%A8%8B%E9%81%8E%E7%A8%8B%E8%AA%BF%E7%94%A8" title="遠程過程調用" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">RPC</a>&nbsp;&#183;&nbsp;<a href="http://zh.wikipedia.org/wiki/%E5%AE%9E%E6%97%B6%E4%BC%A0%E8%BE%93%E6%8E%A7%E5%88%B6%E5%8D%8F%E8%AE%AE" title="实时传输控制协议" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">RTCP</a>&nbsp;&#183;&nbsp;<a href="http://zh.wikipedia.org/wiki/%E5%AE%9E%E6%97%B6%E4%BC%A0%E8%BE%93%E5%8D%8F%E8%AE%AE" title="实时传输协议" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">RTP</a>&nbsp;&#183;<a href="http://zh.wikipedia.org/wiki/RTSP" title="RTSP" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">RTSP</a>&nbsp;&#183;&nbsp;<a href="http://zh.wikipedia.org/wiki/%E4%BC%9A%E8%AF%9D%E6%8F%8F%E8%BF%B0%E5%8D%8F%E8%AE%AE" title="会话描述协议" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">SDP</a>&nbsp;&#183;&nbsp;<a href="http://zh.wikipedia.org/wiki/SOAP" title="SOAP" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">SOAP</a>&#183; GTP &#183;&nbsp;<a href="http://zh.wikipedia.org/wiki/STUN" title="STUN" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">STUN</a>&nbsp;&#183;&nbsp;<a href="http://zh.wikipedia.org/wiki/%E7%B6%B2%E7%B5%A1%E6%99%82%E9%96%93%E5%8D%94%E8%AD%B0" title="網絡時間協議" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">NTP</a>&nbsp;&#183;&nbsp;<a href="http://zh.wikipedia.org/wiki/%E7%AE%80%E5%8D%95%E6%9C%8D%E5%8A%A1%E5%8F%91%E7%8E%B0%E5%8D%8F%E8%AE%AE" title="简单服务发现协议" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">SSDP</a>&nbsp;&#183;&nbsp;<a href="http://zh.wikipedia.org/wiki/%E8%BE%B9%E7%95%8C%E7%BD%91%E5%85%B3%E5%8D%8F%E8%AE%AE" title="边界网关协议" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">BGP</a>&nbsp;&#183;<a href="http://zh.wikipedia.org/wiki/%E8%B7%AF%E7%94%B1%E4%BF%A1%E6%81%AF%E5%8D%8F%E8%AE%AE" title="路由信息协议" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">RIP</a>&nbsp;&#183;&nbsp;<a href="http://zh.wikipedia.org/wiki/Category:%E5%BA%94%E7%94%A8%E5%B1%82%E7%BD%91%E7%BB%9C%E5%8D%8F%E8%AE%AE" title="Category:应用层网络协议" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">更多</a></td></tr><tr><th colspan="2" style="vertical-align: top; text-align: center; background-color: rgb(204, 255, 204); "><a href="http://zh.wikipedia.org/wiki/%E4%BC%A0%E8%BE%93%E5%B1%82" title="传输层" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">传输层</a></th></tr><tr class=""><td colspan="2" class="" style="vertical-align: top; text-align: center; "><p style="margin-top: 0.4em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; line-height: 1.5em; "><a href="http://zh.wikipedia.org/wiki/%E4%BC%A0%E8%BE%93%E6%8E%A7%E5%88%B6%E5%8D%8F%E8%AE%AE" title="传输控制协议" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">TCP</a>&nbsp;&#183;&nbsp;<a href="http://zh.wikipedia.org/wiki/%E7%94%A8%E6%88%B7%E6%95%B0%E6%8D%AE%E6%8A%A5%E5%8D%8F%E8%AE%AE" title="用户数据报协议" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">UDP</a>&nbsp;&#183;&nbsp;<a href="http://zh.wikipedia.org/wiki/%E4%BC%A0%E8%BE%93%E5%B1%82%E5%AE%89%E5%85%A8" title="传输层安全" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">TLS</a>&nbsp;&#183;&nbsp;<a href="http://zh.wikipedia.org/wiki/DCCP" title="DCCP" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">DCCP</a>&nbsp;&#183;&nbsp;<a href="http://zh.wikipedia.org/wiki/SCTP" title="SCTP" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">SCTP</a>&nbsp;&#183;</p><a href="http://zh.wikipedia.org/wiki/%E8%B5%84%E6%BA%90%E9%A2%84%E7%95%99%E5%8D%8F%E8%AE%AE" title="资源预留协议" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">RSVP</a>&nbsp;&#183;&nbsp;<a href="http://zh.wikipedia.org/wiki/%E9%BB%9E%E5%B0%8D%E9%BB%9E%E9%9A%A7%E9%81%93%E5%8D%94%E8%AD%B0" title="點對點隧道協議" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">PPTP</a>&nbsp;&#183;&nbsp;<a href="http://zh.wikipedia.org/wiki/%E5%BC%80%E6%94%BE%E5%BC%8F%E6%9C%80%E7%9F%AD%E8%B7%AF%E5%BE%84%E4%BC%98%E5%85%88" title="开放式最短路径优先" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">OSPF</a>&nbsp;&#183;&nbsp;<a href="http://zh.wikipedia.org/wiki/Category:%E4%BC%A0%E8%BE%93%E5%B1%82%E7%BD%91%E7%BB%9C%E5%8D%8F%E8%AE%AE" title="Category:传输层网络协议" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">更多</a></td></tr><tr><th colspan="2" style="vertical-align: top; text-align: center; background-color: rgb(204, 255, 204); "><a href="http://zh.wikipedia.org/wiki/%E7%BD%91%E7%BB%9C%E5%B1%82" title="网络层" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">网络层</a></th></tr><tr class=""><td colspan="2" class="" style="vertical-align: top; text-align: center; "><p style="margin-top: 0.4em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; line-height: 1.5em; "><a href="http://zh.wikipedia.org/wiki/%E7%BD%91%E9%99%85%E5%8D%8F%E8%AE%AE" title="网际协议" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">IP</a>&nbsp;(<a href="http://zh.wikipedia.org/wiki/IPv4" title="IPv4" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">IPv4</a>&nbsp;&#183;&nbsp;<a href="http://zh.wikipedia.org/wiki/IPv6" title="IPv6" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">IPv6</a>) &#183;&nbsp;<a href="http://zh.wikipedia.org/wiki/%E4%BA%92%E8%81%94%E7%BD%91%E6%8E%A7%E5%88%B6%E6%B6%88%E6%81%AF%E5%8D%8F%E8%AE%AE" title="互联网控制消息协议" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">ICMP</a>&nbsp;&#183;&nbsp;<a href="http://zh.wikipedia.org/wiki/ICMPv6" title="ICMPv6" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">ICMPv6</a>&nbsp;&#183;&nbsp;<a href="http://zh.wikipedia.org/wiki/%E5%9B%A0%E7%89%B9%E7%BD%91%E7%BB%84%E7%AE%A1%E7%90%86%E5%8D%8F%E8%AE%AE" title="因特网组管理协议" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">IGMP</a>&#183;</p><a href="http://zh.wikipedia.org/wiki/%E4%B8%AD%E9%97%B4%E7%B3%BB%E7%BB%9F%E5%88%B0%E4%B8%AD%E9%97%B4%E7%B3%BB%E7%BB%9F" title="中间系统到中间系统" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">IS-IS</a>&nbsp;&#183;&nbsp;<a href="http://zh.wikipedia.org/wiki/IPsec" title="IPsec" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">IPsec</a>&nbsp;&#183;&nbsp;<a href="http://zh.wikipedia.org/wiki/Category:%E7%BD%91%E7%BB%9C%E5%B1%82%E5%8D%8F%E8%AE%AE" title="Category:网络层协议" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">更多</a></td></tr><tr><th colspan="2" style="vertical-align: top; text-align: center; background-color: rgb(204, 255, 204); "><a href="http://zh.wikipedia.org/wiki/%E6%95%B0%E6%8D%AE%E9%93%BE%E8%B7%AF%E5%B1%82" title="数据链路层" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">数据链路层</a></th></tr><tr class=""><td colspan="2" class="" style="vertical-align: top; text-align: center; "><p style="margin-top: 0.4em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; line-height: 1.5em; "><a href="http://zh.wikipedia.org/wiki/Wi-Fi" title="Wi-Fi" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">Wi-Fi</a>(<a href="http://zh.wikipedia.org/wiki/IEEE_802.11" title="IEEE 802.11" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">IEEE 802.11</a>) &#183;&nbsp;<a href="http://zh.wikipedia.org/wiki/WiMAX" title="WiMAX" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">WiMAX</a>(<a href="http://zh.wikipedia.org/wiki/WiMAX" title="WiMAX" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">IEEE 802.16</a>) &#183;&nbsp;<a href="http://zh.wikipedia.org/wiki/%E5%9C%B0%E5%9D%80%E8%A7%A3%E6%9E%90%E5%8D%8F%E8%AE%AE" title="地址解析协议" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">ARP</a>&nbsp;&#183;&nbsp;<a href="http://zh.wikipedia.org/wiki/%E5%8F%8D%E5%90%91%E5%9C%B0%E5%9D%80%E8%BD%AC%E6%8D%A2%E5%8D%8F%E8%AE%AE" title="反向地址转换协议" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">RARP</a>&nbsp;&#183;</p><a href="http://zh.wikipedia.org/wiki/%E5%BC%82%E6%AD%A5%E4%BC%A0%E8%BE%93%E6%A8%A1%E5%BC%8F" title="异步传输模式" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">ATM</a>&nbsp;&#183;&nbsp;<a href="http://zh.wikipedia.org/w/index.php?title=DTM&amp;action=edit&amp;redlink=1" class="new" title="DTM" style="text-decoration: none; color: rgb(204, 34, 0); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">DTM</a>&nbsp;&#183;&nbsp;<a href="http://zh.wikipedia.org/wiki/%E4%BB%A4%E7%89%8C%E7%8E%AF" title="令牌环" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">令牌环</a>&nbsp;&#183;&nbsp;<a href="http://zh.wikipedia.org/wiki/%E4%BB%A5%E5%A4%AA%E7%BD%91" title="以太网" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">以太网</a>&nbsp;&#183;&nbsp;<a href="http://zh.wikipedia.org/wiki/%E5%85%89%E7%BA%A4%E5%88%86%E5%B8%83%E5%BC%8F%E6%95%B0%E6%8D%AE%E6%8E%A5%E5%8F%A3" title="光纤分布式数据接口" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">FDDI</a>&nbsp;&#183;<a href="http://zh.wikipedia.org/wiki/%E5%B8%A7%E4%B8%AD%E7%BB%A7" title="帧中继" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">帧中继</a>&nbsp;&#183;&nbsp;<a href="http://zh.wikipedia.org/wiki/%E9%80%9A%E7%94%A8%E5%88%86%E7%BB%84%E6%97%A0%E7%BA%BF%E6%9C%8D%E5%8A%A1" title="通用分组无线服务" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">GPRS</a>&nbsp;&#183;&nbsp;<a href="http://zh.wikipedia.org/wiki/EVDO" title="EVDO" class="mw-redirect" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">EVDO</a>&nbsp;&#183;&nbsp;<a href="http://zh.wikipedia.org/wiki/%E9%AB%98%E9%80%9F%E5%B0%81%E5%8C%85%E5%AD%98%E5%8F%96" title="高速封包存取" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">HSPA</a>&nbsp;&#183;&nbsp;<a href="http://zh.wikipedia.org/wiki/%E9%AB%98%E7%BA%A7%E6%95%B0%E6%8D%AE%E9%93%BE%E8%B7%AF%E6%8E%A7%E5%88%B6" title="高级数据链路控制" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">HDLC</a>&#183;&nbsp;<a href="http://zh.wikipedia.org/wiki/%E7%82%B9%E5%AF%B9%E7%82%B9%E5%8D%8F%E8%AE%AE" title="点对点协议" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">PPP</a>&nbsp;&#183;&nbsp;<a href="http://zh.wikipedia.org/w/index.php?title=L2TP&amp;action=edit&amp;redlink=1" class="new" title="L2TP" style="text-decoration: none; color: rgb(204, 34, 0); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">L2TP</a>&nbsp;&#183;&nbsp;<a href="http://zh.wikipedia.org/wiki/%E7%BB%BC%E5%90%88%E4%B8%9A%E5%8A%A1%E6%95%B0%E5%AD%97%E7%BD%91" title="综合业务数字网" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">ISDN</a>&nbsp;&#183;&nbsp;<a href="http://zh.wikipedia.org/wiki/Category:%E9%93%BE%E8%B7%AF%E5%8D%8F%E8%AE%AE" title="Category:链路协议" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">更多</a></td></tr><tr><th colspan="2" style="vertical-align: top; text-align: center; background-color: rgb(204, 255, 204); "><a href="http://zh.wikipedia.org/wiki/%E7%89%A9%E7%90%86%E5%B1%82" title="物理层" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">物理层</a></th></tr><tr class=""><td colspan="2" class="" style="vertical-align: top; text-align: center; "><a href="http://zh.wikipedia.org/wiki/%E4%BB%A5%E5%A4%AA%E7%BD%91" title="以太网" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">以太网</a>&nbsp;&#183;&nbsp;<a href="http://zh.wikipedia.org/wiki/%E8%B0%83%E5%88%B6%E8%A7%A3%E8%B0%83%E5%99%A8" title="调制解调器" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">调制解调器</a>&nbsp;&#183;&nbsp;<a href="http://zh.wikipedia.org/wiki/%E9%9B%BB%E5%8A%9B%E7%B7%9A%E9%80%9A%E4%BF%A1" title="電力線通信" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">電力線通信(PLC)</a>&nbsp;&#183;<a href="http://zh.wikipedia.org/wiki/%E5%90%8C%E6%AD%A5%E5%85%89%E7%BD%91%E7%BB%9C" title="同步光网络" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">SONET/SDH</a>&nbsp;&#183;&nbsp;<a href="http://zh.wikipedia.org/w/index.php?title=G.709&amp;action=edit&amp;redlink=1" class="new" title="G.709" style="text-decoration: none; color: rgb(204, 34, 0); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">G.709</a>&nbsp;&#183;&nbsp;<a href="http://zh.wikipedia.org/wiki/%E5%85%89%E5%B0%8E%E7%BA%96%E7%B6%AD" title="光導纖維" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">光导纤维</a>&nbsp;&#183;&nbsp;<a href="http://zh.wikipedia.org/wiki/%E5%90%8C%E8%BD%B4%E7%94%B5%E7%BC%86" title="同轴电缆" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">同轴电缆</a>&nbsp;&#183;&nbsp;<a href="http://zh.wikipedia.org/wiki/%E5%8F%8C%E7%BB%9E%E7%BA%BF" title="双绞线" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">双绞线</a>&nbsp;&#183;&nbsp;<a href="http://zh.wikipedia.org/wiki/Category:%E7%89%A9%E7%90%86%E5%B1%A4%E5%8D%94%E8%AD%B0" title="Category:物理層協議" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">更多</a></td></tr><tr><td colspan="2" class="" style="vertical-align: top; text-align: center; "><div class="noprint plainlinksneverexpand" style="background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: transparent; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-weight: normal; font-size: 12px; color: rgb(0, 0, 0); white-space: nowrap; background-position: initial initial !important; background-repeat: initial initial !important; ">本模板：<a href="http://zh.wikipedia.org/wiki/Template:%E7%BD%91%E7%BB%9C%E5%8D%8F%E8%AE%AE" title="Template:网络协议" style="text-decoration: none; color: rgb(6, 69, 173); background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; background-position: initial initial !important; background-repeat: initial initial !important; "><span style="color: rgb(0, 43, 184); ">查看</span></a>&nbsp;<span style="font-size: 9px; ">&#8226;</span>&nbsp;<a href="http://zh.wikipedia.org/w/index.php?title=Template_talk:%E7%BD%91%E7%BB%9C%E5%8D%8F%E8%AE%AE&amp;action=edit&amp;redlink=1" class="new" title="Template talk:网络协议" style="text-decoration: none; color: rgb(204, 34, 0); background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; background-position: initial initial !important; background-repeat: initial initial !important; "><span title="关于这个模板的讨论页面" style="color: rgb(0, 43, 184); ">討論</span></a>&nbsp;<span style="font-size: 9px; ">&#8226;</span>&nbsp;<a href="http://zh.wikipedia.org/w/index.php?title=Template:%E7%BD%91%E7%BB%9C%E5%8D%8F%E8%AE%AE&amp;action=edit" class="external text" rel="nofollow" style="text-decoration: none; color: rgb(51, 102, 187); background-image: url(http://bits.wikimedia.org/skins-1.5/vector/images/external-link-ltr-icon.png?2); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; padding-top: 0px; padding-right: 13px; padding-bottom: 0px; padding-left: 0px; background-position: 0% 0%; background-repeat: no-repeat no-repeat; "><span title="您可以编辑这个模板。请在储存变更之前先预览" style="color: rgb(0, 43, 184); ">編輯</span></a>&nbsp;<span style="font-size: 9px; ">&#8226;</span>&nbsp;<a href="http://zh.wikipedia.org/w/index.php?title=Template:%E7%BD%91%E7%BB%9C%E5%8D%8F%E8%AE%AE&amp;action=history" class="external text" rel="nofollow" style="text-decoration: none; color: rgb(51, 102, 187); background-image: url(http://bits.wikimedia.org/skins-1.5/vector/images/external-link-ltr-icon.png?2); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; padding-top: 0px; padding-right: 13px; padding-bottom: 0px; padding-left: 0px; background-position: 0% 0%; background-repeat: no-repeat no-repeat; "><span title="查看这个模板的编辑历史" style="color: rgb(0, 43, 184); ">歷史</span></a></div></td></tr></tbody></table></span>
<img src ="http://www.cppblog.com/momoxiao/aggbug/133994.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/momoxiao/" target="_blank">小默</a> 2010-11-18 16:03 <a href="http://www.cppblog.com/momoxiao/archive/2010/11/18/133994.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>http 1.1 GET</title><link>http://www.cppblog.com/momoxiao/archive/2010/11/06/132784.html</link><dc:creator>小默</dc:creator><author>小默</author><pubDate>Sat, 06 Nov 2010 10:39:00 GMT</pubDate><guid>http://www.cppblog.com/momoxiao/archive/2010/11/06/132784.html</guid><wfw:comment>http://www.cppblog.com/momoxiao/comments/132784.html</wfw:comment><comments>http://www.cppblog.com/momoxiao/archive/2010/11/06/132784.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/momoxiao/comments/commentRss/132784.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/momoxiao/services/trackbacks/132784.html</trackback:ping><description><![CDATA[不需要回复Header的话 <br><br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="COLOR: #000000">GET&nbsp;</span><span style="COLOR: #000000">/</span></div>
<br>没有指定host<br><br>&gt; telnet <a href="http://www.xxx.com/">www.xxx.com</a> 80<br>GET /<br><br>返回的是，http://xxx.xxx.xxx.xxx:80<br>xxx.xxx.xxx.xxx是<a href="http://www.xxx.com/">www.xxx.com</a>的ip地址<br>---<br><br>需要回复Header的话 <br>Request Header要有HOST，指定要浏览的服务器 <br><br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="COLOR: #000000">GET&nbsp;</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">&nbsp;HTTP</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">1.1</span><span style="COLOR: #000000"><br>HOST:www.xxx.com</span><span style="COLOR: #000000"><br>[空白行]&nbsp;</span></div>
<br>---<br><br>如果上面两种get返回不同页面内容，说明这个主机上有多个网站。
<img src ="http://www.cppblog.com/momoxiao/aggbug/132784.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/momoxiao/" target="_blank">小默</a> 2010-11-06 18:39 <a href="http://www.cppblog.com/momoxiao/archive/2010/11/06/132784.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>python 给出ip,子网掩码，求网络内主机Ip列表</title><link>http://www.cppblog.com/momoxiao/archive/2010/11/01/131994.html</link><dc:creator>小默</dc:creator><author>小默</author><pubDate>Mon, 01 Nov 2010 07:58:00 GMT</pubDate><guid>http://www.cppblog.com/momoxiao/archive/2010/11/01/131994.html</guid><wfw:comment>http://www.cppblog.com/momoxiao/comments/131994.html</wfw:comment><comments>http://www.cppblog.com/momoxiao/archive/2010/11/01/131994.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.cppblog.com/momoxiao/comments/commentRss/131994.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/momoxiao/services/trackbacks/131994.html</trackback:ping><description><![CDATA[
		<textarea>暂存T_T

############

# given ip and subnet_mask, find neighbor in the same subnet

def ipToInt(ip):
    ip_items = ip.split('.')

    ip_int = 0
    for item in ip_items:
        ip_int = ip_int * 256 + int(item)

    return ip_int
def intToIp(ip_int):
    ip_items = ['0','0','0','0']
    for i in range(0,4):
        ip_items[3-i] = str(ip_int % 256)
        ip_int = int((int(ip_int) - int(ip_items[3-i])) / 256) 

    seq = '.'
    ip = seq.join(ip_items)

    return ip

ip = '192.168.1.1'
sm = '255.255.255.128'

ip_int = ipToInt(ip)
sm_int = ipToInt(sm)

total = 256 ** 4

subnet_int = total - sm_int
net_int = int(ip_int / subnet_int) * subnet_int

neibor_ip = []
for i in range(1,subnet_int - 1):
    neibor_int = net_int + i
    neibor_ip.append(intToIp(neibor_int))
print(neibor_ip)
</textarea>
		<br />
		<br />wxpython 之 menubar<br /><textarea>
  1 #!/usr/bin/env python
  2 
  3 import wx
  4 
  5 class MainWindow(wx.Frame):
  6     def __init__(self, parent, title):
  7         wx.Frame.__init__(self,parent,title=title,size=(200,100))
  8         self.control = wx.TextCtrl(self, style=wx.TE_MULTILINE)
  9         self.CreateStatusBar() # A statusbar in the bottom of the window
 10 
 11         # Setting up the menu
 12         filemenu = wx.Menu()
 13         # wx.ID_ABOUT and wx.ID_EXIT are standard IDs provided by wxWidgets.
 14         filemenu.Append(wx.ID_ABOUT,"&amp;About", "Information about this program")
 15         filemenu.AppendSeparator()
 16         filemenu.Append(wx.ID_EXIT,"E&amp;xit", "Terminate the program")
 17 
 18         # Creating the menubar
 19         menuBar = wx.MenuBar()
 20         menuBar.Append(filemenu,"&amp;File") # Adding the filemenu to the menuBar
 21         self.SetMenuBar(menuBar) # Adding the MenuBar to the Frame content
 22         self.Show(True)
 23 
 24 app = wx.App(False)
 25 frame = MainWindow(None, "Simple editor")
 26 app.MainLoop()

</textarea><img src ="http://www.cppblog.com/momoxiao/aggbug/131994.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/momoxiao/" target="_blank">小默</a> 2010-11-01 15:58 <a href="http://www.cppblog.com/momoxiao/archive/2010/11/01/131994.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>net helpmsg</title><link>http://www.cppblog.com/momoxiao/archive/2010/10/29/131766.html</link><dc:creator>小默</dc:creator><author>小默</author><pubDate>Fri, 29 Oct 2010 09:33:00 GMT</pubDate><guid>http://www.cppblog.com/momoxiao/archive/2010/10/29/131766.html</guid><wfw:comment>http://www.cppblog.com/momoxiao/comments/131766.html</wfw:comment><comments>http://www.cppblog.com/momoxiao/archive/2010/10/29/131766.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/momoxiao/comments/commentRss/131766.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/momoxiao/services/trackbacks/131766.html</trackback:ping><description><![CDATA[
C:\Documents and Settings\Administrator&gt;net helpmsg 2<br>系统找不到指定的文件。<img src ="http://www.cppblog.com/momoxiao/aggbug/131766.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/momoxiao/" target="_blank">小默</a> 2010-10-29 17:33 <a href="http://www.cppblog.com/momoxiao/archive/2010/10/29/131766.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>【转】IP, Internet Protocol</title><link>http://www.cppblog.com/momoxiao/archive/2010/10/28/131597.html</link><dc:creator>小默</dc:creator><author>小默</author><pubDate>Thu, 28 Oct 2010 02:06:00 GMT</pubDate><guid>http://www.cppblog.com/momoxiao/archive/2010/10/28/131597.html</guid><wfw:comment>http://www.cppblog.com/momoxiao/comments/131597.html</wfw:comment><comments>http://www.cppblog.com/momoxiao/archive/2010/10/28/131597.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/momoxiao/comments/commentRss/131597.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/momoxiao/services/trackbacks/131597.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: Description:                        Protocol suite:                        TCP/IP.                                        Protocol type:            Connectionless network layer p...&nbsp;&nbsp;<a href='http://www.cppblog.com/momoxiao/archive/2010/10/28/131597.html'>阅读全文</a><img src ="http://www.cppblog.com/momoxiao/aggbug/131597.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/momoxiao/" target="_blank">小默</a> 2010-10-28 10:06 <a href="http://www.cppblog.com/momoxiao/archive/2010/10/28/131597.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>【转】ping.py</title><link>http://www.cppblog.com/momoxiao/archive/2010/10/25/131240.html</link><dc:creator>小默</dc:creator><author>小默</author><pubDate>Mon, 25 Oct 2010 14:16:00 GMT</pubDate><guid>http://www.cppblog.com/momoxiao/archive/2010/10/25/131240.html</guid><wfw:comment>http://www.cppblog.com/momoxiao/comments/131240.html</wfw:comment><comments>http://www.cppblog.com/momoxiao/archive/2010/10/25/131240.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/momoxiao/comments/commentRss/131240.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/momoxiao/services/trackbacks/131240.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 差点勾成Jiong的分类了，因为最近真的很囧Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->#!/usr/bin/env&nbsp;python#&nbsp;-*-&nbsp;coding:&nbsp;iso-8859-1&nbsp;-*-"""p...&nbsp;&nbsp;<a href='http://www.cppblog.com/momoxiao/archive/2010/10/25/131240.html'>阅读全文</a><img src ="http://www.cppblog.com/momoxiao/aggbug/131240.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/momoxiao/" target="_blank">小默</a> 2010-10-25 22:16 <a href="http://www.cppblog.com/momoxiao/archive/2010/10/25/131240.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>【转】IP checksum definition</title><link>http://www.cppblog.com/momoxiao/archive/2010/10/20/130586.html</link><dc:creator>小默</dc:creator><author>小默</author><pubDate>Wed, 20 Oct 2010 09:05:00 GMT</pubDate><guid>http://www.cppblog.com/momoxiao/archive/2010/10/20/130586.html</guid><wfw:comment>http://www.cppblog.com/momoxiao/comments/130586.html</wfw:comment><comments>http://www.cppblog.com/momoxiao/archive/2010/10/20/130586.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/momoxiao/comments/commentRss/130586.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/momoxiao/services/trackbacks/130586.html</trackback:ping><description><![CDATA[<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; "><font size="4"><strong><u>IP checksum definition</u></strong></font></p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; ">The IP checksum is the 16 bit one's complement of the one's complement sum of all 16 bit words in the header.</p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; ">One question many people may ask is "What is the 1's complement sum ?". This is because all computers utilize the 2's complement representation and the 1's complement is not used. The following gives a short introduction.</p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; "><strong><u>2's complement fixed point integers (8-bit)</u></strong></p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; "></p><table border="0" style="font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; width: 476px; "><tbody><tr><td style="font-size: 12px; "><strong>Binary</strong></td><td align="center" style="font-size: 12px; "><strong>Decimal</strong></td><td align="center" style="font-size: 12px; "><strong>Hex</strong></td></tr><tr><td style="font-size: 12px; ">0000 0000</td><td align="center" style="font-size: 12px; ">0</td><td align="center" style="font-size: 12px; ">00</td></tr><tr><td style="font-size: 12px; ">0000 0001</td><td align="center" style="font-size: 12px; ">1</td><td align="center" style="font-size: 12px; ">01</td></tr><tr><td style="font-size: 12px; ">0000 0010</td><td align="center" style="font-size: 12px; ">2</td><td align="center" style="font-size: 12px; ">02</td></tr><tr><td style="font-size: 12px; ">0000 0011</td><td align="center" style="font-size: 12px; ">3</td><td align="center" style="font-size: 12px; ">03</td></tr><tr><td style="font-size: 12px; ">1111 1111</td><td align="center" style="font-size: 12px; ">-1</td><td align="center" style="font-size: 12px; ">FF</td></tr><tr><td style="font-size: 12px; ">1111 1110</td><td align="center" style="font-size: 12px; ">-2</td><td align="center" style="font-size: 12px; ">FE</td></tr><tr><td style="font-size: 12px; ">1111 1101</td><td align="center" style="font-size: 12px; ">-3</td><td align="center" style="font-size: 12px; ">FD</td></tr></tbody></table><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; "></p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; ">Let's add two intergers:&nbsp;<br>-3 + 5 = 2&nbsp;<br>FD + 05 = 01 02<br><strong>Discarding</strong>&nbsp;the carry (01) gives the correct result.</p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; "><strong><u>1's complement fixed point integers (8-bit)</u></strong></p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; "></p><table border="0" style="font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; width: 476px; "><tbody><tr><td style="font-size: 12px; "><strong>Binary</strong></td><td align="center" style="font-size: 12px; "><strong>Decimal</strong></td><td align="center" style="font-size: 12px; "><strong>Hex</strong></td></tr><tr><td style="font-size: 12px; ">0000 0000</td><td align="center" style="font-size: 12px; ">0</td><td align="center" style="font-size: 12px; ">00</td></tr><tr><td style="font-size: 12px; ">0000 0001</td><td align="center" style="font-size: 12px; ">1</td><td align="center" style="font-size: 12px; ">01</td></tr><tr><td style="font-size: 12px; ">0000 0010</td><td align="center" style="font-size: 12px; ">2</td><td align="center" style="font-size: 12px; ">02</td></tr><tr><td style="font-size: 12px; ">0000 0011</td><td align="center" style="font-size: 12px; ">3</td><td align="center" style="font-size: 12px; ">03</td></tr><tr><td style="font-size: 12px; ">1111 1111</td><td align="center" style="font-size: 12px; ">-0</td><td align="center" style="font-size: 12px; ">FF</td></tr><tr><td style="font-size: 12px; ">1111 1110</td><td align="center" style="font-size: 12px; ">-1</td><td align="center" style="font-size: 12px; ">FE</td></tr><tr><td style="font-size: 12px; ">1111 1101</td><td align="center" style="font-size: 12px; ">-2</td><td align="center" style="font-size: 12px; ">FD</td></tr><tr><td style="font-size: 12px; ">1111 1100</td><td align="center" style="font-size: 12px; ">-3</td><td align="center" style="font-size: 12px; ">FC</td></tr></tbody></table><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; "></p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; ">Add the same numbers:&nbsp;<br>-3 + 5 = 2<br>FC + 05 = 01 01<br><strong>Adding</strong>&nbsp;the carry (01) to the LSB (01) gives the correct result:<br>01 + 01 = 02</p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; ">So, the 1's complement sum is done by summing the numbers and adding the carry (or carries) to the result..</p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; "><font size="3"><strong><u>Simple Internet checksum example<br></u></strong></font></p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; ">Suppose we have an 8-bit, 2's complement, machine and send the packet</p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; ">FE 05 00</p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; ">where 00 is the checksum field.</p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; "><font face="Arial" size="2">Let's calculate and verify the Internet checksum.</font></p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; "><font face="Arial" size="2">&nbsp;FE + 05&nbsp; =&nbsp; 01 03</font></p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; "><font face="Arial" size="2">This is the result of the normal (2's complement) addition.</font>&nbsp;<font face="Arial" size="2">The 1's complement sum requires the addition of the carry to the 8-bit word (even though we will not get the same result)</font></p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; "><font face="Arial" size="2">&nbsp;03 + 01 = 04&nbsp;</font>&nbsp;</p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; "><font face="Arial" size="2">so the 1's complement sum of FE + 05 is 04.</font></p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; "><font face="Arial" size="2">The 1's complement of the 1's complement sum (Internet checksum) will be</font>&nbsp;</p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; "><font face="Arial" size="2">~04&nbsp; = FB</font></p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; ">and the packet will be sent as</p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; ">FE 05 FB&nbsp;</p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; "><font face="Arial" size="2">Now, at the receiving end we add all the received bytes, including the checksum</font>&nbsp;(<font face="Arial" size="2">again using the 2's complement representation)</font></p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; "><font face="Arial" size="2">FE + 05 + FB&nbsp; = 01 FE&nbsp;</font>&nbsp;</p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; "><font face="Arial" size="2">The 1's complement sum is</font>&nbsp;&nbsp;</p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; "><font face="Arial" size="2">&nbsp;FE + 01 = FF = -0</font>&nbsp;&nbsp;</p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; "><font face="Arial" size="2">which checks that the transmission was OK (see below).</font></p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; "><font face="Arial" size="2"><strong><u>A more complex example (32-bit machine)</u></strong></font></p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; ">As shown in RFC 1071, the checksum calculation is done in the following way:</p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; ">(1) Adjacent octets to be checksummed are paired to form 16-bit integers, and the 1's complement sum of these 16-bit integers is formed.</p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; ">(2) To generate a checksum, the checksum field itself is cleared, the 16-bit 1's complement sum is computed over the octets concerned, and the 1's complement of this sum is placed in the checksum field.</p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; ">(3) To check a checksum, the 1's complement sum is computed over the same set of octets, including the checksum field. If the result is all 1 bits (-0 in 1's complement arithmetic), the check succeeds.</p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; "><font face="Arial" size="2">Packet</font></p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; "><font face="Arial" size="2">01 00 F2 03 F4 F5 F6 F7 00 00</font></p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; "><font face="Arial" size="2">(00 00 is the checksum field)</font></p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; "><font face="Arial" size="2">Form the 16-bit words</font></p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; "><font face="Arial" size="2">0100 F203 F4F5 F6F7</font></p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; "><font face="Arial" size="2">Calculate 2's complement sum</font></p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; "><font face="Arial" size="2">0100 + F203 + F4F5 + F6F7 = 0002 DEEF (store the sum in a 32-bit word)</font></p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; "><font face="Arial" size="2">Add the carries (0002) to get the 16-bit 1's complement sum</font></p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; "><font face="Arial" size="2">DEEF + 002 = DEF1</font></p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; "><font face="Arial" size="2">Calculate 1's complement of the 1's complement sum</font></p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; "><font face="Arial" size="2">~DEF1 = 210E</font></p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; "><font face="Arial" size="2">We send the packet including the checksum 21 0E</font></p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; "><font face="Arial" size="2">01 00 F2 03 F4 F5 F6 F7 21 0E</font></p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; ">At the receiving</p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; ">0100 + F203 + F4F5 + F6F7 + 210E = 0002 FFFD<br>FFFD + 0002 = FFFF</p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; ">which checks OK.</p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; "><strong><u>Comments<br></u></strong>It may look awkword to use a 1's complement addition on 2's complement machines. This method however has its own benefits.</p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; ">Probably the most important is that it is endian independent. Little Endian computers store hex numbers with the LSB last (Intel processors for example). Big Endian computers put the LSB first (IBM mainframes for example). When carry is added to the LSB to form the 1's complement sum (see the example) it doesn't matter if we add 03 + 01 or 01 + 03. The result is the same.</p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; ">Other benefits include the easiness of checking the transmission and the checksum calculation plus a variety of ways to speed up the calculation by updating only IP fields that have changed.</p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; "><br><font face="Courier New">The IP Header Checksum is computed on the header fields only.&nbsp;<br>Before starting the calculation, the checksum fields (octets 11 and 12)&nbsp;<br>are made equal to zero.&nbsp;<br><br>In the example code,&nbsp;<br>u16 buff[] is an array containing all octets in the header with octets 11 and 12 equal to zero.&nbsp;<br>u16 len_ip_header is the length (number of octets) of the header.<br><br><br>/*<br>**************************************************************************<br>Function: ip_sum_calc<br>Description: Calculate the 16 bit IP sum.<br>***************************************************************************<br>*/<br>typedef unsigned short u16;<br>typedef unsigned long u32;<br><br>u16 ip_sum_calc(u16 len_ip_header, u16 buff[])<br>{<br>&nbsp; &nbsp; &nbsp; &nbsp; u16 word16;<br>&nbsp; &nbsp; &nbsp; &nbsp; u32 sum=0;<br>&nbsp; &nbsp; &nbsp; &nbsp; u16 i;<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; // make 16 bit words out of every two adjacent 8 bit words in the packet<br>&nbsp; &nbsp; &nbsp; &nbsp; // and add them up<br>&nbsp; &nbsp; &nbsp; &nbsp; for (i=0;i&lt;len_ip_header;i=i+2){<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; word16 =((buff[i]&lt;&lt;8)&amp;0xFF00)+(buff[i+1]&amp;0xFF);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sum = sum + (u32) word16;<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br><br>&nbsp; &nbsp; &nbsp; &nbsp; // take only 16 bits out of the 32 bit sum and add up the carries<br>&nbsp; &nbsp; &nbsp; &nbsp; while (sum&gt;&gt;16)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sum = (sum &amp; 0xFFFF)+(sum &gt;&gt; 16);<br><br>&nbsp; &nbsp; &nbsp; &nbsp; // one's complement the result<br>&nbsp; &nbsp; &nbsp; &nbsp; sum = ~sum;<br><br>&nbsp; &nbsp; &nbsp; &nbsp; return ((u16) sum);<br>}</font></p>
<img src ="http://www.cppblog.com/momoxiao/aggbug/130586.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/momoxiao/" target="_blank">小默</a> 2010-10-20 17:05 <a href="http://www.cppblog.com/momoxiao/archive/2010/10/20/130586.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>【转】lighttpd添加cgi支持</title><link>http://www.cppblog.com/momoxiao/archive/2010/10/07/128904.html</link><dc:creator>小默</dc:creator><author>小默</author><pubDate>Thu, 07 Oct 2010 04:34:00 GMT</pubDate><guid>http://www.cppblog.com/momoxiao/archive/2010/10/07/128904.html</guid><wfw:comment>http://www.cppblog.com/momoxiao/comments/128904.html</wfw:comment><comments>http://www.cppblog.com/momoxiao/archive/2010/10/07/128904.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/momoxiao/comments/commentRss/128904.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/momoxiao/services/trackbacks/128904.html</trackback:ping><description><![CDATA[<span  style="color: rgb(149, 152, 137); font-family: sans-serif; font-size: 13px; line-height: 20px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; "><a href="http://hi.baidu.com/shallwe19/blog/item/0e6f2e03a06cd08fd43f7ca7.html">http://hi.baidu.com/shallwe19/blog/item/0e6f2e03a06cd08fd43f7ca7.html</a>在lighttpd里面加入 server.modules += ( "mod_cgi" ) $HTTP["url"] =~ "/cgi-bin/" { alias.url += ( "/cgi-bin/" =&gt; "/usr/local/www/cgi_bin/" ) cgi.assign = ( "" =&gt; "" ) }</span>
<img src ="http://www.cppblog.com/momoxiao/aggbug/128904.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/momoxiao/" target="_blank">小默</a> 2010-10-07 12:34 <a href="http://www.cppblog.com/momoxiao/archive/2010/10/07/128904.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>【转】任播 广播 多播 单播</title><link>http://www.cppblog.com/momoxiao/archive/2010/09/25/127626.html</link><dc:creator>小默</dc:creator><author>小默</author><pubDate>Sat, 25 Sep 2010 09:02:00 GMT</pubDate><guid>http://www.cppblog.com/momoxiao/archive/2010/09/25/127626.html</guid><wfw:comment>http://www.cppblog.com/momoxiao/comments/127626.html</wfw:comment><comments>http://www.cppblog.com/momoxiao/archive/2010/09/25/127626.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/momoxiao/comments/commentRss/127626.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/momoxiao/services/trackbacks/127626.html</trackback:ping><description><![CDATA[<img border="0" align="absmiddle" src="http://www.cppblog.com/images/cppblog_com/momoxiao/network/router_func.png"><br><img src ="http://www.cppblog.com/momoxiao/aggbug/127626.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/momoxiao/" target="_blank">小默</a> 2010-09-25 17:02 <a href="http://www.cppblog.com/momoxiao/archive/2010/09/25/127626.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>【转】文本传输协议HTTP包</title><link>http://www.cppblog.com/momoxiao/archive/2010/09/14/126588.html</link><dc:creator>小默</dc:creator><author>小默</author><pubDate>Tue, 14 Sep 2010 05:50:00 GMT</pubDate><guid>http://www.cppblog.com/momoxiao/archive/2010/09/14/126588.html</guid><wfw:comment>http://www.cppblog.com/momoxiao/comments/126588.html</wfw:comment><comments>http://www.cppblog.com/momoxiao/archive/2010/09/14/126588.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/momoxiao/comments/commentRss/126588.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/momoxiao/services/trackbacks/126588.html</trackback:ping><description><![CDATA[http://www.abc188.com/info/html/chengxusheji/Javajishu/20080225/48468.html<br>========<br>&nbsp;一、超文本传输协议及HTTP包<br>
HTTP协议用于在Internet上发送和接收消息。HTTP协议是一种请求-应答式的协议——客户端发送一个请求，服务器返回该请求的应答，所有的请
求与应答都是HTTP包。HTTP协议使用可靠的TCP连接，默认端口是80。HTTP的第一个版本是HTTP/0.9，后来发展到了HTTP/1.0，
现在最新的版本是HTTP/1.1。HTTP/1.1由RFC 2616 定义。<br>
在HTTP中，Client/Server之间的会话总是由客户端通过建立连接和发送HTTP请求包初始化，服务器不会主动联系客户端或要求与客户端建立
连接。浏览器和服务器都可以随时中断连接，例如，在浏览网页时你可以随时点击&#8220;停止&#8221;按钮中断当前的文件下载过程，关闭与Web服务器的HTTP连接。 <br>　　1 HTTP请求包<br>　　HTTP请求包(GET、POST等请求方法)由三个部分构成，分别是：方法-URI-协议/版本，请求头，请求正文。下面是一个HTTP请求包(GET)的例子： <br>GET /index.JSP HTTP/1.1<br>Accept-Language: zh-cn<br>Connection: Keep-Alive <br>Host: 192.168.0.106<br>Content-Length: 37
<p>userName=new_andy&amp;password=new_andy<br> <br>    请求包的第一行是方法-URI-协议/版本：<br>    GET就是请求方法，根据HTTP标准，HTTP请求可以使用多种请求方法。HTTP 1.1支持七种请求方法：GET、POST、HEAD、OPTIONS、PUT、DELETE和TRACE等，常用的为请求方法是GET和POST。<br>    /index.jsp表示URI。URI指定了要访问的网络资源。<br>    HTTP/1.1是协议和协议的版本。<br>
最后一行userName=new_andy&amp;password=new_andy为正文，正文与HTTP头部有一个空行(\r\n)分隔。这里
需要说明的一点，其中Content-Length说明正文的长度，有的正文长度没有在头部说明，只是标明Transfer-Encoding:
chunked。关于chunked类型的长度计算方法，见RFC 1626。<br>    请求包的头部还会包含许多有关客户端环境和请求正文的有用信息，这里不再描述。<br>　　2 HTTP应答包</p>
<p>　　和HTTP请求包相似，由三个部分构成，分别是：协议-状态代码-描述，应答头，应答正文。下面是一个HTTP应答的例子： </p>
<p>HTTP/1.1 200 OK<br>Server: Microsoft-IIS/4.0<br>Date: Mon, 3 Jan 2005 13:13:33 GMT<br>Content-Type: text/html<br>Last-Modified: Mon, 11 Jan 2004 13:23:42 GMT<br>Content-Length: 90</p>
<p>&lt;html&gt;<br>&lt;head&gt;<br>&lt;title&gt;解读HTTP包示例&lt;/title&gt;&lt;/head&gt;&lt;body&gt;<br>Hello WORLD!<br>&lt;/body&gt;<br>&lt;/html&gt;</p>
<p>　　HTTP应答包的第一行类似于HTTP请求的第一行，表示所用的协议是HTTP 1.1，服务器处理请求的状态码200。 <br>　　应答头也和请求头一样包含许多有用的信息，例如服务器类型、日期时间、内容类型和长度等。应答的正文就是服务器返回的HTML页面。应答头和正文之间也用CRLF分隔。 <br>二、Socket类与ServerSocket类 <br>
在Java中，通信端点由java.net.Socket类(客户端)或java.net.ServerSocket类(服务器端)表示。应用程序通过
端点向网络发送或从网络读取数据。位于两台不同机器上的应用软件通过网络连接发送和接收字节流，从而实现通信。要把HTTP包发送给另一个应用，首先要知
道对方的IP地址以及其通信端点的端口号。<br>   Socket类代表的是客户端，它是一个连接远程服务器应用时临时创建的端点。<br>
ServerSocker类代表的是服务器端，它启动后等待来自客户端的连接请求；一旦接收到请求，ServerSocket创建一个Socket实例来
处理与该客户端的通信。对于服务器应用，我们不知道客户端应用什么时候会试图连接服务器，服务器必须一直处于等待连接的状态。</p>
<p>　　下面是ServerSocket提供了四个构造函数，常用的构造函数的的一种形式为：<br>  public ServerSocket(int port, int backLog, InetAddress bindingAddress);<br>  参数：port指定服务器端监听客户端的端口；<br>  backlog为连接请求的最大队列长度，一旦超越这个长度，服务器端点开始拒绝客户端的连接请求。<br>  bindingAddress是一个java.net.InetAddress的实例，指定绑定IP地址。<br>　　 创建好ServerSocket实例之后，调用它的accept方法，要求它等待传入的连接请求。只有出现了连接请求时，accept方法才会返回，它的返回值是一个Socket类的实例。随后，这个Socket对象就可以用来与客户端应用通信。<br>  <br>  Socket类有许多构造函数，常用的为：<br>  public Socket(String host, int port)。参数是主机名称(IP地址或域名)和端口号。<br>　　 参数host是远程机器的名字或IP地址，port是远程应用的端口号。<br> 　　成功创建了Socket类的实例之后，我们就可以用它来发送和接收字节流形式的数据，数据一般为HTTP包。<br>   <br>
要发送字节流，首先要调用Socket类的getOutputStream方法获得一个java.io.OutputStream对象；要从连接的另一端
接收字节流，首先要调用Socket类的getInputStream方法获得一个java.io.InputStream对象。 <br> 　　下面的代码片断创建一个与本地HTTP服务器（127.0.0.1代表本地主机的IP地址）通信的Socket，发送一个HTTP请求包，准备接收服务器的应答。<br>  Socket socket    = new Socket("127.0.0.1", "80");<br>  OutputStream os  = socket.getOutputStream();<br>  InputStream  ins = socket.getInputStream();<br>  StringBuffer sb=new StringBuffer();<br>  sb.append("GET /index.jsp HTTP/1.1\r\n");//注意\r\n为回车换行<br>  sb.append("Accept-Language: zh-cn\r\n");<br>  sb.append("Connection: Keep-Alive\r\n");<br>  sb.append("Host: 192.168.0.106\r\n");<br>  sb.append("Content-Length: 37\r\n");<br>  sb.append("\r\n");<br>  sb.append("userName=new_andy&amp;password=new_andy\r\n");<br>  sb.append("\r\n");<br>  <br>  //向Web服务器发送一个HTTP请求包<br>  os.write(sb.toString().getBytes());  <br>  <br>  服务器端的代码在大致结构为：<br>  while (!shutdown) {<br>        Socket socket = null;<br>        try {<br>            socket = serverSocket.accept(); //等待客户以送HTTP请求包 <br></p>
<p>// 创建HTTP请求包处理线程<br>            RequestThread request = new RequestThread(socket);<br>            request.start();<br>            if(shutdown) System.exit(0);<br>        }<br>        catch (Exception e) {<br>            e.printStackTrace();<br>        }<br>    }<br>  RequestThread线程分析HTTP请求包，跟根据请求包内容在服务端生成一个HTTP应答包。下一节说明怎样分析HTTP包。<br>  InputStream  input = socket.getInputStream();  //从此字节数据流获得HTTP请求包内容<br>    OutputStream output= socket.getOutputStream(); //向此字节流写入HTTP应答包内容<br>    <br>三、读取HTTP包<br>  以下我自己设计的一个读取HTTP包的类SocketRequest。<br>  public class SocketRequest {  //从指定的Socket的InputStream中读取数据</p>
<p>  private InputStream  input;<br>  private String     uri;<br>  private StringBuffer  request=new StringBuffer();  //用于保存所有内容<br>  private int       CONTENT_LENGTH=0;  //实际包内容数据长<br>  private boolean    bePost = false;<br>  private boolean    beHttpResponse = false;<br>  private boolean    beChucked = false;<br>  private boolean    beGet = false;<br>  private byte       crlf13 = (byte)13; //'\r'<br>  private byte       crlf10 = (byte)10;  //'\n'</p>
<p>  public SocketRequest(InputStream input) {<br>    this.input = input;<br>  }<br> public SocketRequest(Socket socket) {<br>    this.input = socket.getInputStream();<br>  }</p>
<p>  public void ReadData() {  //解析 获得InputStream的数据<br> <br>  ReadHeader();  //头部</p>
<p>  if(beChucked) //为Chucked<br>  {<br>   int ChuckSize=0;<br>   while((ChuckSize=getChuckSize())&gt;0) //多个Chucked<br>   {<br>    readLenData(ChuckSize 2);//读取定长数据<br>   }<br>   readLenData(2); //最后的2位  <br>  }<br>  <br>  if(CONTENT_LENGTH&gt;0)<br>  {<br>   readLenData(CONTENT_LENGTH);//读取定长数据<br>  }<br>  <br>    uri = "";//parseUri(new String(request));<br>  }<br>  <br>  private void readLenData(int size)  //读取定长数据<br>  {<br>   int readed=0;  //已经读取数<br>   try{<br>    int available=0;//input.available(); //可读数<br>    if(available&gt;(size-readed)) available=size-readed;<br>    while( readed&lt;size )<br>     {<br>       while(available==0){  //等到有数据可读<br>         available = input.available(); //可读数<br>        }<br>        if(available&gt;(size-readed)) available= size-readed; //size-readed--剩余数<br>        if(available&gt;2048) available= 2048; //size-readed--剩余数<br>       byte[] buffer = new byte[available];<br>       int reading = input.read(buffer);<br>       request=request.append(new String(buffer,0,reading));  //byte数组相加<br>        readed =reading;  //已读字符<br>   }<br>   }catch(IOException e){<br>     System.out.println("Read readLenData Error!");<br>   }<br> }<br> <br>   private void  ReadHeader() //读取头部 并获得大小<br>   {<br>    byte[]  crlf   = new byte[1];<br>   int     crlfNum= 0;   //已经连接的回车换行数 crlfNum=4为头部结束<br>    try{<br>     while( input.read(crlf)!=-1 )   //读取头部<br>     {<br>      if(crlf[0]==crlf13 || crlf[0]==crlf10)<br>      {<br>         crlfNum  ; <br>      }<br>      else<br>      {  crlfNum=0;  } //不是则清<br>      request=request.append(new String(crlf,0,1));  //byte数组相加<br>      if(crlfNum==4) break;<br>     }<br>   }catch(IOException e){<br>     System.out.println("Read Http Header Error!");<br>     return;<br>    }<br>   <br>    String tempStr=(new String(request)).toUpperCase();<br>    <br>    //这里我只处理了GET与POST方法<br>    String  strMethod  = tempStr.substring(0,4);<br>    if(strMethod.equals("GET ")) //前<br>    {  beGet=true;    <br>    }<br>    else if(strMethod.equals("POST"))<br>    {<br>     bePost=true;<br>     getContentlen_Chucked(tempStr);<br>    }<br>    else {<br>     System.out.println("不支持的HTTP包类型");<br>     <br>    } //其它的其它类型 暂不支持<br>  }</p>
<p>  private void getContentlen_Chucked(String tempStr)  //获得长度 CONTENT-LENGTH 或 是否为CHUNKED型<br>  {<br>   String ss1="CONTENT-LENGTH:";<br>   String ss2=new String("TRANSFER-ENCODING: CHUNKED");<br>   <br>   int clIndex   = tempStr.indexOf(ss1);<br>    int chuckIndex = tempStr.indexOf(ss2);  //为CHUNKED型<br>    byte requst[]= tempStr.getBytes();<br>    if(clIndex!=-1)<br>    { //从clIndex 1起至\r\n<br>       StringBuffer sb=new StringBuffer();<br>       <br>       for(int i=(clIndex 16);;i  )<br>       {<br>        if(requst[i]!=(byte)13 &amp;&amp; requst[i]!=(byte)10 )<br>        {<br>          sb.append((char)requst[i]);<br>        }<br>        else <br>         break;<br>       }<br>       <br>       CONTENT_LENGTH=Integer.parseInt(sb.toString());  //正式的HTML文件的大小<br>       //System.out.println("CONTENT_LENGTH==  " CONTENT_LENGTH);<br>   }<br>   if(chuckIndex!=-1) beChucked=true;<br>  }<br>   <br>  private int  getChuckSize() //Chuck大小<br>   {<br>    byte[]  crlf   = new byte[1];<br>    StringBuffer  sb1   = new StringBuffer();</p>
<p>    int     crlfNum= 0;   //已经连接的回车换行数 crlfNum=4为头部结束 <br></p>
<p>try{<br>     while(input.read(crlf)!=-1)   //读取头部<br>     {<br>      if(crlf[0]==crlf13 || crlf[0]==crlf10)<br>      {  crlfNum  ; }<br>      else<br>      {  crlfNum=0;  } //不是则清<br>      sb1.append((char)crlf[0]);<br>      request=request.append(new String(crlf,0,1));  //byte数组相加<br>      if(crlfNum==2) break;<br>     }<br>   }catch(IOException e){<br>     System.out.println("Read Http Package Error!");<br>     return 0;<br>    }<br>   <br>   return Integer.parseInt((sb1.toString()).trim(),16); //16进控制<br> }<br>  //通过此来进行过滤，是否为发至目标服务器的HTTP包<br>  private String parseUri(String requestString) { <br>    int index1, index2;<br>    index1 = requestString.indexOf(' ');<br>    if (index1 != -1) {<br>      index2 = requestString.indexOf(' ', index1   1);<br>      if (index2 &gt; index1)<br>        return requestString.substring(index1   1, index2);<br>    }<br>    return null;<br>  }</p>
<p>  public String getData() {<br>    return request.toString();<br>  }<br>}</p>
<p> 使用此类:<br> SocketRequest request = new SocketRequest(socket); //socket为ServerSocket.accept()返回的Socket实例<br> request.ReadData();  //读取数据<br> request.getData();<br> 为什么我要用这么大的力量去读取呢，尤其是在因为Socket连接在发送数据时，由于网络的原因经常会发生延迟现象，可能在服务器端开始接收数据时可能只有部分数据可以从InputStream中获得，在一些地方处理不当时，可能只能获得不完整的数据或是错误的数据。<br> 从InputStream读取字节时有多种办法:<br> 常用int read()与int read(byte[] b)。在用read(byte[])时，程序员经常会犯错误，因为在网络环境中，读取的数据量不一定等于参数的大小。<br> <br> 希望我的这篇文章能给你带来一些帮助。<br> <br> <br> 作者：袁文聪<br> QQ：7684315 MSN:new_andy@msn.com</p><img src ="http://www.cppblog.com/momoxiao/aggbug/126588.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/momoxiao/" target="_blank">小默</a> 2010-09-14 13:50 <a href="http://www.cppblog.com/momoxiao/archive/2010/09/14/126588.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>【转】广播域 冲突域</title><link>http://www.cppblog.com/momoxiao/archive/2010/08/28/125017.html</link><dc:creator>小默</dc:creator><author>小默</author><pubDate>Sat, 28 Aug 2010 02:15:00 GMT</pubDate><guid>http://www.cppblog.com/momoxiao/archive/2010/08/28/125017.html</guid><wfw:comment>http://www.cppblog.com/momoxiao/comments/125017.html</wfw:comment><comments>http://www.cppblog.com/momoxiao/archive/2010/08/28/125017.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/momoxiao/comments/commentRss/125017.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/momoxiao/services/trackbacks/125017.html</trackback:ping><description><![CDATA[<a  href="http://hextwolf.blog.51cto.com/59501/29696">http://hextwolf.blog.51cto.com/59501/29696</a><br>============<br><span class="Apple-style-span" style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"><span class="Apple-style-span" style="font-family: Verdana,Arial,Helvetica,宋体,sans-serif; font-size: 13px; line-height: 23px; text-align: left;">
<div class="MsoNormal" style="margin: 0cm 0cm 0pt; padding: 0px; border-width: 0px;"><span times="" roman?;="" mso-hansi-font-family:="" ?times="" new="" roman?="" style="font-family: 宋体;"><font size="3">广播域就是说如果站点发出一个<span style="color: red;">广播信号</span>后能接收到这个信号的范围。通常来说一个局域网就是一个广播域。（用路由器连接的除外）</font></span></div>
<div class="MsoNormal" style="margin: 0cm 0cm 0pt; padding: 0px; border-width: 0px;"><span times="" roman?;="" mso-hansi-font-family:="" ?times="" new="" roman?="" style="font-family: 宋体;"><font size="3">冲突域：一个站点<span style="color: red;">向另一个站点发出信号</span>。除目的站点外，有多少站点能收到这个信号。这些站点就构成一个冲突域。（因为不是自己的东西来了。当然大家要生气起点冲突嘛</font></span></div>
</span></span><br><img src ="http://www.cppblog.com/momoxiao/aggbug/125017.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/momoxiao/" target="_blank">小默</a> 2010-08-28 10:15 <a href="http://www.cppblog.com/momoxiao/archive/2010/08/28/125017.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>【转】HTTP头中的X-Cache和X-Pad是什么意思？</title><link>http://www.cppblog.com/momoxiao/archive/2010/08/20/124104.html</link><dc:creator>小默</dc:creator><author>小默</author><pubDate>Fri, 20 Aug 2010 08:12:00 GMT</pubDate><guid>http://www.cppblog.com/momoxiao/archive/2010/08/20/124104.html</guid><wfw:comment>http://www.cppblog.com/momoxiao/comments/124104.html</wfw:comment><comments>http://www.cppblog.com/momoxiao/archive/2010/08/20/124104.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/momoxiao/comments/commentRss/124104.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/momoxiao/services/trackbacks/124104.html</trackback:ping><description><![CDATA[<strong>&nbsp;<a href="http://bbs.chinaunix.net/viewpro.php?uid=11327" target=_blank><u><font color=#0000ff>abel</font></u></a> 回复于：2004-12-30 19:20:02</strong><br><br>X-Cache:&nbsp;表示你的&nbsp;http&nbsp;request&nbsp;是由&nbsp;proxy&nbsp;server&nbsp;回的 <br>MISS&nbsp;表&nbsp;proxy&nbsp;無資料,代理動作,&nbsp;HIT&nbsp;表&nbsp;proxy&nbsp;直接回應 <br><br>X-Pad:&nbsp;這個是800&nbsp;年前的&nbsp;netscape&nbsp;&nbsp;bug&nbsp;的因素才用的 <br><br>你若有心,看懂&nbsp;RFC&nbsp; <br><br>RFC&nbsp;2187&nbsp;-&nbsp;Application&nbsp;of&nbsp;Internet&nbsp;Cache&nbsp;Protocol&nbsp;(ICP),&nbsp;version&nbsp;2&nbsp; <br>RFC&nbsp;2186&nbsp;-&nbsp;Internet&nbsp;Cache&nbsp;Protocol&nbsp;(ICP),&nbsp;version&nbsp;2&nbsp; <br><br>RFC&nbsp;2616&nbsp;-&nbsp;Hypertext&nbsp;Transfer&nbsp;Protocol&nbsp;--&nbsp;HTTP/1.1&nbsp; <br>RFC&nbsp;2068&nbsp;-&nbsp;Hypertext&nbsp;Transfer&nbsp;Protocol&nbsp;--&nbsp;HTTP/1.1&nbsp; <br>RFC&nbsp;1945&nbsp;-&nbsp;Hypertext&nbsp;Transfer&nbsp;Protocol&nbsp;--&nbsp;HTTP/1.0<br><br><br><br></td>
</tr>
<tr>
    <td height="1" bgcolor="#747474"><img src="http://image2.sina.com.cn/c.gif" width=1 height=1></td>
</tr>
<tr>
    <td><br>原文链接：<a href="http://bbs.chinaunix.net/viewthread.php?tid=474898"><u><font color=#0000ff>http://bbs.chinaunix.net/viewthread.php?tid=474898</font></u></a><br>转载请注明作者名及原文出处<br></td>
</tr>
<img src ="http://www.cppblog.com/momoxiao/aggbug/124104.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/momoxiao/" target="_blank">小默</a> 2010-08-20 16:12 <a href="http://www.cppblog.com/momoxiao/archive/2010/08/20/124104.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>lighttpd - 1 - watcher 创建并监控 workers</title><link>http://www.cppblog.com/momoxiao/archive/2010/08/17/123646.html</link><dc:creator>小默</dc:creator><author>小默</author><pubDate>Mon, 16 Aug 2010 16:28:00 GMT</pubDate><guid>http://www.cppblog.com/momoxiao/archive/2010/08/17/123646.html</guid><wfw:comment>http://www.cppblog.com/momoxiao/comments/123646.html</wfw:comment><comments>http://www.cppblog.com/momoxiao/archive/2010/08/17/123646.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/momoxiao/comments/commentRss/123646.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/momoxiao/services/trackbacks/123646.html</trackback:ping><description><![CDATA[<a  href="http://bbs.chinaunix.net/viewthread.php?tid=1251434">http://bbs.chinaunix.net/viewthread.php?tid=1251434</a><br>==================<br>lighttpd 采用 多进程 的工作模式，watcher 创建 workers 并且监控 workers 的退出。<br><br>watcher 循环创建 worker, 子进程 被创建后跳出循环做自己的工作。<br>当创建够 子进程 后，父进程 调用 wait() 等待有 子进程退出。<br>当父进程wait()中收到信号 SIGHUP，通知进程组的所有成员。<br>当服务器被关闭，父进程kill所有子进程，做清理工作，退出循环。<br>==================<br>版本: 1.4.27<br>
&lt;server.c&gt;<br>=================<br>/// watcher 创建并监控 workers 工作<br>#ifdef HAVE_FORK<br>&nbsp;&nbsp;&nbsp; /* start watcher and workers */<br>&nbsp;&nbsp;&nbsp; num_childs = srv-&gt;srvconf.max_worker;&nbsp;&nbsp; // num_childs，需要创建的 worker 数量<br>&nbsp;&nbsp;&nbsp; if (num_childs &gt; 0) {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; int child = 0;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // child 是一个 flag, 为0是watcher（父进程），为1是worker（子进程）<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; while (!child &amp;&amp; !srv_shutdown &amp;&amp; !graceful_shutdown) {&nbsp;&nbsp;&nbsp;&nbsp; // 如果是父进程，且服务器没有被关闭<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (num_childs &gt; 0) { // num_childs&gt;0, fork()创建子进程<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; switch (fork()) {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; case -1:<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return -1;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; case 0:&nbsp;&nbsp;&nbsp;&nbsp; // 子进程，置child为1。退出循环。<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; child = 1;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; break;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; default:&nbsp;&nbsp;&nbsp; // 父进程，孩子数减1<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; num_childs--;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; break;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; } else {&nbsp;&nbsp;&nbsp; // num_childs=0, 子进程已经创建完了，父进程wait()等待有子进程退出<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; int status;<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (-1 != wait(&amp;status)) {&nbsp; // 有子进程退出，num_childs++<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; /**<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;* one of our workers went away<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;*/<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; num_childs++;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; } else {&nbsp;&nbsp;&nbsp; // wait 返回错误 (-1)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; switch (errno) {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; case EINTR:&nbsp;&nbsp;&nbsp;&nbsp; // wait()被中断打断<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; /**<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;* if we receive a SIGHUP we have to close our logs ourself as we don't<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;* have the mainloop who can help us here<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;*/<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (handle_sig_hup) {&nbsp;&nbsp; // 收到 SIGHUP, 关闭日志，通知进程组的所有进程<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; handle_sig_hup = 0;<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; log_error_cycle(srv);<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; /**<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;* forward to all procs in the process-group<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;*<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;* we also send it ourself<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;*/<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (!forwarded_sig_hup) {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; forwarded_sig_hup = 1;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; kill(0, SIGHUP);&nbsp;&nbsp;&nbsp; // pid=0 通知进程组所有成员<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; break;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; default:<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; break;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; /**<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;* for the parent this is the exit-point<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;*/<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;/// 服务器被关闭。通知进程组所有成员<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;/// 父进程只在这时才退出循环<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (!child) {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; /**<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;* kill all children too<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;*/<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (graceful_shutdown) {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; kill(0, SIGINT);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; } else if (srv_shutdown) {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; kill(0, SIGTERM);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // 清理工作<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; log_error_close(srv);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; network_close(srv);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; connections_free(srv);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; plugins_free(srv);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; server_free(srv);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return 0;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; }<br>#endif<br><br>  <img src ="http://www.cppblog.com/momoxiao/aggbug/123646.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/momoxiao/" target="_blank">小默</a> 2010-08-17 00:28 <a href="http://www.cppblog.com/momoxiao/archive/2010/08/17/123646.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>SCGI</title><link>http://www.cppblog.com/momoxiao/archive/2010/08/03/122024.html</link><dc:creator>小默</dc:creator><author>小默</author><pubDate>Mon, 02 Aug 2010 17:01:00 GMT</pubDate><guid>http://www.cppblog.com/momoxiao/archive/2010/08/03/122024.html</guid><wfw:comment>http://www.cppblog.com/momoxiao/comments/122024.html</wfw:comment><comments>http://www.cppblog.com/momoxiao/archive/2010/08/03/122024.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/momoxiao/comments/commentRss/122024.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/momoxiao/services/trackbacks/122024.html</trackback:ping><description><![CDATA[<strong>=============<br>Apache+SCGI</strong>&nbsp;<br>Apache 前端处理用户请求，负责静态页面<br>mod_scgi 充当 scgi client， 将http请求中动态部分发给 scgi runner。<br><strong>=============</strong><br>参考：<a href="http://www.pc51.net/server/web/apache/2006-12-21/334.html"><u><font color=#0000ff>http://www.pc51.net/server/web/apache/2006-12-21/334.html</font></u></a><br>关注SCGI,一种更佳的高性能CGI方案<br><span class=Apple-style-span style="WORD-SPACING: 0px; FONT: medium Simsun; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate; orphans: 2; widows: 2; webkit-border-horizontal-spacing: 0px; webkit-border-vertical-spacing: 0px; webkit-text-decorations-in-effect: none; webkit-text-size-adjust: auto; webkit-text-stroke-width: 0px"><span class=Apple-style-span style="FONT-SIZE: 14px; COLOR: rgb(54,54,54); LINE-HEIGHT: 26px; TEXT-ALIGN: left"><span class=Apple-style-span style="WORD-SPACING: 0px; FONT: medium Simsun; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate; orphans: 2; widows: 2; webkit-border-horizontal-spacing: 0px; webkit-border-vertical-spacing: 0px; webkit-text-decorations-in-effect: none; webkit-text-size-adjust: auto; webkit-text-stroke-width: 0px"><span class=Apple-style-span style="FONT-SIZE: 12px; COLOR: rgb(54,54,54); TEXT-ALIGN: left"></span></span>目前，rubyonrails可以采用服务器方案有：<span class=Apple-converted-space>&nbsp;</span><br style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px">1。 Webrick<span class=Apple-converted-space>&nbsp;</span><br style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px">2。 Apache(lighttpd) + CGI<span class=Apple-converted-space>&nbsp;</span><br style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px">3。 Apache+FastCGI<span class=Apple-converted-space>&nbsp;</span><br style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px">4。 Lighttpd + FastCGI<span class=Apple-converted-space>&nbsp;</span><br style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px">5。 Apache(lighttpd)+SCGI<span class=Apple-converted-space>&nbsp;</span><br style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px"><br style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px">其中，Webrick是一个玩具，不支持并发请求，只能作为开发工具进行调试。而CGI方式就直接踢出，在性能上是难以忍受的。 FastCGI虽然性能卓越（据称是传统CGI程序的5倍），但是在Apache中非常不稳定，经常会出现500错误。相对来说Lighttpd+FastCGI的方案比较稳定，性能也不错，但lighttpd毕竟不是一个十分流行的http服务器，大部分人都不熟悉此服务，扩展模块也相对较少，另外似乎还有些bug，没有apache那么健壮。<span class=Apple-converted-space>&nbsp;</span><br style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px">在这几个方案中能够兼具高性能和高稳定性的莫过于Apache+SCGI方案。SCGI是用来替换传统CGI的新的CGI协议，以Client/Server的方式实现，具有和FastCGI一样优秀的性能，同时又在稳定性方面远远超过FastCGI, 该方案在Python Web领域应用较多。<span class=Apple-converted-space>&nbsp;</span><br style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px">一般搭建一个SCGI环境需要准备，Apache，mod_scgi, scgi runner等软件，其中apache做为前端http服务器处理用户请求并且负责静态文件，而mod_scgi是apache的一个扩展模块，该模块实现了SCGI协议的client部分，负责将http请求中的动态部分发给SCGI服务器，即SCGI Runner,在rubyonrails社区，已经有人开发了SCGI Rails Runner--SRR，只需要将一个脚本放你的rails程序的script目录中，运行该脚本就会建立一个SCGI Server,等待并且处理SCGI Client(mod_scgi)转发的请求。<span class=Apple-converted-space>&nbsp;</span><br style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px">对SCGI有兴趣的朋友，可以查看这些内容：<span class=Apple-converted-space>&nbsp;</span><br style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px"><a style="PADDING-RIGHT: 10px; BACKGROUND-POSITION: 100% 0%; PADDING-LEFT: 0px; BACKGROUND-IMAGE: url(http://www.pc51.net/img/desatured.gif); PADDING-BOTTOM: 0px; MARGIN: 0px; COLOR: rgb(0,109,163); PADDING-TOP: 0px; TEXT-DECORATION: underline; background-origin: initial; background-clip: initial" href="http://www.mems-exchange.org/software/scgi/" target=_blank>http://www.mems-exchange.org/software/scgi/</a><span class=Apple-converted-space>&nbsp;</span><br style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px"><a style="PADDING-RIGHT: 10px; BACKGROUND-POSITION: 100% 0%; PADDING-LEFT: 0px; BACKGROUND-IMAGE: url(http://www.pc51.net/img/desatured.gif); PADDING-BOTTOM: 0px; MARGIN: 0px; COLOR: rgb(0,109,163); PADDING-TOP: 0px; TEXT-DECORATION: underline; background-origin: initial; background-clip: initial" href="http://www.zedshaw.com/projects/scgi_rails/" target=_blank>http://www.zedshaw.com/projects/scgi_rails/</a><span class=Apple-converted-space>&nbsp;</span><br style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px"><br style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px">另外，由于RubyOnRails特殊的url rewrite机制，官方目前提供的apache配置模板可能会使一些看起来是静态文件的url无法被rubyonrails处理，如typo里的rss: /xml/rss.xml，不过，rails社区的Kyle等人已经搞出了两个方案，而SRR的作者也打算采用他们的方案。当然，一般情况下，使用官方的配置模板就已经能够处理大部分url。对这个问题有兴趣的朋友可以在rails的邮件列表中搜索：scgi apache, 最近的几篇邮件应该有提到。</span></span>
<img src ="http://www.cppblog.com/momoxiao/aggbug/122024.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/momoxiao/" target="_blank">小默</a> 2010-08-03 01:01 <a href="http://www.cppblog.com/momoxiao/archive/2010/08/03/122024.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>【转】大型门户网站的cdn部署</title><link>http://www.cppblog.com/momoxiao/archive/2010/07/16/120597.html</link><dc:creator>小默</dc:creator><author>小默</author><pubDate>Fri, 16 Jul 2010 15:20:00 GMT</pubDate><guid>http://www.cppblog.com/momoxiao/archive/2010/07/16/120597.html</guid><wfw:comment>http://www.cppblog.com/momoxiao/comments/120597.html</wfw:comment><comments>http://www.cppblog.com/momoxiao/archive/2010/07/16/120597.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/momoxiao/comments/commentRss/120597.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/momoxiao/services/trackbacks/120597.html</trackback:ping><description><![CDATA[<a href="http://www.ixpub.net/viewthread.php?tid=744304"><u><font color=#800080>http://www.ixpub.net/viewthread.php?tid=744304</font></u></a><br>======================================<br><br><span class=Apple-style-span style="WORD-SPACING: 0px; FONT: medium Simsun; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate; orphans: 2; widows: 2; webkit-border-horizontal-spacing: 0px; webkit-border-vertical-spacing: 0px; webkit-text-decorations-in-effect: none; webkit-text-size-adjust: auto; webkit-text-stroke-width: 0px"><span class=Apple-style-span style="FONT-SIZE: 14px; COLOR: rgb(68,68,68); LINE-HEIGHT: 22px; FONT-FAMILY: Verdana, Helvetica, Arial, sans-serif; BORDER-COLLAPSE: collapse; TEXT-ALIGN: left">　　新浪采用了ChinaCache做的CDN<span class=t_tag style="CURSOR: pointer; LINE-HEIGHT: normal; BORDER-BOTTOM: rgb(255,0,0) 1px solid; WHITE-SPACE: nowrap; WORD-WRAP: break-word" onclick=tagshow(event) href="tag.php?name=%CF%B5%CD%B3">系统</span>，ChinaCache在全国分布了四十多个点，同时采用基于动态DNS分配的全球<span class=t_tag style="CURSOR: pointer; LINE-HEIGHT: normal; BORDER-BOTTOM: rgb(255,0,0) 1px solid; WHITE-SPACE: nowrap; WORD-WRAP: break-word" onclick=tagshow(event) href="tag.php?name=%B7%FE%CE%F1%C6%F7">服务器</span>负载均衡<span class=t_tag style="CURSOR: pointer; LINE-HEIGHT: normal; BORDER-BOTTOM: rgb(255,0,0) 1px solid; WHITE-SPACE: nowrap; WORD-WRAP: break-word" onclick=tagshow(event) href="tag.php?name=%BC%BC%CA%F5">技术</span>。<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　从新浪的站点结构可以看出：<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　&gt;<span class=Apple-converted-space>&nbsp;</span><a style="COLOR: rgb(0,153,204); LINE-HEIGHT: normal; TEXT-DECORATION: none; WORD-WRAP: break-word" href="http://www.sina.com.cn/" target=_blank>www.sina.com.cn</a><br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Server: UnKnown<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Address: 192.168.1.254<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Non-authoritative answer:<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Name: libra.sina.com.cn<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Addresses: 61.135.152.71, 61.135.152.72, 61.135.152.73,61.135.152.74 61.135.152.75, 61.135.152.76, 61.135.153.181,61.135.153.182, 61.135.53.183, 61.135.153.184, 61.135.152.65,61.135.152.66, 61.135.152.67, 61.135.12.68, 61.135.152.69, 61.135.152.70<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Aliases:<span class=Apple-converted-space>&nbsp;</span><a style="COLOR: rgb(0,153,204); LINE-HEIGHT: normal; TEXT-DECORATION: none; WORD-WRAP: break-word" href="http://www.sina.com.cn/" target=_blank>www.sina.com.cn</a>, jupiter.sina.com.cn<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　在<span class=t_tag style="CURSOR: pointer; LINE-HEIGHT: normal; BORDER-BOTTOM: rgb(255,0,0) 1px solid; WHITE-SPACE: nowrap; WORD-WRAP: break-word" onclick=tagshow(event) href="tag.php?name=%B1%B1%BE%A9">北京</span>地区ChinaCache将<a style="COLOR: rgb(0,153,204); LINE-HEIGHT: normal; TEXT-DECORATION: none; WORD-WRAP: break-word" href="http://www.sina.com.cn的网址解析到libra.sina.com.cn/" target=_blank>www.sina.com.cn的网址解析到libra.sina.com.cn</a>，然后libra.sina.com.cn做了DNS负载均衡，将libra.sina.com.cn解析到61.135.152.71等16个ip上，这16个ip分布在北京的多台前台缓存<span class=t_tag style="CURSOR: pointer; LINE-HEIGHT: normal; BORDER-BOTTOM: rgb(255,0,0) 1px solid; WHITE-SPACE: nowrap; WORD-WRAP: break-word" onclick=tagshow(event) href="tag.php?name=%B7%FE%CE%F1">服务</span>器上，使用squid做前台缓存。如果是在其它地区<span class=t_tag style="CURSOR: pointer; LINE-HEIGHT: normal; BORDER-BOTTOM: rgb(255,0,0) 1px solid; WHITE-SPACE: nowrap; WORD-WRAP: break-word" onclick=tagshow(event) href="tag.php?name=%B7%C3%CE%CA">访问</span><a style="COLOR: rgb(0,153,204); LINE-HEIGHT: normal; TEXT-DECORATION: none; WORD-WRAP: break-word" href="http://www.sina.com.cn可能解析刮../??" target=_blank>http://www.sina.com.cn可能解析刮..??</a>的效果。<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　我们再看一个新浪其它频道是指到哪里的：<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　&gt; news.sina.com.cn<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Server: UnKnown<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Address: 192.168.1.254<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Non-authoritative answer:<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Name: libra.sina.com.cn<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Addresses: 61.135.152.65, 61.135.152.66, 61.135.152.67,61.135.152.68 61.135.152.69, 61.135.152.70, 61.135.152.71,61.135.152.72, 61.135.152.73 61.135.153.178, 61.135.153.179,61.135.153.180, 61.135.153.181, 61.135.153.182 61.135.153.183,61.135.153.184<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Aliases: news.sina.com.cn, jupiter.sina.com.cn<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　可以看出，各个频道的前台缓存集群与<a style="COLOR: rgb(0,153,204); LINE-HEIGHT: normal; TEXT-DECORATION: none; WORD-WRAP: break-word" href="http://www.sina.com.cn/" target=_blank>www.sina.com.cn</a>的前台缓存集群是相同的。<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word"><br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　<strong style="FONT-WEIGHT: bold; LINE-HEIGHT: normal; FONT-STYLE: normal; TEXT-ALIGN: left; WORD-WRAP: break-word">2、搜狐</strong><br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Sohu与新浪的原理差不多，下面是nslookup的结果：<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　&gt;<span class=Apple-converted-space>&nbsp;</span><a style="COLOR: rgb(0,153,204); LINE-HEIGHT: normal; TEXT-DECORATION: none; WORD-WRAP: break-word" href="http://www.sohu.com/" target=_blank>www.sohu.com</a><br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Server: UnKnown<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Address: 192.168.1.254<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Non-authoritative answer:<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Name: pagegrp1.sohu.com<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Addresses: 61.135.132.172, 61.135.132.173, 61.135.132.176,61.135.133.109 61.135.145.47, 61.135.150.65, 61.135.150.67,61.135.150.69, 61.135.150.74 61.135.150.75, 61.135.150.113,61.135.150.145, 61.135.131.73, 61.135.131.91 61.135.131.180,61.135.131.182, 61.135.131.183, 61.135.132.65, 61.135.<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　132.80<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Aliases:<span class=Apple-converted-space>&nbsp;</span><a style="COLOR: rgb(0,153,204); LINE-HEIGHT: normal; TEXT-DECORATION: none; WORD-WRAP: break-word" href="http://www.sohu.com/" target=_blank>www.sohu.com</a><br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　只不过libra.sina.com.cn换成了pagegrp1.sohu.com<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　我们再来看一下sohu的频道：<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　&gt; news.sohu.com<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Server: UnKnown<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Address: 192.168.1.254<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Non-authoritative answer:<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Name: pagegrp1.sohu.com<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Addresses: 61.135.145.47, 61.135.150.65, 61.135.150.67,61.135.150.69 61.135.150.74, 61.135.150.75, 61.135.150.113,61.135.150.145, 61.135.131.73 61.135.131.91, 61.135.131.180,61.135.131.182, 61.135.131.183, 61.135.132.65 61.135.132.80,61.135.132.172, 61.135.132.173, 61.135.132.176, 61.135.133.109<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Aliases: news.sohu.com<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　同新浪相同，用的是同样的服务器群，这可能是因为他们用的都是ChinaCache的服务吧，不过sohu的名字起的有点土，pagegrp1，没有libra，pavo好听，这名字听起来有点像法语，比较浪漫。<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word"><br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　<strong style="FONT-WEIGHT: bold; LINE-HEIGHT: normal; FONT-STYLE: normal; TEXT-ALIGN: left; WORD-WRAP: break-word">3、网易</strong><br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　网易似乎没用ChinaCache的服务，下面是nslookup结果：<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　&gt;<span class=Apple-converted-space>&nbsp;</span><a style="COLOR: rgb(0,153,204); LINE-HEIGHT: normal; TEXT-DECORATION: none; WORD-WRAP: break-word" href="http://www.163.com/" target=_blank>www.163.com</a><br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Server: UnKnown<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Address: 192.168.1.254<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Non-authoritative answer:<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Name:<span class=Apple-converted-space>&nbsp;</span><a style="COLOR: rgb(0,153,204); LINE-HEIGHT: normal; TEXT-DECORATION: none; WORD-WRAP: break-word" href="http://www.163.com/" target=_blank>www.163.com</a><br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Addresses: 202.106.168.103, 202.106.168.104, 202.106.168.109,202.106.168.121 202.108.36.153, 202.108.36.155, 202.108.36.156,202.108.36.167, 202.108.36.172 202.108.36.196<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　直接在<a style="COLOR: rgb(0,153,204); LINE-HEIGHT: normal; TEXT-DECORATION: none; WORD-WRAP: break-word" href="http://www.163.com/" target=_blank>www.163.com</a><span class=Apple-converted-space>&nbsp;</span>这个域名上做了DNS负载均衡。这样的话就要求服务器必须放的非常靠近主节点，才能保证各地的<span class=t_tag style="CURSOR: pointer; LINE-HEIGHT: normal; BORDER-BOTTOM: rgb(255,0,0) 1px solid; WHITE-SPACE: nowrap; WORD-WRAP: break-word" onclick=tagshow(event) href="tag.php?name=%D3%C3%BB%A7">用户</span>访问的速度。<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　但163不同的频道是放在不同的缓存集群上的，这与sina，sohu有些不同，等于sina，sohu是按照地区划分服务器集群，而网易按照频道划分服务器集群。<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　&gt; 163.com<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Server: UnKnown<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Address: 192.168.1.254<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Non-authoritative answer:<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Name: 163.com<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Addresses: 202.108.36.205, 202.108.36.206, 202.108.36.207, 202.108.36.201 202.108.36.202, 202.108.36.203, 202.108.36.204<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　显然，这和<a style="COLOR: rgb(0,153,204); LINE-HEIGHT: normal; TEXT-DECORATION: none; WORD-WRAP: break-word" href="http://www.163.com/" target=_blank>www.163.com</a><span class=Apple-converted-space>&nbsp;</span>不是一个集群，我们再来试一个：<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　&gt; sports.163.com<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Server: UnKnown<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Address: 192.168.1.254<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Non-authoritative answer:<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Name: channel.cache.163.com<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Addresses: 202.108.36.136, 202.108.36.208, 202.108.36.209, 202.108.36.210 202.108.36.211, 202.108.36.212, 202.108.36.213<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Aliases: sports.163.com<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　可以看出，和上面的集群也是不同的。<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word"><br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　<strong style="FONT-WEIGHT: bold; LINE-HEIGHT: normal; FONT-STYLE: normal; TEXT-ALIGN: left; WORD-WRAP: break-word">4、百度</strong><br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　百度的前台服务器就不是很多了：<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　&gt;<span class=Apple-converted-space>&nbsp;</span><a style="COLOR: rgb(0,153,204); LINE-HEIGHT: normal; TEXT-DECORATION: none; WORD-WRAP: break-word" href="http://www.baidu.com/" target=_blank>www.baidu.com</a><br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Server: UnKnown<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Address: 192.168.1.254<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Non-authoritative answer:<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Name:<span class=Apple-converted-space>&nbsp;</span><a style="COLOR: rgb(0,153,204); LINE-HEIGHT: normal; TEXT-DECORATION: none; WORD-WRAP: break-word" href="http://www.baidu.com/" target=_blank>www.baidu.com</a><br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Addresses: 202.108.250.249, 202.108.249.134<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　&gt; baidu.com<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Server: UnKnown<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Address: 192.168.1.254<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Non-authoritative answer:<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Name: baidu.com<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Address: 202.108.250.228<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　&gt; mp3.baidu.com<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Server: UnKnown<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Address: 192.168.1.254<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Non-authoritative answer:<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Name: mp3.baidu.com<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Address: 202.108.249.131<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　只有<a style="COLOR: rgb(0,153,204); LINE-HEIGHT: normal; TEXT-DECORATION: none; WORD-WRAP: break-word" href="http://www.baidu.com/" target=_blank>www.baidu.com</a>做了两台服务器的集群，频道都用了一台服务器做前台<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word"><br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　<strong style="FONT-WEIGHT: bold; LINE-HEIGHT: normal; FONT-STYLE: normal; TEXT-ALIGN: left; WORD-WRAP: break-word">5、一搜</strong><br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　&gt; yisou.com<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Server: UnKnown<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Address: 192.168.1.254<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Non-authoritative answer:<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Name: yisou.com<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Addresses: 202.165.102.114, 202.43.217.14, 202.43.217.15,202.43.217.16 202.43.217.17, 202.165.102.111, 202.165.102.112,202.165.102.113<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　&gt;<span class=Apple-converted-space>&nbsp;</span><a style="COLOR: rgb(0,153,204); LINE-HEIGHT: normal; TEXT-DECORATION: none; WORD-WRAP: break-word" href="http://www.yisou.com/" target=_blank>www.yisou.com</a><br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Server: UnKnown<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Address: 192.168.1.254<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Non-authoritative answer:<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Name:<span class=Apple-converted-space>&nbsp;</span><a style="COLOR: rgb(0,153,204); LINE-HEIGHT: normal; TEXT-DECORATION: none; WORD-WRAP: break-word" href="http://www.yisou.com/" target=_blank>www.yisou.com</a><br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Addresses: 202.43.217.17, 202.165.102.111, 202.165.102.112,202.165.102.113 202.165.102.114, 202.43.217.14, 202.43.217.15,202.43.217.16<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　&gt; mp3.yisou.com<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Server: UnKnown<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Address: 192.168.1.254<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Non-authoritative answer:<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Name:<span class=Apple-converted-space>&nbsp;</span><a style="COLOR: rgb(0,153,204); LINE-HEIGHT: normal; TEXT-DECORATION: none; WORD-WRAP: break-word" href="http://www.yisou.com/" target=_blank>www.yisou.com</a><br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Addresses: 202.165.102.113, 202.165.102.114, 202.43.217.14,202.43.217.15 202.43.217.16, 202.43.217.17, 202.165.102.111,22.165.102.112<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　Aliases: mp3.yisou.com<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　前台做了8台服务器的缓存集群，<a style="COLOR: rgb(0,153,204); LINE-HEIGHT: normal; TEXT-DECORATION: none; WORD-WRAP: break-word" href="http://www.yisou.com/" target=_blank>www.yisou.com</a>和 yisou.com以及mp3.yisou.com是用的同一个集群。<br style="LINE-HEIGHT: normal; WORD-WRAP: break-word"><br style="LINE-HEIGHT: normal; WORD-WRAP: break-word">　　通过前面的分析我们可以得到一个结论：sina和sohu使用了CDN与GSBL与DNS负载均衡技术，每个地区一组前台服务器群，网易，百度使用了DNS负载均衡技术，每个频道一组前台服务器，一搜使用了DNS负载技术，所有频道共用一组前台服务器集群。</span></span>
<img src ="http://www.cppblog.com/momoxiao/aggbug/120597.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/momoxiao/" target="_blank">小默</a> 2010-07-16 23:20 <a href="http://www.cppblog.com/momoxiao/archive/2010/07/16/120597.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>【转】HTTP Document API       //TOFILE</title><link>http://www.cppblog.com/momoxiao/archive/2010/05/11/115079.html</link><dc:creator>小默</dc:creator><author>小默</author><pubDate>Tue, 11 May 2010 02:20:00 GMT</pubDate><guid>http://www.cppblog.com/momoxiao/archive/2010/05/11/115079.html</guid><wfw:comment>http://www.cppblog.com/momoxiao/comments/115079.html</wfw:comment><comments>http://www.cppblog.com/momoxiao/archive/2010/05/11/115079.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/momoxiao/comments/commentRss/115079.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/momoxiao/services/trackbacks/115079.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 目录    HTTP Document API            Naming/Addressing        Documents                    Special Fields                 Working With Documents Over HTTP                    GET ...&nbsp;&nbsp;<a href='http://www.cppblog.com/momoxiao/archive/2010/05/11/115079.html'>阅读全文</a><img src ="http://www.cppblog.com/momoxiao/aggbug/115079.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/momoxiao/" target="_blank">小默</a> 2010-05-11 10:20 <a href="http://www.cppblog.com/momoxiao/archive/2010/05/11/115079.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>【转】http 错误编号大全</title><link>http://www.cppblog.com/momoxiao/archive/2010/04/26/113614.html</link><dc:creator>小默</dc:creator><author>小默</author><pubDate>Mon, 26 Apr 2010 09:16:00 GMT</pubDate><guid>http://www.cppblog.com/momoxiao/archive/2010/04/26/113614.html</guid><wfw:comment>http://www.cppblog.com/momoxiao/comments/113614.html</wfw:comment><comments>http://www.cppblog.com/momoxiao/archive/2010/04/26/113614.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/momoxiao/comments/commentRss/113614.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/momoxiao/services/trackbacks/113614.html</trackback:ping><description><![CDATA[<span style="FONT-FAMILY: simsun; COLOR: #464646" class=Apple-style-span>&nbsp;
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px"><font style="LINE-HEIGHT: 21px; WORD-WRAP: normal; WORD-BREAK: normal" face=宋体>　　状态行包含HTTP版本、状态代码、与状态代码对应的简短说明信息。在大多数情况下，除了Content-Type之外的所有应答头都是可选的。但Content-Type是必需的，它描述的是后面文档的MIME类型。虽然大多数应答都包含一个文档，但也有一些不包含，例如对HEAD请求的应答永远不会附带文档。有许多状态代码实际上用来标识一次失败的请求，这些应答也不包含文档（或只包含一个简短的错误信息说明）。</font></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px"><font style="LINE-HEIGHT: 21px; WORD-WRAP: normal; WORD-BREAK: normal" face=宋体>　&nbsp;<wbr>&nbsp;当用户试图通过 HTTP 访问一台正在运行 Internet 信息服务 （IIS） 的服务器上的内容时，IIS 返回一个表示该请求的状态的数字代码。状态代码可以指明具体请求是否已成功，还可以揭示请求失败的确切原因。</font></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px">&nbsp;<wbr></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px"><font style="LINE-HEIGHT: 21px; WORD-WRAP: normal; WORD-BREAK: normal" face=宋体>　　1xx - 信息提示</font></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px">&nbsp;<wbr></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px"><font style="LINE-HEIGHT: 21px; WORD-WRAP: normal; WORD-BREAK: normal" face=宋体>　　这些状态代码表示临时的响应。客户端在收到常规响应之前，应准备接收一个或多个 1xx 响应。 100 - 继续。</font></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px">&nbsp;<wbr></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px"><font style="LINE-HEIGHT: 21px; WORD-WRAP: normal; WORD-BREAK: normal" face=宋体>　　101 - 切换协议。</font></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px">&nbsp;<wbr></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px"><font style="LINE-HEIGHT: 21px; WORD-WRAP: normal; WORD-BREAK: normal" face=宋体>　　2xx - 成功</font></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px">&nbsp;<wbr></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px"><font style="LINE-HEIGHT: 21px; WORD-WRAP: normal; WORD-BREAK: normal" face=宋体>　　这类状态代码表明服务器成功地接受了客户端请求。</font></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px">&nbsp;<wbr></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px"><font style="LINE-HEIGHT: 21px; WORD-WRAP: normal; WORD-BREAK: normal" face=宋体>　　200 - 确定。客户端请求已成功。<br>　　201 - 已创建。<br>　　202 - 已接受。<br>　　203 - 非权威性信息。<br>　　204 - 无内容。<br>　　205 - 重置内容。<br>　　206 - 部分内容。</font></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px">&nbsp;<wbr></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px"><font style="LINE-HEIGHT: 21px; WORD-WRAP: normal; WORD-BREAK: normal" face=宋体>　　3xx - 重定向</font></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px">&nbsp;<wbr></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px"><font style="LINE-HEIGHT: 21px; WORD-WRAP: normal; WORD-BREAK: normal" face=宋体>　　客户端浏览器必须采取更多操作来实现请求。例如，浏览器可能不得不请求服务器上的不同的页面，或通过代理服务器重复该请求。</font></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px">&nbsp;<wbr></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px"><font style="LINE-HEIGHT: 21px; WORD-WRAP: normal; WORD-BREAK: normal" face=宋体>　　302 - 对象已移动。<br>　　304 - 未修改。<br>　　307 - 临时重定向。</font></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px">&nbsp;<wbr></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px"><font style="LINE-HEIGHT: 21px; WORD-WRAP: normal; WORD-BREAK: normal" face=宋体>　　4xx - 客户端错误</font></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px">&nbsp;<wbr></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px"><font style="LINE-HEIGHT: 21px; WORD-WRAP: normal; WORD-BREAK: normal" face=宋体>　　发生错误，客户端似乎有问题。例如，客户端请求不存在的页面，客户端未提供有效的身份验证信息。</font></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px">&nbsp;<wbr></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px"><font style="LINE-HEIGHT: 21px; WORD-WRAP: normal; WORD-BREAK: normal" face=宋体>　　400 - 错误的请求。<br>　　401 - 访问被拒绝。IIS 定义了许多不同的 401 错误，它们指明更为具体的错误原因。这些具体的错误代码在浏览器中显示，但不在 IIS 日志中显示：<br>　　401.1 - 登录失败。<br>　　401.2 - 服务器配置导致登录失败。<br>　　401.3 - 由于 ACL 对资源的限制而未获得授权。<br>　　401.4 - 筛选器授权失败。<br>　　401.5 - ISAPI/CGI 应用程序授权失败。<br>　　401.7 ? 访问被 Web 服务器上的 URL 授权策略拒绝。这个错误代码为 IIS 6.0 所专用。<br>　　403 - 禁止访问：IIS 定义了许多不同的 403 错误，它们指明更为具体的错误原因：<br>　　403.1 - 执行访问被禁止。<br>　　403.2 - 读访问被禁止。<br>　　403.3 - 写访问被禁止。<br>　　403.4 - 要求 SSL.<br>　　403.5 - 要求 SSL 128.<br>　　403.6 - IP 地址被拒绝。<br>　　403.7 - 要求客户端证书。<br>　　403.8 - 站点访问被拒绝。<br>　　403.9 - 用户数过多。<br>　　403.10 - 配置无效。<br>　　403.11 - 密码更改。<br>　　403.12 - 拒绝访问映射表。<br>　　403.13 - 客户端证书被吊销。<br>　　403.14 - 拒绝目录列表。<br>　　403.15 - 超出客户端访问许可。<br>　　403.16 - 客户端证书不受信任或无效。<br>　　403.17 - 客户端证书已过期或尚未生效。<br>　　403.18 - 在当前的应用程序池中不能执行所请求的 URL.这个错误代码为 IIS 6.0 所专用。<br>　　403.19 - 不能为这个应用程序池中的客户端执行 CGI.这个错误代码为 IIS 6.0 所专用。<br>　　403.20 - Passport 登录失败。这个错误代码为 IIS 6.0 所专用。<br>　　404 - 未找到。<br>　　404.0 -（无） ? 没有找到文件或目录。<br>　　404.1 - 无法在所请求的端口上访问 Web 站点。<br>　　404.2 - Web 服务扩展锁定策略阻止本请求。<br>　　404.3 - MIME 映射策略阻止本请求。<br>　　405 - 用来访问本页面的 HTTP 谓词不被允许（方法不被允许）<br>　　406 - 客户端浏览器不接受所请求页面的 MIME 类型。<br>　　407 - 要求进行代理身份验证。<br>　　412 - 前提条件失败。<br>　　413 ? 请求实体太大。<br>　　414 - 请求 URI 太长。<br>　　415 ? 不支持的媒体类型。<br>　　416 ? 所请求的范围无法满足。<br>　　417 ? 执行失败。<br>　　423 ? 锁定的错误。</font></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px">&nbsp;<wbr></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px"><font style="LINE-HEIGHT: 21px; WORD-WRAP: normal; WORD-BREAK: normal" face=宋体>　　5xx - 服务器错误</font></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px">&nbsp;<wbr></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px"><font style="LINE-HEIGHT: 21px; WORD-WRAP: normal; WORD-BREAK: normal" face=宋体>　　服务器由于遇到错误而不能完成该请求。</font></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px">&nbsp;<wbr></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px"><font style="LINE-HEIGHT: 21px; WORD-WRAP: normal; WORD-BREAK: normal" face=宋体>　　500 - 内部服务器错误。<br>　　500.12 - 应用程序正忙于在 Web 服务器上重新启动。<br>　　500.13 - Web 服务器太忙。<br>　　500.15 - 不允许直接请求 Global.asa.<br>　　500.16 ? UNC 授权凭据不正确。这个错误代码为 IIS 6.0 所专用。<br>　　500.18 ? URL 授权存储不能打开。这个错误代码为 IIS 6.0 所专用。<br>　　500.100 - 内部 ASP 错误。<br>　　501 - 页眉值指定了未实现的配置。<br>　　502 - Web 服务器用作网关或代理服务器时收到了无效响应。502.1 - CGI 应用程序超时。<br>　　502.2 - CGI 应用程序出错。<br>　　503 - 服务不可用。这个错误代码为 IIS 6.0 所专用。<br>　　504 - 网关超时。<br>　　505 - HTTP 版本不受支持。</font></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px">&nbsp;<wbr></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px"><font style="LINE-HEIGHT: 21px; WORD-WRAP: normal; WORD-BREAK: normal" face=宋体>　　常见的 HTTP 状态代码及其原因</font></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px">&nbsp;<wbr></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px"><font style="LINE-HEIGHT: 21px; WORD-WRAP: normal; WORD-BREAK: normal" face=宋体>　　200 - 成功。 此状态代码表示 IIS 已成功处理请求。<br>　　304 - 未修改。 客户端请求的文档已在其缓存中，文档自缓存以来尚未被修改过。客户端使用文档的缓存副本，而不从服务器下载文档。<br>　　401.1 - 登录失败。 登录尝试不成功，可能因为用户名或密码无效。<br>　　401.3 - 由于 ACL 对资源的限制而未获得授权。 这表示存在 NTFS 权限问题。即使您对试图访问的文件具备相应的权限，也可能发生此错误。<br>　　403.1 - 执行访问被禁止。</font></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px">&nbsp;<wbr></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px"><font style="LINE-HEIGHT: 21px; WORD-WRAP: normal; WORD-BREAK: normal" face=宋体>　　下面是导致此错误信息的两个常见原因：</font></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px">&nbsp;<wbr></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px"><font style="LINE-HEIGHT: 21px; WORD-WRAP: normal; WORD-BREAK: normal" face=宋体>　　您没有足够的执行许可。例如，如果试图访问的 ASP 页所在的目录权限设为&#8220;无&#8221;，或者，试图执行的 CGI 脚本所在的目录权限为&#8220;只允许脚本&#8221;，将出现此错误信息。若要修改执行权限，请在 Microsoft 管理控制台 （MMC） 中右击目录，然后依次单击属性和目录选项卡，确保为试图访问的内容设置适当的执行权限。<br>　　您没有将试图执行的文件类型的脚本映射设置为识别所使用的谓词（例如，GET 或 POST）。若要验证这一点，请在 MMC 中右击目录，依次单击属性、目录选项卡和配置，然后验证相应文件类型的脚本映射是否设置为允许所使用的谓词。<br>　　403.2 - 读访问被禁止。验证是否已将 IIS 设置为允许对目录进行读访问。另外，如果您正在使用默认文件，请验证该文件是否存在。<br>　　403.3 - 写访问被禁止。 验证 IIS 权限和 NTFS 权限是否已设置以便向该目录授予写访问权。<br>　　403.4 - 要求 SSL.禁用要求安全通道选项，或使用 HTTPS 代替 HTTP 来访问该页面。<br>　　403.5 - 要求 SSL 128.禁用要求 128 位加密选项，或使用支持 128 位加密的浏览器以查看该页面。<br>　　403.6 - IP 地址被拒绝。您已把您的服务器配置为拒绝访问您目前的 IP 地址。<br>　　403.7 - 要求客户端证书。您已把您的服务器配置为要求客户端身份验证证书，但您未安装有效的客户端证书。<br>　　403.8 - 站点访问被拒绝。您已为您用来访问服务器的域设置了域名限制。<br>　　403.9 - 用户数过多。与该服务器连接的用户数量超过了您设置的连接限制。</font></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px">&nbsp;<wbr></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px"><font style="LINE-HEIGHT: 21px; WORD-WRAP: normal; WORD-BREAK: normal" face=宋体>　　注意：Microsoft Windows 2000 Professional 和 Microsoft Windows XP Professional 自动设置了在 IIS 上最多 10 个连接的限制。您无法更改此限制。</font></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px">&nbsp;<wbr></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px"><font style="LINE-HEIGHT: 21px; WORD-WRAP: normal; WORD-BREAK: normal" face=宋体>　　403.12 - 拒绝访问映射表。 您要访问的页面要求提供客户端证书，但映射到您的客户端证书的用户 ID 已被拒绝访问该文件。<br>　　404 - 未找到。 发生此错误的原因是您试图访问的文件已被移走或删除。如果在安装 URLScan 工具之后，试图访问带有有限扩展名的文件，也会发生此错误。这种情况下，该请求的日志文件项中将出现&#8220;Rejected by URLScan&#8221;的字样。<br>　　500 - 内部服务器错误。 很多服务器端的错误都可能导致该错误信息。事件查看器日志包含更详细的错误原因。此外，您可以禁用友好 HTTP 错误信息以便收到详细的错误说明。<br>　　500.12 - 应用程序正在重新启动。 这表示您在 IIS 重新启动应用程序的过程中试图加载 ASP 页。刷新页面后，此信息即会消失。如果刷新页面后，此信息再次出现，可能是防病毒软件正在扫描 Global.asa 文件。<br>　　500-100.ASP - ASP 错误。 如果试图加载的 ASP 页中含有错误代码，将出现此错误信息。若要获得更确切的错误信息，请禁用友好 HTTP 错误信息。默认情况下，只会在默认 Web 站点上启用此错误信息。<br>　　502 - 网关错误。 如果试图运行的 CGI 脚本不返回有效的 HTTP 标头集，将出现此错误信息。</font></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px">&nbsp;<wbr></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px"><font style="LINE-HEIGHT: 21px; WORD-WRAP: normal; WORD-BREAK: normal" face=宋体>　　&#8220;IIS配置401错误&#8221;完美解决方案</font></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px">&nbsp;<wbr></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px"><font style="LINE-HEIGHT: 21px; WORD-WRAP: normal; WORD-BREAK: normal" face=宋体>　　&#8220;IIS配置401错误&#8221;完美解决方案（54powerman）</font></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px">&nbsp;<wbr></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px"><font style="LINE-HEIGHT: 21px; WORD-WRAP: normal; WORD-BREAK: normal" face=宋体>　　1、错误号401.1</font></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px">&nbsp;<wbr></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px"><font style="LINE-HEIGHT: 21px; WORD-WRAP: normal; WORD-BREAK: normal" face=宋体>　　症状：HTTP 错误 401.1 - 未经授权：访问由于凭据无效被拒绝。</font></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px">&nbsp;<wbr></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px"><font style="LINE-HEIGHT: 21px; WORD-WRAP: normal; WORD-BREAK: normal" face=宋体>　　分析：</font></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px">&nbsp;<wbr></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px"><font style="LINE-HEIGHT: 21px; WORD-WRAP: normal; WORD-BREAK: normal" face=宋体>　　由于用户匿名访问使用的账号（默认是IUSR_机器名）被禁用，或者没有权限访问计算机，将造成用户无法访问。</font></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px">&nbsp;<wbr></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px"><font style="LINE-HEIGHT: 21px; WORD-WRAP: normal; WORD-BREAK: normal" face=宋体>　　解决方案：</font></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px">&nbsp;<wbr></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px"><font style="LINE-HEIGHT: 21px; WORD-WRAP: normal; WORD-BREAK: normal" face=宋体>　　（1）查看IIS管理器中站点安全设置的匿名帐户是否被禁用，如果是，请尝试用以下办法启用：</font></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px">&nbsp;<wbr></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px"><font style="LINE-HEIGHT: 21px; WORD-WRAP: normal; WORD-BREAK: normal" face=宋体>　　控制面板-&gt;管理工具-&gt;计算机管理-&gt;本地用户和组，将IUSR_机器名账号启用。如果还没有解决，请继续下一步。</font></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px">&nbsp;<wbr></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px"><font style="LINE-HEIGHT: 21px; WORD-WRAP: normal; WORD-BREAK: normal" face=宋体>　　（2）查看本地安全策略中，IIS管理器中站点的默认匿名访问帐号或者其所属的组是否有通过网络访问服务器的权限，如果没有尝试用以下步骤赋予权限：</font></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px">&nbsp;<wbr></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px"><font style="LINE-HEIGHT: 21px; WORD-WRAP: normal; WORD-BREAK: normal" face=宋体>　　开始-&gt;程序-&gt;管理工具-&gt;本地安全策略-&gt;安全策略-&gt;本地策略-&gt;用户权限分配，双击&#8220;从网络访问此计算机&#8221;，添加IIS默认用户或者其所属的组。</font></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px">&nbsp;<wbr></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px"><font style="LINE-HEIGHT: 21px; WORD-WRAP: normal; WORD-BREAK: normal" face=宋体>　　注意：一般自定义 IIS默认匿名访问帐号都属于组，为了安全，没有特殊需要，请遵循此规则。</font></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px">&nbsp;<wbr></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px"><font style="LINE-HEIGHT: 21px; WORD-WRAP: normal; WORD-BREAK: normal" face=宋体>　　2、错误号401.2</font></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px">&nbsp;<wbr></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px"><font style="LINE-HEIGHT: 21px; WORD-WRAP: normal; WORD-BREAK: normal" face=宋体>　　症状：HTTP 错误 401.2 - 未经授权：访问由于服务器配置被拒绝。</font></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px">&nbsp;<wbr></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px"><font style="LINE-HEIGHT: 21px; WORD-WRAP: normal; WORD-BREAK: normal" face=宋体>　　原因：关闭了匿名身份验证</font></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px">&nbsp;<wbr></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px"><font style="LINE-HEIGHT: 21px; WORD-WRAP: normal; WORD-BREAK: normal" face=宋体>　　解决方案：</font></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px">&nbsp;<wbr></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px"><font style="LINE-HEIGHT: 21px; WORD-WRAP: normal; WORD-BREAK: normal" face=宋体>　　运行inetmgr，打开站点属性-&gt;目录安全性-&gt;身份验证和访问控制-&gt;选中&#8220;启用匿名访问&#8221;，输入用户名，或者点击&#8220;浏览&#8221;选择合法的用户，并两次输入密码后确定。</font></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px">&nbsp;<wbr></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px"><font style="LINE-HEIGHT: 21px; WORD-WRAP: normal; WORD-BREAK: normal" face=宋体>　　3、错误号：401.3</font></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px">&nbsp;<wbr></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px"><font style="LINE-HEIGHT: 21px; WORD-WRAP: normal; WORD-BREAK: normal" face=宋体>　　症状：HTTP 错误 401.3 - 未经授权：访问由于 ACL 对所请求资源的设置被拒绝。</font></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px">&nbsp;<wbr></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px"><font style="LINE-HEIGHT: 21px; WORD-WRAP: normal; WORD-BREAK: normal" face=宋体>　　原因：IIS匿名用户一般属于Guests组，而我们一般把存放网站的硬盘的权限只分配给administrators组，这时候按照继承原则，网站文件夹也只有administrators组的成员才能访问，导致IIS匿名用户访问该文件的NTFS权限不足，从而导致页面无法访问。</font></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px">&nbsp;<wbr></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px"><font style="LINE-HEIGHT: 21px; WORD-WRAP: normal; WORD-BREAK: normal" face=宋体>　　解决方案：</font></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px">&nbsp;<wbr></p>
<p style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px 0px 5px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; WORD-WRAP: normal; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WORD-BREAK: normal; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px"><font style="LINE-HEIGHT: 21px; WORD-WRAP: normal; WORD-BREAK: normal" face=宋体>　　给IIS匿名用户访问网站文件夹的权限，方法：进入该文件夹的安全选项，添加IIS匿名用户，并赋予相应权限，一般是读、写</font></p>
</span>
<img src ="http://www.cppblog.com/momoxiao/aggbug/113614.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/momoxiao/" target="_blank">小默</a> 2010-04-26 17:16 <a href="http://www.cppblog.com/momoxiao/archive/2010/04/26/113614.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>【转】HTTP方法</title><link>http://www.cppblog.com/momoxiao/archive/2010/04/22/113237.html</link><dc:creator>小默</dc:creator><author>小默</author><pubDate>Thu, 22 Apr 2010 02:56:00 GMT</pubDate><guid>http://www.cppblog.com/momoxiao/archive/2010/04/22/113237.html</guid><wfw:comment>http://www.cppblog.com/momoxiao/comments/113237.html</wfw:comment><comments>http://www.cppblog.com/momoxiao/archive/2010/04/22/113237.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cppblog.com/momoxiao/comments/commentRss/113237.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/momoxiao/services/trackbacks/113237.html</trackback:ping><description><![CDATA[<p>掌握HTTP虽然不是必须的，但是如果你知道它的工作原理，那么在学习JSP开发中的某些知识就可以易如反掌了。</p>
<p>一，HTTP协议详解之URL篇</p>
<p>http（超文本传输协议）是一个基于请求与响应模式的、无状态的、应用层的协议，常基于TCP的连接方式，HTTP1.1版本中给出一种持续连接的机制，绝大多数的Web开发，都是构建在HTTP协议之上的Web应用。</p>
<p>HTTP URL (URL是一种特殊类型的URI，包含了用于查找某个资源的足够的信息)的格式如下：<br><a href="http://host%5b%22:22/"><u><font color=#0066cc>http://host[":"port][abs_path</font></u></a>]<br>http表示要通过HTTP协议来定位网络资源；host表示合法的Internet主机域名或者IP地址；port指定一个端口号，为空则使用缺省端口 80；abs_path指定请求资源的URI；如果URL中没有给出abs_path，那么当它作为请求URI时，必须以&#8220;/&#8221;的形式给出，通常这个工作 浏览器自动帮我们完成。<br>eg:<br>1、输入：<a href="http://www.nit.edu.cn/"><u><font color=#0066cc>www.nit.edu.cn</font></u></a><br>浏览器自动转换成：<a href="http://www.nit.edu.cn/"><u><font color=#0066cc>http://www.nit.edu.cn/</font></u></a><br>2、http:192.168.0.116:8080/index.jsp</p>
<p>二、HTTP协议详解之请求篇</p>
<p>http请求由三部分组成，分别是：请求行、消息报头、请求正文</p>
<p>1、请求行以一个方法符号开头，以空格分开，后面跟着请求的URI和协议的版本，格式如下：Method Request-URI HTTP-Version CRLF&nbsp;&nbsp;<br>其中 Method表示请求方法；Request-URI是一个统一资源标识符；HTTP-Version表示请求的HTTP协议版本；CRLF表示回车和换行（除了作为结尾的CRLF外，不允许出现单独的CR或LF字符）。</p>
<p>请求方法（所有方法全为大写）有多种，各个方法的解释如下：<br>GET&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 请求获取Request-URI所标识的资源<br>POST&nbsp;&nbsp;&nbsp;&nbsp; 在Request-URI所标识的资源后附加新的数据<br>HEAD&nbsp;&nbsp;&nbsp;&nbsp; 请求获取由Request-URI所标识的资源的响应消息报头<br>PUT&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 请求服务器存储一个资源，并用Request-URI作为其标识<br>DELETE&nbsp;&nbsp; 请求服务器删除Request-URI所标识的资源<br>TRACE&nbsp;&nbsp;&nbsp; 请求服务器回送收到的请求信息，主要用于测试或诊断<br>CONNECT 保留将来使用<br>OPTIONS 请求查询服务器的性能，或者查询与资源相关的选项和需求<br>应用举例：<br>GET方法：在浏览器的地址栏中输入网址的方式访问网页时，浏览器采用GET方法向服务器获取资源，eg:GET /form.html HTTP/1.1 (CRLF)</p>
<p>POST方法要求被请求服务器接受附在请求后面的数据，常用于提交表单。<br>eg：POST /reg.jsp HTTP/ (CRLF)<br>Accept:image/gif,image/x-xbit,... (CRLF)<br>...<br>HOST:www.nit.edu.cn (CRLF)<br>Content-Length:22 (CRLF)<br>Connection:Keep-Alive (CRLF)<br>Cache-Control:no-cache (CRLF)<br>(CRLF)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //该CRLF表示消息报头已经结束，在此之前为消息报头<br>user=jeffrey&amp;pwd=1234&nbsp;&nbsp; //此行以下为提交的数据</p>
<p>HEAD方法与GET方法几乎是一样的，对于HEAD请求的回应部分来说，它的HTTP头部中包含的信息与通过GET请求所得到的信息是相同的。利 用这个方法，不必传输整个资源内容，就可以得到Request-URI所标识的资源的信息。该方法常用于测试超链接的有效性，是否可以访问，以及最近是否 更新。<br>2、请求报头后述<br>3、请求正文(略)</p>
<p>三，HTTP协议详解之响应篇</p>
<p>HTTP响应也是由三个部分组成，分别是：状态行、消息报头、响应正文<br>1、状态行格式如下：<br>HTTP-Version Status-Code Reason-Phrase CRLF<br>其中，HTTP-Version表示服务器HTTP协议的版本；Status-Code表示服务器发回的响应状态代码；Reason-Phrase表示状态代码的文本描述。<br>状态代码有三位数字组成，第一个数字定义了响应的类别，且有五种可能取值：<br>1xx：指示信息--表示请求已接收，继续处理<br>2xx：成功--表示请求已被成功接收、理解、接受<br>3xx：重定向--要完成请求必须进行更进一步的操作<br>4xx：客户端错误--请求有语法错误或请求无法实现<br>5xx：服务器端错误--服务器未能实现合法的请求<br>常见状态代码、状态描述、说明：<br>200 OK&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //客户端请求成功<br>400 Bad Request&nbsp;&nbsp; //客户端请求有语法错误，不能被服务器所理解<br>401 Unauthorized //请求未经授权，这个状态代码必须和WWW-Authenticate报&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //头域一起使用 <br>403 Forbidden&nbsp;&nbsp; //服务器收到请求，但是拒绝提供服务<br>404 Not Found&nbsp;&nbsp; //请求资源不存在，eg：输入了错误的URL<br>500 Internal Server Error //服务器发生不可预期的错误<br>503 Server Unavailable&nbsp;&nbsp; //服务器当前不能处理客户端的请求，一段时间后，&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //可能恢复正常<br>eg：HTTP/1.1 200 OK （CRLF）</p>
<p>2、响应报头后述</p>
<p>3、响应正文就是服务器返回的资源的内容</p>
<p>四，HTTP协议详解之消息报头篇</p>
<p>HTTP消息由客户端到服务器的请求和服务器到客户端的响应组成。请求消息和响应消息都是由开始行（对于请求消息，开始行就是请求行，对于响应消息，开始行就是状态行），消息报头（可选），空行（只有CRLF的行），消息正文（可选）组成。</p>
<p>HTTP消息报头包括普通报头、请求报头、响应报头、实体报头。<br>每一个报头域都是由名字+&#8220;：&#8221;+空格+值 组成，消息报头域的名字是大小写无关的。</p>
<p>1、普通报头<br>在普通报头中，有少数报头域用于所有的请求和响应消息，但并不用于被传输的实体，只用于传输的消息。<br>eg：<br>Cache-Control&nbsp;&nbsp;&nbsp; 用于指定缓存指令，缓存指令是单向的（响应中出现的缓存指令在请求中未必会出现），且是独立的（一个消息的缓存指令不会影响另一个消息处理的缓存机制），HTTP1.0使用的类似的报头域为Pragma。<br>请求时的缓存指令包括：no-cache（用于指示请求或响应消息不能缓存）、no-store、max-age、max-stale、min-fresh、only-if-cached;<br>响应时的缓存指令包括：public、private、no-cache、no-store、no-transform、must-revalidate、proxy-revalidate、max-age、s-maxage.<br>eg：为了指示IE浏览器（客户端）不要缓存页面，服务器端的JSP程序可以编写如下：response.sehHeader("Cache-Control","no-cache");<br>//response.setHeader("Pragma","no-cache");作用相当于上述代码，通常两者//合用<br>这句代码将在发送的响应消息中设置普通报头域：Cache-Control:no-cache</p>
<p><br>Date普通报头域表示消息产生的日期和时间</p>
<p>Connection普通报头域允许发送指定连接的选项。例如指定连接是连续，或者指定&#8220;close&#8221;选项，通知服务器，在响应完成后，关闭连接</p>
<p>2、请求报头<br>请求报头允许客户端向服务器端传递请求的附加信息以及客户端自身的信息。<br>常用的请求报头<br>Accept<br>Accept请求报头域用于指定客户端接受哪些类型的信息。eg：Accept：image/gif，表明客户端希望接受GIF图象格式的资源；Accept：text/html，表明客户端希望接受html文本。<br>Accept-Charset<br>Accept-Charset请求报头域用于指定客户端接受的字符集。eg：Accept-Charset:iso-8859-1,gb2312.如果在请求消息中没有设置这个域，缺省是任何字符集都可以接受。<br>Accept-Encoding<br>Accept-Encoding请求报头域类似于Accept，但是它是用于指定可接受的内容编码。eg：Accept-Encoding:gzip.deflate.如果请求消息中没有设置这个域服务器假定客户端对各种内容编码都可以接受。<br>Accept-Language<br>Accept-Language请求报头域类似于Accept，但是它是用于指定一种自然语言。eg：Accept-Language:zh-cn.如果请求消息中没有设置这个报头域，服务器假定客户端对各种语言都可以接受。<br>Authorization<br>Authorization请求报头域主要用于证明客户端有权查看某个资源。当浏览器访问一个页面时，如果收到服务器的响应代码为401（未授权），可以发送一个包含Authorization请求报头域的请求，要求服务器对其进行验证。<br>Host（发送请求时，该报头域是必需的）<br>Host请求报头域主要用于指定被请求资源的Internet主机和端口号，它通常从HTTP URL中提取出来的，eg：<br>我们在浏览器中输入：<a href="http://www.nit.edu.cn/index.html"><u><font color=#0066cc>http://www.nit.edu.cn/index.html</font></u></a><br>浏览器发送的请求消息中，就会包含Host请求报头域，如下：<br>Host：<a href="http://www.nit.edu.cn/"><u><font color=#0066cc>www.nit.edu.cn</font></u></a><br>此处使用缺省端口号80，若指定了端口号，则变成：Host：<a href="http://www.nit.edu.cn/"><u><font color=#0066cc>www.nit.edu.cn</font></u></a>:指定端口号<br>User-Agent<br>我们上网登陆论坛的时候，往往会看到一些欢迎信息，其中列出了你的操作系统的名称和版本，你所使用的浏览器的名称和版本，这往往让很多人感到很神奇，实际 上，服务器应用程序就是从User-Agent这个请求报头域中获取到这些信息。User-Agent请求报头域允许客户端将它的操作系统、浏览器和其它 属性告诉服务器。不过，这个报头域不是必需的，如果我们自己编写一个浏览器，不使用User-Agent请求报头域，那么服务器端就无法得知我们的信息 了。<br>请求报头举例：<br>GET /form.html HTTP/1.1 (CRLF)<br>Accept:image/gif,image/x-xbitmap,image/jpeg,application/x-shockwave-flash,application/vnd.ms-excel,application/vnd.ms-powerpoint,application/msword,*/* (CRLF)<br>Accept-Language:zh-cn (CRLF)<br>Accept-Encoding:gzip,deflate (CRLF)<br>If-Modified-Since:Wed,05 Jan 2007 11:21:25 GMT (CRLF)<br>If-None-Match:W/"80b1a4c018f3c41:8317" (CRLF)<br>User-Agent:Mozilla/4.0(compatible;MSIE6.0;Windows NT 5.0) (CRLF)<br>Host:www.nit.edu.cn (CRLF)<br>Connection:Keep-Alive (CRLF)<br>(CRLF)</p>
<p>3、响应报头<br>响应报头允许服务器传递不能放在状态行中的附加响应信息，以及关于服务器的信息和对Request-URI所标识的资源进行下一步访问的信息。<br>常用的响应报头<br>Location<br>Location响应报头域用于重定向接受者到一个新的位置。Location响应报头域常用在更换域名的时候。<br>Server<br>Server响应报头域包含了服务器用来处理请求的软件信息。与User-Agent请求报头域是相对应的。下面是<br>Server响应报头域的一个例子：<br>Server：Apache-Coyote/1.1<br>WWW-Authenticate<br>WWW-Authenticate响应报头域必须被包含在401（未授权的）响应消息中，客户端收到401响应消息时候，并发送Authorization报头域请求服务器对其进行验证时，服务端响应报头就包含该报头域。<br>eg：WWW-Authenticate:Basic realm="Basic Auth Test!"&nbsp;&nbsp; //可以看出服务器对请求资源采用的是基本验证机制。</p>
<p><br>4、实体报头<br>请求和响应消息都可以传送一个实体。一个实体由实体报头域和实体正文组成，但并不是说实体报头域和实体正文要在一起发送，可以只发送实体报头域。实体报头定义了关于实体正文（eg：有无实体正文）和请求所标识的资源的元信息。<br>常用的实体报头<br>Content-Encoding<br>Content-Encoding实体报头域被用作媒体类型的修饰符，它的值指示了已经被应用到实体正文的附加内容的编码，因而要获得Content- Type报头域中所引用的媒体类型，必须采用相应的解码机制。Content-Encoding这样用于记录文档的压缩方法，eg：Content- Encoding：gzip<br>Content-Language<br>Content-Language实体报头域描述了资源所用的自然语言。没有设置该域则认为实体内容将提供给所有的语言阅读<br>者。eg：Content-Language:da<br>Content-Length<br>Content-Length实体报头域用于指明实体正文的长度，以字节方式存储的十进制数字来表示。<br>Content-Type<br>Content-Type实体报头域用语指明发送给接收者的实体正文的媒体类型。eg：<br>Content-Type:text/html;charset=ISO-8859-1<br>Content-Type:text/html;charset=GB2312<br>Last-Modified<br>Last-Modified实体报头域用于指示资源的最后修改日期和时间。<br>Expires<br>Expires实体报头域给出响应过期的日期和时间。为了让代理服务器或浏览器在一段时间以后更新缓存中(再次访问曾访问过的页面时，直接从缓存中加载， 缩短响应时间和降低服务器负载)的页面，我们可以使用Expires实体报头域指定页面过期的时间。eg：Expires：Thu，15 Sep 2006 16:23:12 GMT<br>HTTP1.1的客户端和缓存必须将其他非法的日期格式（包括0）看作已经过期。eg：为了让浏览器不要缓存页面，我们也可以利用Expires实体报头域，设置为0，jsp中程序如下：response.setDateHeader("Expires","0");</p>
<p>五，利用telnet观察http协议的通讯过程</p>
<p>实验目的及原理：<br>利用MS的telnet工具，通过手动输入http请求信息的方式，向服务器发出请求，服务器接收、解释和接受请求后，会返回一个响应，该响应会在telnet窗口上显示出来，从而从感性上加深对http协议的通讯过程的认识。</p>
<p>实验步骤：</p>
<p>1、打开telnet<br>1.1 打开telnet<br>运行--&gt;cmd--&gt;telnet</p>
<p>1.2 打开telnet回显功能<br>set localecho</p>
<p>2、连接服务器并发送请求<br>2.1 open <a href="http://www.nit.edu.cn/"><u><font color=#0066cc>www.nit.edu.cn</font></u></a> 80&nbsp;&nbsp; //注意端口号不能省略</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp; HEAD /index.asp HTTP/1.0<br>&nbsp;&nbsp;&nbsp;&nbsp; Host:www.nit.edu.cn<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp; /*我们可以变换请求方法,请求桂林电子主页内容,输入消息如下*/<br>&nbsp;&nbsp;&nbsp;&nbsp; open <a href="http://www.nit.edu.cn/"><u><font color=#0066cc>www.nit.edu.cn</font></u></a> 80 <br>&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp; GET /index.asp HTTP/1.0&nbsp;&nbsp; //请求资源的内容<br>&nbsp;&nbsp;&nbsp;&nbsp; Host:www.nit.edu.cn&nbsp;&nbsp;&nbsp;</p>
<p>2.2 open <a href="http://www.sina.com.cn/"><u><font color=#0066cc>www.sina.com.cn</font></u></a> 80&nbsp;&nbsp; //在命令提示符号下直接输入telnet <a href="http://www.sina.com.cn/"><u><font color=#0066cc>www.sina.com.cn</font></u></a> 80<br>&nbsp;&nbsp;&nbsp;&nbsp; HEAD /index.asp HTTP/1.0<br>&nbsp;&nbsp;&nbsp;&nbsp; Host:www.sina.com.cn</p>
<p>3 实验结果：</p>
<p>3.1 请求信息2.1得到的响应是:</p>
<p>HTTP/1.1 200 OK&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //请求成功<br>Server: Microsoft-IIS/5.0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //web服务器<br>Date: Thu,08 Mar 200707:17:51 GMT<br>Connection: Keep-Alive&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>Content-Length: 23330<br>Content-Type: text/html<br>Expries: Thu,08 Mar 2007 07:16:51 GMT<br>Set-Cookie: ASPSESSIONIDQAQBQQQB=BEJCDGKADEDJKLKKAJEOIMMH; path=/<br>Cache-control: private</p>
<p>//资源内容省略</p>
<p>3.2 请求信息2.2得到的响应是:</p>
<p>HTTP/1.0 404 Not Found&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //请求失败<br>Date: Thu, 08 Mar 2007 07:50:50 GMT<br>Server: Apache/2.0.54 &lt;Unix&gt;<br>Last-Modified: Thu, 30 Nov 2006 11:35:41 GMT<br>ETag: "6277a-415-e7c76980"<br>Accept-Ranges: bytes<br>X-Powered-By: mod_xlayout_jh/0.0.1vhs.markII.remix<br>Vary: Accept-Encoding<br>Content-Type: text/html<br>X-Cache: MISS from zjm152-78.sina.com.cn<br>Via: 1.0 zjm152-78.sina.com.cn:80&lt;squid/2.6.STABLES-20061207&gt;<br>X-Cache: MISS from th-143.sina.com.cn<br>Connection: close</p>
<p><br>失去了跟主机的连接</p>
<p>按任意键继续...</p>
<p><br>4 .注意事项：1、出现输入错误，则请求不会成功。<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2、报头域不分大小写。<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3、更深一步了解HTTP协议，可以查看RFC2616，在<a href="http://www.letf.org/rfc"><u><font color=#0066cc>http://www.letf.org/rfc</font></u></a>上找到该文件。<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4、开发后台程序必须掌握http协议</p>
<img src ="http://www.cppblog.com/momoxiao/aggbug/113237.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/momoxiao/" target="_blank">小默</a> 2010-04-22 10:56 <a href="http://www.cppblog.com/momoxiao/archive/2010/04/22/113237.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>web容器</title><link>http://www.cppblog.com/momoxiao/archive/2010/04/15/112678.html</link><dc:creator>小默</dc:creator><author>小默</author><pubDate>Thu, 15 Apr 2010 08:34:00 GMT</pubDate><guid>http://www.cppblog.com/momoxiao/archive/2010/04/15/112678.html</guid><wfw:comment>http://www.cppblog.com/momoxiao/comments/112678.html</wfw:comment><comments>http://www.cppblog.com/momoxiao/archive/2010/04/15/112678.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/momoxiao/comments/commentRss/112678.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/momoxiao/services/trackbacks/112678.html</trackback:ping><description><![CDATA[实际上容器就是一个服务程序,在服务器一个端口就有一个提供相应服务的程序,而这个程序就是处理从客户端发出的请求,如java中的Tomcat容器,ASP的IIS或PWS都是这样的容器,一个服务器不止一个容器的.<br><br>
<hr>
字面上来讲:容器就是装东西的器皿.也就是你可以往里面放你想放的东西.一个Frame是一个容器,你可以往里面放Panel,Label,Button;一个Panel也是一个容器,你可以往里面放Label,Button等等.就像你可以往盆子里放盘子,往盘子里放水果一样.<br><br>
<hr>
容器就是放你jsp页面和servlet还有其他资源的那个环境。就象ASP的IIS一样的。主要作用么无非就是把客户端发来的HTTP请求 &nbsp; 打造成request对象，然后根据所请求的JSP或者servlet，将其结果用reponse这个对象以HTTP的格式发到客户端。让你的浏览器解释发来的HTML等格式的字符串（或2进制）。&nbsp;&nbsp;&nbsp;&nbsp; <br>
<img src ="http://www.cppblog.com/momoxiao/aggbug/112678.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/momoxiao/" target="_blank">小默</a> 2010-04-15 16:34 <a href="http://www.cppblog.com/momoxiao/archive/2010/04/15/112678.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>【zz】网络命令</title><link>http://www.cppblog.com/momoxiao/archive/2010/04/10/112190.html</link><dc:creator>小默</dc:creator><author>小默</author><pubDate>Sat, 10 Apr 2010 09:47:00 GMT</pubDate><guid>http://www.cppblog.com/momoxiao/archive/2010/04/10/112190.html</guid><wfw:comment>http://www.cppblog.com/momoxiao/comments/112190.html</wfw:comment><comments>http://www.cppblog.com/momoxiao/archive/2010/04/10/112190.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/momoxiao/comments/commentRss/112190.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/momoxiao/services/trackbacks/112190.html</trackback:ping><description><![CDATA[<p>&nbsp;</p>
<p><span style="FONT-SIZE: 12pt"><font face=宋体><strong><font style="FONT-SIZE: 12px">Ping</font></strong></font></span></p>
<p><font style="FONT-SIZE: 12px">Ping是个使用频率极高的实用程序，用于确定本地主机是否能与另一台主机交换（发送与接收）数据报。根据返回的信息，你就可以推断TCP/IP参数是否设置得正确以及运行是否正常。需要注意的是：成功地与另一台主机进行一次或两次数据报交换并不表示TCP/IP配置就是正确的，你必须执行大量的本地主机与远程主机的数据报交换，才能确信TCP/IP的正确性。</font></p>
<p><font style="FONT-SIZE: 12px">简单的说，Ping就是一个测试程序，如果Ping运行正确，你大体上就可以排除网络访问层、网卡、MODEM的输入输出线路、电缆和路由器等存在的故障，从而减小了问题的范围。但由于可以自定义所发数据报的大小及无休止的高速发送，Ping也被某些别有用心的人作为DDOS（拒绝服务攻击）的工具，前段时间Yahoo就是被黑客利用数百台可以高速接入互联网的电脑连续发送大量Ping数据报而瘫痪的。</font></p>
<p><font style="FONT-SIZE: 12px">按照缺省设置，Windows上运行的Ping命令发送4个ICMP（网间控制报文协议）回送请求，每个32字节数据，如果一切正常，你应能得到4个回送应答。</font></p>
<p><font style="FONT-SIZE: 12px">Ping能够以毫秒为单位显示发送回送请求到返回回送应答之间的时间量。如果应答时间短，表示数据报不必通过太多的路由器或网络连接速度比较快。Ping还能显示TTL（Time To Live存在时间）值，你可以通过TTL值推算一下数据包已经通过了多少个路由器：源地点TTL起始值（就是比返回TTL略大的一个2的乘方数）-返回时TTL值。例如，返回TTL值为119，那么可以推算数据报离开源地址的TTL起始值为128，而源地点到目标地点要通过9个路由器网段（128-119）；如果返回TTL值为246，TTL起始值就是256，源地点到目标地点要通过9个路由器网段。</font></p>
<p><font style="FONT-SIZE: 12px">通过Ping检测网络故障的典型次序</font></p>
<p><font style="FONT-SIZE: 12px">正常情况下，当你使用Ping命令来查找问题所在或检验网络运行情况时，你需要使用许多Ping命令，如果所有都运行正确，你就可以相信基本的连通性和配置参数没有问题；如果某些Ping命令出现运行故障，它也可以指明到何处去查找问题。下面就给出一个典型的检测次序及对应的可能故障：</font></p>
<p><font style="FONT-SIZE: 12px">ping 127.0.0.1--这个Ping命令被送到本地计算机的IP软件，该命令永不退出该计算机。如果没有做到这一点，就表示TCP/IP的安装或运行存在某些最基本的问题。</font></p>
<p><font style="FONT-SIZE: 12px">ping 本机IP--这个命令被送到你计算机所配置的IP地址，你的计算机始终都应该对该Ping命令作出应答，如果没有，则表示本地配置或安装存在问题。出现此问题时，局域网用户请断开网络电缆，然后重新发送该命令。如果网线断开后本命令正确，则表示另一台计算机可能配置了相同的IP地址。</font></p>
<p><font style="FONT-SIZE: 12px">ping 局域网内其他IP--这个命令应该离开你的计算机，经过网卡及网络电缆到达其他计算机，再返回。收到回送应答表明本地网络中的网卡和载体运行正确。但如果收到0个回送应答，那么表示子网掩码（进行子网分割时，将IP地址的网络部分与主机部分分开的代码）不正确或网卡配置错误或电缆系统有问题。</font></p>
<p><font style="FONT-SIZE: 12px">ping 网关IP--这个命令如果应答正确，表示局域网中的网关路由器正在运行并能够作出应答。</font></p>
<p><font style="FONT-SIZE: 12px">ping 远程IP--如果收到4个应答，表示成功的使用了缺省网关。对于拨号上网用户则表示能够成功的访问Internet（但不排除ISP的DNS会有问题）。</font></p>
<p><font style="FONT-SIZE: 12px">ping localhost--localhost是个作系统的网络保留名，它是127.0.0.1的别名，每太计算机都应该能够将该名字转换成该地址。如果没有做到这一带内，则表示主机文件（/Windows/host）中存在问题。</font></p>
<p><font style="FONT-SIZE: 12px">ping www.yahoo.com--对这个域名执行Pin ... 地址，通常是通过DNS 服务器如果这里出现故障，则表示DNS服务器的IP地址配置不正确或DNS服务器有故障（对于拨号上网用户，某些ISP已经不需要设置DNS服务器了）。顺便说一句：你也可以利用该命令实现域名对IP地址的转换功能。</font></p>
<p><font style="FONT-SIZE: 12px">如果上面所列出的所有Ping命令都能正常运行，那么你对你的计算机进行本地和远程通信的功能基本上就可以放心了。但是，这些命令的成功并不表示你所有的网络配置都没有问题，例如，某些子网掩码错误就可能无法用这些方法检测到。</font></p>
<p><font style="FONT-SIZE: 12px">Ping命令的常用参数选项<br>ping IP -t--连续对IP地址执行Ping命令，直到被用户以Ctrl+C中断。<br></font><font style="FONT-SIZE: 12px">ping IP -l 2000--指定Ping命令中的数据长度为2000字节，而不是缺省的32字节。</font></p>
<p><font style="FONT-SIZE: 12px">ping IP -n--执行特定次数的Ping命令。<br>Netstat Netstat用于显示与IP、TCP、UDP和ICMP协议相关的统计数据，一般用于检验本机各端口的网络连接情况。</font></p>
<p><font style="FONT-SIZE: 12px">如果你的计算机有时候接受到的数据报会导致出错数据删除或故障，你不必感到奇怪，TCP/IP可以容许这些类型的错误，并能够自动重发数据报。但如果累计的出错情况数目占到所接收的IP数据报相当大的百分比，或者它的数目正迅速增加，那么你就应该使用Netstat查一查为什么会出现这些情况了。</font></p>
<p><font style="FONT-SIZE: 12px">netstat 的一些常用选项：</font></p>
<p><font style="FONT-SIZE: 12px">netstat -s--本选项能够按照各个协议分别显示其统计数据。如果你的应用程序（如Web浏览器）运行速度比较慢，或者不能显示Web页之类的数据，那么你就可以用本选项来查看一下所显示的信息。你需要仔细查看统计数据的各行，找到出错的关键字，进而确定问题所在。</font></p>
<p><font style="FONT-SIZE: 12px">netstat -e--本选项用于显示关于以太网的统计数据。它列出的项目包括传送的数据报的总字节数、错误数、删除数、数据报的数量和广播的数量。这些统计数据既有发送的数据报数量，也有接收的数据报数量。这个选项可以用来统计一些基本的网络流量）。</font></p>
<p><font style="FONT-SIZE: 12px">netstat -r--本选项可以显示关于路由表的信息，类似于后面所讲使用route print命令时看到的信息。除了显示有效路由外，还显示当前有效的连接。</font></p>
<p><font style="FONT-SIZE: 12px">netstat -a--本选项显示一个所有的有效连接信息列表，包括已建立的连接（ESTABLISHED），也包括监听连接请求（LISTENING）的那些连接。</font></p>
<p><font style="FONT-SIZE: 12px">netstat -n--显示所有已建立的有效连接。</font></p>
<p><font style="FONT-SIZE: 12px">Netstat的妙用</font></p>
<p><font style="FONT-SIZE: 12px">经常上网的人一般都使用ICQ的，不知道你有没有被一些讨厌的人骚扰得不敢上线，想投诉却又不知从和下手？其实，你只要知道对方的IP，就可以向他所属的ISP投诉了。但怎样才能通过ICQ知道对方的IP呢？如果对方在设置ICQ时选择了不显示IP地址，那你是无法在信息栏中看到的。其实，你只需要通过Netstat就可以很方便的做到这一点：当他通过ICQ或其他的工具与你相连时（例如你给他发一条ICQ信息或他给你发一条信息），你立刻在DOS Prompt下输入netstat -n或netstat -a就可以看到对方上网时所用的IP或ISP域名了。甚至连所用Port都完全暴露了，如果你想给他一些教训，这些信息已经足够&#8230;&#8230;</font></p>
<p><strong><font style="FONT-SIZE: 12px">IPConfig</font></strong></p>
<p><font style="FONT-SIZE: 12px">IPConfig实用程序和它的等价图形用户界面——Windows 95/98中的WinIPCfg可用于显示当前的TCP/IP配置的设置值。这些信息一般用来检验人工配置的TCP/IP设置是否正确。但是，如果你的计算机和所在的局域网使用了动态主机配置协议（Dynamic Host Configuration Protocol，DHCP--Windows NT下的一种把较少的IP地址分配给较多主机使用的协议，类似于拨号上网的动态IP分配），这个程序所显示的信息也许更加实用。这时，IPConfig可以让你了解你的计算机是否成功的租用到一个IP地址，如果租用到则可以了解它目前分配到的是什么地址。了解计算机当前的IP地址、子网掩码和缺省网关实际上是进行测试和故障分析的必要项目。</font></p>
<p><font style="FONT-SIZE: 12px">最常用的选项：</font></p>
<p><font style="FONT-SIZE: 12px">ipconfig--当使用IPConfig时不带任何参数选项，那么它为每个已经配置了的接口显示IP地址、子网掩码和缺省网关值</font></p>
<p><font style="FONT-SIZE: 12px">ipconfig /all--当使用all选项时，IPConfig能为DNS和WINS服务器显示它已配置且所要使用的附加信息（如IP地址等），并且显示内置于本地网卡中的物理地址（MAC）。如果IP地址是从DHCP服务器租用的，IPConfig将显示DHCP服务器的IP地址和租用地址预计失效的日期（有关DHCP服务器的相关内容请详见其他有关NT服务器的书籍或询问你的网管），其输出信息见图6的下半部分。</font></p>
<p><font style="FONT-SIZE: 12px">ipconfig /release和ipconfig /renew--这是两个附加选项，只能在向DHCP服务器租用其IP地址的计算机上起作用。如果你输入ipconfig /release，那么所有接口的租用IP地址便重新交付给DHCP服务器（归还IP地址）。如果你输入ipconfig /renew，那么本地计算机便设法与DHCP服务器取得联系，并租用一个IP地址。请注意，大多数情况下网卡将被重新赋予和以前所赋予的相同的IP地址。</font></p>
<p><font style="FONT-SIZE: 12px">如果你使用的是Windows 95/98，那么你应该更习惯使用winipcfg而不是ipconfig，因为它是一个图形用户界面，而且所显示的信息与ipconfig相同，并且也提供发布和更新动态IP地址的选项如果你购买了Windows NT Resource Kit（NT资源包），那么Windows NT也包含了一个图形替代界面，该实用程序的名字是wntipcfg，和Windows 95/98的winipcfg类似。</font></p>
<p><font style="FONT-SIZE: 12px"><strong>ARP</strong>（地址转换协议）</font></p>
<p><font style="FONT-SIZE: 12px">ARP是一个重要的TCP/IP协议，并且用于确定对应IP地址的网卡物理地址。实用arp命令，你能够查看本地计算机或另一台计算机的ARP高速缓存中的当前内容。此外，使用arp命令，也可以用人工方式输入静态的网卡物理/IP地址对，你可能会使用这种方式为缺省网关和本地服务器等常用主机进行这项作，有助于减少网络上的信息量。</font></p>
<p><font style="FONT-SIZE: 12px">按照缺省设置，ARP高速缓存中的项目是动态的，每当发送一个指定地点的数据报且高速缓存中不存在当前项目时，ARP便会自动添加该项目。一旦高速缓存的项目被输入，它们就已经开始走向失效状态。例如，在Windows NT网络中，如果输入项目后不进一步使用，物理/IP地址对就会在2至10分钟内失效。因此，如果ARP高速缓存中项目很少或根本没有时，请不要奇怪，通过另一台计算机或路由器的ping命令即可添加。所以，需要通过arp命令查看高速缓存中的内容时，请最好先ping 此台计算机（不能是本机发送ping命令）。</font></p>
<p><font style="FONT-SIZE: 12px">常用命令选项：</font></p>
<p><font style="FONT-SIZE: 12px">arp -a或arp -g--用于查看高速缓存中的所有项目。-a和-g参数的结果是一样的，多年来-g一直是UNIX平台上用来显示ARP高速缓存中所有项目的选项，而Windows用的是arp -a（-a可被视为all，即全部的意思），但它也可以接受比较传统的-g选项。</font></p>
<p><font style="FONT-SIZE: 12px">arp -a IP--如果你有多个网卡，那么使用arp -a加上接口的IP地址，就可以只显示与该接口相关的ARP缓存项目。</font></p>
<p><font style="FONT-SIZE: 12px">arp -s IP 物理地址——你可以向ARP高速缓存中人工输入一个静态项目。该项目在计算机引导过程中将保持有效状态，或者在出现错误时，人工配置的物理地址将自动更新该项目。</font></p>
<p><font style="FONT-SIZE: 12px">arp -d IP--使用本命令能够人工删除一个静态项目。</font></p>
<p><font style="FONT-SIZE: 12px">看到这里，你也许已经有些累了&#8230;&#8230;其实对于一般用户来说也已经足够——你可以用ipconfig和ping命令来查看自己的网络配置并判断是否正确、可以用netstat查看别人与你所建立的连接并找出ICQ使用者所隐藏的IP信息、可以用arp查看网卡的MAC地址——这些已足已让你丢掉菜鸟的头衔。如果你并不满足，那就&#8220;硬着头皮&#8221;（下面的内容可能有些枯燥）继续Follow me......</font></p>
<p><strong><font style="FONT-SIZE: 12px">Tracert</font></strong></p>
<p><font style="FONT-SIZE: 12px">当数据报从你的计算机经过多个网关传送到目的地时，Tracert命令可以用来跟踪数据报使用的路由（路径）。该实用程序跟踪的路径是源计算机到目的地的一条路径，不能保证或认为数据报总遵循这个路径。如果你的配置使用DNS，那么你常常会从所产生的应答中得到城市、地址和常见通信公司的名字。Tracert是一个运行得比较慢的命令（如果你指定的目标地址比较远），每个路由器你大约需要给它15秒钟<br>Tracert的使用很简单，只需要在tracert后面跟一个IP地址或URL，Tracert会进行相应的域名转换的。Tracert一般用来检测故障的位置，你可以用tracert IP在哪个环节上出了问题，虽然还是没有确定是什么问题，但它已经告诉了我们问题所在的地方，你也就可以很有把握的告诉别人——某某出了问题。</font></p>
<p><strong><font style="FONT-SIZE: 12px">Route</font></strong></p>
<p><font style="FONT-SIZE: 12px">大多数主机一般都是驻留在只连接一台路由器的网段上。由于只有一台路由器，因此不存在使用哪一台路由器将数据报发表到远程计算机上去的问题，该路由器的IP地址可作为该网段上所有计算机的缺省网关来输入。</font></p>
<p><font style="FONT-SIZE: 12px">但是，当网络上拥有两个或多个路由器时，你就不一定想只依赖缺省网关了。实际上你可能想让你的某些远程IP地址通过某个特定的路由器来传递，而其他的远程IP则通过另一个路由器来传递。</font></p>
<p><font style="FONT-SIZE: 12px">在这种情况下，你需要相应的路由信息，这些信息储存在路由表中，每个主机和每个路由器都配有自己独一无二的路由表。大多数路由器使用专门的路由协议来交换和动态更新路由器之间的路由表。但在有些情况下，必须人工将项目添加到路由器和主机上的路由表中。Route就是用来显示、人工添加和修改路由表项目的。</font></p>
<p><font style="FONT-SIZE: 12px">一般使用选项：</font></p>
<p><font style="FONT-SIZE: 12px">route print--本命令用于显示路由表中的当前项目，在单路由器网段上的输出结果如图12，由于用IP地址配置了网卡，因此所有的这些项目都是自动添加的。<br>route add--使用本命令，可以将信路由项目添加给路由表。例如，如果要设定一个到目的网络209.98.32.33的路由，其间要经过5个路由器网段，首先要经过本地网络上的一个路由器，器IP为202.96.123.5，子网掩码为255.255.255.224，那么你应该输入以下命令：</font></p>
<p><font style="FONT-SIZE: 12px">route add 209.98.32.33 mask 255.255.255.224 202.96.123.5 metric 5</font></p>
<p><font style="FONT-SIZE: 12px">route change--你可以使用本命令来修改数据的传输路由，不过，你不能使用本命令来改变数据的目的地。下面这个例子可以将数据的路由改到另一个路由器，它采用一条包含3个网段的更直的路径：<br>route add 209.98.32.33 mask 255.255.255.224 202.96.123.250 metric 3<br>route delete--使用本命令可以从路由表中删除路由。例如：route delete 209.98.32.33</font></p>
<p><strong><font style="FONT-SIZE: 12px">NBTStat</font></strong></p>
<p><font style="FONT-SIZE: 12px">NBTStat（TCP/IP上的NetBIOS统计数据）实用程序用于提供关于关于NetBIOS的统计数据。运用NetBIOS，你可以查看本地计算机或远程计算机上的NetBIOS名字表格。</font></p>
<p><font style="FONT-SIZE: 12px">常用选项：</font></p>
<p><font style="FONT-SIZE: 12px">nbtstat -n--显示寄存在本地的名字和服务程序<br>nbtstat -c--本命令用于显示NetBIOS名字高速缓存的内容。NetBIOS名字高速缓存用于寸放与本计算机最近进行通信的其他计算机的NetBIOS名字和IP地址对。<br>nbtstat -r--本命令用于清除和重新加载NetBIOS名字高速缓存。<br>nbtstat -a IP--通过IP显示另一台计算机的物理地址和名字列表，你所显示的内容就像对方计算机自己运行nbtstat -n一样<br>nbtstat -s IP--显示实用其IP地址的另一台计算机的NetBIOS连接表。</font></p>
<p><strong><font style="FONT-SIZE: 12px">Net</font></strong></p>
<p><font style="FONT-SIZE: 12px">Net命令有很多函数用于实用和核查计算机之间的NetBIOS连接。这里我只介绍最常用的两个：net view和net use。</font></p>
<p><font style="FONT-SIZE: 12px">net view UNC--运用此命令，你可以查看目标服务器上的共享点名字。任何局域网里的人都可以发出此命令，而且不需要提供用户ID或口令。UNC名字总是以\开头，后面跟随目标计算机的名字。例如，net view \\lx就是查看主机名为lx的计算机的共享点（见图15）。</font></p>
<p><font style="FONT-SIZE: 12px">net use 本地盘符目标计算机共享点——本命令用于建立或取消到达特定共享点的映像驱动器的连接（如果需要，你必须提供用户ID或口令）。例如，你输入net use f: \lxmp3就是将映像驱动器F:连接到\lxmp3共享点上，今后你直接访问F:就可以访问\lxmp3共享点，这和你右击&#8220;我的电脑&#8221;选择映射网络驱动器类似。</font></p>
<img src ="http://www.cppblog.com/momoxiao/aggbug/112190.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/momoxiao/" target="_blank">小默</a> 2010-04-10 17:47 <a href="http://www.cppblog.com/momoxiao/archive/2010/04/10/112190.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>【zz】端口列表 </title><link>http://www.cppblog.com/momoxiao/archive/2010/04/10/112189.html</link><dc:creator>小默</dc:creator><author>小默</author><pubDate>Sat, 10 Apr 2010 09:36:00 GMT</pubDate><guid>http://www.cppblog.com/momoxiao/archive/2010/04/10/112189.html</guid><wfw:comment>http://www.cppblog.com/momoxiao/comments/112189.html</wfw:comment><comments>http://www.cppblog.com/momoxiao/archive/2010/04/10/112189.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/momoxiao/comments/commentRss/112189.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/momoxiao/services/trackbacks/112189.html</trackback:ping><description><![CDATA[　　端口可分为3大类： <br>　　1） <strong>公认端口</strong>（Well Known Ports）：从<strong>0到1023</strong>，它们<strong>紧密绑定</strong>于一些服务。通常这些端口的通讯明确表明了某种服务的协议。例如：80端口实际上总是HTTP通讯。 <br>　　2） <strong>注册端口</strong>（Registered Ports）：从1024到49151。它们<strong>松散地绑定</strong>于一些服务。也就是说有许多服务绑定于这些端口，这些端口同样用于许多其它目的。例如：许多系统处理动态端口从1024左右开始。 <br>　　3） <strong>动态和/或私有端口</strong>（Dynamic and/or Private Ports）：从49152到65535。理论上，不应为服务分配这些端口。实际上，机器通常从1024起分配动态端口。但也有例外：SUN的RPC端口从32768开始。 <br><br>　　本节讲述通常TCP/UDP端口扫描在防火墙记录中的信息。记住：并不存在所谓ICMP端口。如果你对解读ICMP数据感兴趣，请参看本文的其它部分。 <br><br>　　0 通常用于分析操作系统。这一方法能够工作是因为在一些系统中&#8220;0&#8221;是无效端口，当你试图使用一种通常的闭合端口连接它时将产生不同的结果。一种典型的扫描：使用IP地址为0.0.0.0，设置ACK位并在以太网层广播。<br><br>　　1 tcpmux 这显示有人在寻找SGI Irix机器。Irix是实现tcpmux的主要提供者，缺省情况下tcpmux在这种系统中被打开。Iris机器在发布时含有几个缺省的无密码的帐户，如lp, guest, uucp, nuucp, demos, tutor, diag, EZsetup, OutOfBox, 和4Dgifts。许多管理员安装后忘记删除这些帐户。因此Hacker们在Internet上搜索tcpmux并利用这些帐户。 <br><br>　　7 Echo 你能看到许多人们搜索Fraggle放大器时，发送到x.x.x.0和x.x.x.255的信息。 <br>　　常见的一种DoS攻击是echo循环（echo-loop），攻击者伪造从一个机器发送到另一个机器的UDP数据包，而两个机器分别以它们最快的方式回应这些数据包。（参见Chargen） <br>　　另一种东西是由DoubleClick在词端口建立的TCP连接。有一种产品叫做&#8220;Resonate Global Dispatch&#8221;，它与DNS的这一端口连接以确定最近的路由。 <br>　　Harvest/squid cache将从3130端口发送UDP echo：&#8220;如果将cache的source_ping on选项打开，它将对原始主机的UDP echo端口回应一个HIT reply。&#8221;这将会产生许多这类数据包。 <br><br>　　11 sysstat 这是一种UNIX服务，它会列出机器上所有正在运行的进程以及是什么启动了这些进程。这为入侵者提供了许多信息而威胁机器的安全，如暴露已知某些弱点或帐户的程序。这与UNIX系统中&#8220;ps&#8221;命令的结果相似<br>　　再说一遍：ICMP没有端口，ICMP port 11通常是ICMP type=11 <br><br>　　19 chargen 这是一种仅仅发送字符的服务。UDP版本将会在收到UDP包后回应含有垃圾字符的包。TCP连接时，会发送含有垃圾字符的数据流知道连接关闭。Hacker利用IP欺骗可以发动DoS攻击。伪造两个chargen服务器之间的UDP包。由于服务器企图回应两个服务器之间的无限的往返数据通讯一个chargen和echo将导致服务器过载。同样fraggle DoS攻击向目标地址的这个端口广播一个带有伪造受害者IP的数据包，受害者为了回应这些数据而过载。<br><br>　　21 ftp 最常见的攻击者用于寻找打开&#8220;anonymous&#8221;的ftp服务器的方法。这些服务器带有可读写的目录。Hackers或Crackers 利用这些服务器作为传送warez (私有程序) 和pr0n(故意拼错词而避免被搜索引擎分类)的节点。 <br><br>　　22 ssh PcAnywhere建立TCP和这一端口的连接可能是为了寻找ssh。这一服务有许多弱点。如果配置成特定的模式，许多使用RSAREF库的版本有不少漏洞。（建议在其它端口运行ssh） <br>　　还应该注意的是ssh工具包带有一个称为make-ssh-known-hosts的程序。它会扫描整个域的ssh主机。你有时会被使用这一程序的人无意中扫描到。 <br>　　UDP（而不是TCP）与另一端的5632端口相连意味着存在搜索pcAnywhere的扫描。5632（十六进制的0x1600）位交换后是0x0016（使进制的22）。 <br><br>　　23 Telnet 入侵者在搜索远程登陆UNIX的服务。大多数情况下入侵者扫描这一端口是为了找到机器运行的操作系统。此外使用其它技术，入侵者会找到密码。 <br><br>　　25 smtp 攻击者（spammer）寻找SMTP服务器是为了传递他们的spam。入侵者的帐户总被关闭，他们需要拨号连接到高带宽的e-mail服务器上，将简单的信息传递到不同的地址。SMTP服务器（尤其是sendmail）是进入系统的最常用方法之一，因为它们必须完整的暴露于Internet且邮件的路由是复杂的（暴露+复杂=弱点）。<br><br>
<hr>
<br>　　一些端口常常会被黑客利用，还会被一些木马病毒利用，对计算机系统进行攻击，以下是计算机端口的介绍以及防止被黑客攻击的简要办法。 <br>　　8080端口 <br>　　端口说明：8080端口同80端口，是被用于WWW代理服务的，可以实现网页浏览，经常在访问某个网站或使用代理服务器的时候，会加上&#8220;:8080&#8221;端口号，比如<a href="http://www.cce.com.cn:8080/">http://www.cce.com.cn:8080</a>。 <br>　　端口漏洞：8080端口可以被各种病毒程序所利用，比如Brown Orifice（BrO）特洛伊木马病毒可以利用8080端口完全遥控被感染的计算机。另外，RemoConChubo，RingZero木马也可以利用该端口进行攻击。 <br>　　操作建议：一般我们是使用80端口进行网页浏览的，为了避免病毒的攻击，我们可以关闭该端口。 <br>　　端口：21 <br>　　服务：FTP <br>　　说明：FTP服务器所开放的端口，用于上传、下载。最常见的攻击者用于寻找打开anonymous的FTP服务器的方法。这些服务器带有可读写的目录。木马Doly Trojan、Fore、Invisible FTP、WebEx、WinCrash和Blade Runner所开放的端口。 <br>　　端口：22 <br>　　服务：Ssh <br>　　说明：PcAnywhere建立的TCP和这一端口的连接可能是为了寻找ssh。这一服务有许多弱点，如果配置成特定的模式，许多使用RSAREF库的版本就会有不少的漏洞存在。 <br>　　端口：23 <br>　　服务：Telnet <br>　　说明：远程登录，入侵者在搜索远程登录UNIX的服务。大多数情况下扫描这一端口是为了找到机器运行的操作系统。还有使用其他技术，入侵者也会找到密码。木马Tiny Telnet Server就开放这个端口。 <br>　　端口：25 <br>　　服务：SMTP <br>　　说明：SMTP服务器所开放的端口，用于发送邮件。入侵者寻找SMTP服务器是为了传递他们的SPAM。入侵者的帐户被关闭，他们需要连接到高带宽的E-MAIL服务器上，将简单的信息传递到不同的地址。木马Antigen、Email Password Sender、Haebu Coceda、Shtrilitz Stealth、WinPC、WinSpy都开放这个端口。 <br>　　端口：80 <br>　　服务：HTTP <br>　　说明：用于网页浏览。木马Executor开放此端口。 <br>　　端口：102 <br>　　服务：Message transfer agent(MTA)-X.400 over TCP/IP <br>　　说明：消息传输代理。 <br>　　端口：110 <br>　　服务：Post Office Protocol -Version3 <br>　　说明：POP3服务器开放此端口，用于接收邮件，客户端访问服务器端的邮件服务。POP3服务有许多公认的弱点。关于用户名和密码交 换缓冲区溢出的弱点至少有20个，这意味着入侵者可以在真正登陆前进入系统。成功登陆后还有其他缓冲区溢出错误。 <br>　　端口：111 <br>　　服务：SUN公司的RPC服务所有端口 <br>　　说明：常见RPC服务有rpc.mountd、NFS、rpc.statd、rpc.csmd、rpc.ttybd、amd等 <br>　　端口：119 <br>　　服务：Network News Transfer Protocol <br>　　说明：NEWS新闻组传输协议，承载USENET通信。这个端口的连接通常是人们在寻找USENET服务器。多数ISP限制，只有他们的客户才能访问他们的新闻组服务器。打开新闻组服务器将允许发/读任何人的帖子，访问被限制的新闻组服务器，匿名发帖或发送SPAM。 <br>　　端口：135 <br>　　服务：Location Service <br>　　说明：Microsoft在这个端口运行DCE RPC end-point mapper为它的DCOM服务。这与UNIX 111端口的功能很相似。使用DCOM和RPC的服务利用计算机上的end-point mapper注册它们的位置。远端客户连接到计算机时，它们查找end-point mapper找到服务的位置。HACKER扫描计算机的这个端口是为了找到这个计算机上运行Exchange Server吗？什么版本？还有些DOS攻击直接针对这个端口。 <br>　　端口：137、138、139 <br>　　服务：NETBIOS Name Service <br>　　说明：其中137、138是UDP端口，当通过网上邻居传输文件时用这个端口。而139端口：通过这个端口进入的连接试图获得NetBIOS/SMB服务。这个协议被用于windows文件和打印机共享和SAMBA。还有WINS Regisrtation也用它。 <br>　　端口：161 <br>　　服务：SNMP <br>　　说明：SNMP允许远程管理设备。所有配置和运行信息的储存在数据库中，通过SNMP可获得这些信息。许多管理员的错误配置将被暴露在Internet。Cackers将试图使用默认的密码public、private访问系统。他们可能会试验所有可能的组合。SNMP包可能会被错误的指向用户的网络 <br>　　端口：177 <br>　　服务：X Display Manager Control Protocol <br>　　说明：许多入侵者通过它访问X-windows操作台，它同时需要打开6000端口。 <br>　　端口：389 <br>　　服务：LDAP、ILS <br>　　说明：轻型目录访问协议和NetMeeting Internet Locator Server共用这一端口。 <br><br>
<hr>
<br>常见端口列表 <br>　　TCP端口 <br>　　TCP 1=TCP Port Service Multiplexer <br>　　TCP 2=Death <br>　　TCP 5=Remote Job Entry,yoyo <br>　　TCP 7=Echo <br>　　TCP 11=Skun <br>　　TCP 12=Bomber <br>　　TCP 16=Skun <br>　　TCP 17=Skun <br>　　TCP 18=消息传输协议,skun <br>　　TCP 19=Skun <br>　　TCP 20=FTP Data,Amanda <br>　　TCP 21=文件传输,Back Construction,Blade Runner,Doly Trojan,Fore,FTP trojan,Invisible FTP,Larva, WebEx,WinCrash <br>　　TCP 22=远程登录协议 <br>　　TCP 23=远程登录(Telnet),Tiny Telnet Server (= TTS) <br>　　TCP 25=电子邮件(SMTP),Ajan,Antigen,Email Password Sender,Happy 99,Kuang2,ProMail trojan,Shtrilitz,Stealth,Tapiras,Terminator,WinPC,WinSpy,Haebu Coceda <br>　　TCP 27=Assasin <br>　　TCP 28=Amanda <br>　　TCP 29=MSG ICP <br>　　TCP 30=Agent 40421 <br>　　TCP 31=Agent 31,Hackers Paradise,Masters Paradise,Agent 40421 <br>　　TCP 37=Time,ADM worm <br>　　TCP 39=SubSARI <br>　　TCP 41=DeepThroat,Foreplay <br>　　TCP 42=Host Name Server <br>　　TCP 43=WHOIS <br>　　TCP 44=Arctic <br>　　TCP 48=DRAT <br>　　TCP 49=主机登录协议 <br>　　TCP 50=DRAT <br>　　TCP 51=IMP Logical Address Maintenance,Fuck Lamers Backdoor <br>　　TCP 52=MuSka52,Skun <br>　　TCP 53=DNS,Bonk (DOS Exploit) <br>　　TCP 54=MuSka52 <br>　　TCP 58=DMSetup <br>　　TCP 59=DMSetup <br>　　TCP 63=whois++ <br>　　TCP 64=Communications Integrator <br>　　TCP 65=TACACS-Database Service <br>　　TCP 66=Oracle SQL*NET,AL-Bareki <br>　　TCP 67=Bootstrap Protocol Server <br>　　TCP 68=Bootstrap Protocol Client <br>　　TCP 69=W32.Evala.Worm,BackGate Kit,Nimda,Pasana,Storm,Storm worm,Theef,Worm.Cycle.a <br>　　TCP 70=Gopher服务,ADM worm <br>　　TCP 79=用户查询(Finger),Firehotcker,ADM worm <br>　　TCP 80=超文本服务器(Http),Executor,RingZero <br>　　TCP 81=Chubo,Worm.Bbeagle.q <br>　　TCP 82=Netsky-Z <br>　　TCP 88=Kerberos krb5服务 <br>　　TCP 99=Hidden Port <br>　　TCP 102=消息传输代理 <br>　　TCP 108=SNA网关访问服务器 <br>　　TCP 109=Pop2 <br>　　TCP 110=电子邮件(Pop3),ProMail <br>　　TCP 113=Kazimas, Auther Idnet <br>　　TCP 115=简单文件传输协议 <br>　　TCP 118=SQL Services, Infector 1.4.2 <br>　　TCP 119=新闻组传输协议(Newsgroup(Nntp)), Happy 99 <br>　　TCP 121=JammerKiller, Bo jammerkillah <br>　　TCP 123=网络时间协议(NTP),Net Controller <br>　　TCP 129=Password Generator Protocol <br>　　TCP 133=Infector 1.x <br>　　TCP 135=微软DCE RPC end-point mapper服务 <br>　　TCP 137=微软Netbios Name服务(网上邻居传输文件使用) <br>　　TCP 138=微软Netbios Name服务(网上邻居传输文件使用) <br>　　TCP 139=微软Netbios Name服务(用于文件及打印机共享) <br>　　TCP 142=NetTaxi <br>　　TCP 143=IMAP <br>　　TCP 146=FC Infector,Infector <br>　　TCP 150=NetBIOS Session Service <br>　　TCP 156=SQL服务器 <br>　　TCP 161=Snmp <br>　　TCP 162=Snmp-Trap <br>　　TCP 170=A-Trojan <br>　　TCP 177=X Display管理控制协议 <br>　　TCP 179=Border网关协议(BGP) <br>　　TCP 190=网关访问控制协议(GACP) <br>　　TCP 194=Irc <br>　　TCP 197=目录定位服务(DLS) <br>　　TCP 256=Nirvana <br>　　TCP 315=The Invasor <br>　　TCP 371=ClearCase版本管理软件 <br>　　TCP 389=Lightweight Directory Access Protocol (LDAP) <br>　　TCP 396=Novell Netware over IP <br>　　TCP 420=Breach <br>　　TCP 421=TCP Wrappers <br>　　TCP 443=安全服务 <br>　　TCP 444=Simple Network Paging Protocol(SNPP) <br>　　TCP 445=Microsoft-DS <br>　　TCP 455=Fatal Connections <br>　　TCP 456=Hackers paradise,FuseSpark <br>　　TCP 458=苹果公司QuickTime <br>　　TCP 513=Grlogin <br>　　TCP 514=RPC Backdoor <br>　　TCP 520=Rip <br>　　TCP 531=Rasmin,Net666 <br>　　TCP 544=kerberos kshell <br>　　TCP 546=DHCP Client <br>　　TCP 547=DHCP Server <br>　　TCP 548=Macintosh文件服务 <br>　　TCP 555=Ini-Killer,Phase Zero,Stealth Spy <br>　　TCP 569=MSN <br>　　TCP 605=SecretService <br>　　TCP 606=Noknok8 <br>　　TCP 660=DeepThroat <br>　　TCP 661=Noknok8 <br>　　TCP 666=Attack FTP,Satanz Backdoor,Back Construction,Dark Connection Inside 1.2 <br>　　TCP 667=Noknok7.2 <br>　　TCP 668=Noknok6 <br>　　TCP 669=DP trojan <br>　　TCP 692=GayOL <br>　　TCP 707=Welchia,nachi <br>　　TCP 777=AIM Spy <br>　　TCP 808=RemoteControl,WinHole <br>　　TCP 815=Everyone Darling <br>　　TCP 901=Backdoor.Devil <br>　　TCP 911=Dark Shadow <br>　　TCP 990=ssl加密<br>　　TCP 993=IMAP <br>　　TCP 999=DeepThroat <br>　　TCP 1000=Der Spaeher <br>　　TCP 1001=Silencer,WebEx,Der Spaeher <br>　　TCP 1003=BackDoor <br>　　TCP 1010=Doly <br>　　TCP 1011=Doly <br>　　TCP 1012=Doly <br>　　TCP 1015=Doly <br>　　TCP 1016=Doly <br>　　TCP 1020=Vampire <br>　　TCP 1023=Worm.Sasser.e <br>　　TCP 1024=NetSpy.698(YAI) <br>　　TCP 1059=nimreg <br>　　//TCP 1025=NetSpy.698,Unused Windows Services Block <br>　　//TCP 1026=Unused Windows Services Block <br>　　//TCP 1027=Unused Windows Services Block <br>　　//TCP 1028=Unused Windows Services Block <br>　　//TCP 1029=Unused Windows Services Block <br>　　//TCP 1030=Unused Windows Services Block <br>　　//TCP 1033=Netspy <br>　　//TCP 1035=Multidropper <br>　　//TCP 1042=Bla <br>　　//TCP 1045=Rasmin <br>　　//TCP 1047=GateCrasher <br>　　//TCP 1050=MiniCommand <br>　　TCP 1069=Backdoor.TheefServer.202 <br>　　TCP 1070=Voice,Psyber Stream Server,Streaming Audio Trojan <br>　　TCP 1080=Wingate,Worm.BugBear.B,Worm.Novarg.B <br>　　//TCP 1090=Xtreme, VDOLive <br>　　//TCP 1092=LoveGate <br>　　//TCP 1095=Rat <br>　　//TCP 1097=Rat <br>　　//TCP 1098=Rat <br>　　//TCP 1099=Rat <br>　　TCP 1110=nfsd-keepalive <br>　　TCP 1111=Backdoor.AIMVision <br>　　TCP 1155=Network File Access <br>　　//TCP 1170=Psyber Stream Server,Streaming Audio trojan,Voice <br>　　//TCP 1200=NoBackO <br>　　//TCP 1201=NoBackO <br>　　//TCP 1207=Softwar <br>　　//TCP 1212=Nirvana,Visul Killer <br>　　//TCP 1234=Ultors <br>　　//TCP 1243=BackDoor-G, SubSeven, SubSeven Apocalypse <br>　　//TCP 1245=VooDoo Doll <br>　　//TCP 1269=Mavericks Matrix <br>　　//TCP 1313=Nirvana <br>　　//TCP 1349=BioNet <br>　　TCP 1433=Microsoft SQL服务 <br>　　//TCP 1441=Remote Storm <br>　　//TCP 1492=FTP99CMP(BackOriffice.FTP) <br>　　TCP 1503=NetMeeting T.120 <br>　　//TCP 1509=Psyber Streaming Server <br>　　//TCP 1600=Shivka-Burka <br>　　//TCP 1703=Exloiter 1.1 <br>　　TCP 1720=NetMeeting H.233 call Setup <br>　　TCP 1731=NetMeeting音频调用控制 <br>　　//TCP 1807=SpySender <br>　　//TCP 1966=Fake FTP 2000 <br>　　//TCP 1976=Custom port <br>　　//TCP 1981=Shockrave <br>　　TCP 1990=stun-p1 cisco STUN Priority 1 port <br>　　TCP 1990=stun-p1 cisco STUN Priority 1 port <br>　　TCP 1991=stun-p2 cisco STUN Priority 2 port <br>　　TCP 1992=stun-p3 cisco STUN Priority 3 port,ipsendmsg IPsendmsg <br>　　TCP 1993=snmp-tcp-port cisco SNMP TCP port <br>　　TCP 1994=stun-port cisco serial tunnel port <br>　　TCP 1995=perf-port cisco perf port <br>　　TCP 1996=tr-rsrb-port cisco Remote SRB port <br>　　TCP 1997=gdp-port cisco Gateway Discovery Protocol <br>　　TCP 1998=x25-svc-port cisco X.25 service (XOT) <br>　　//TCP 1999=BackDoor, TransScout <br>　　//TCP 2000=Der Spaeher,INsane Network <br>　　TCP 2002=W32.Beagle.AX @mm <br>　　//TCP 2001=Transmisson scout <br>　　//TCP 2002=Transmisson scout <br>　　//TCP 2003=Transmisson scout <br>　　//TCP 2004=Transmisson scout <br>　　//TCP 2005=TTransmisson scout <br>　　TCP 2011=cypress <br>　　TCP 2015=raid-cs <br>　　//TCP 2023=Ripper,Pass Ripper,Hack City Ripper Pro <br>　　TCP 2049=NFS <br>　　//TCP 2115=Bugs <br>　　//TCP 2121=Nirvana <br>　　//TCP 2140=Deep Throat, The Invasor <br>　　//TCP 2155=Nirvana <br>　　//TCP 2208=RuX <br>　　//TCP 2255=Illusion Mailer <br>　　//TCP 2283=HVL Rat5 <br>　　//TCP 2300=PC Explorer <br>　　//TCP 2311=Studio54 <br>　　TCP 2556=Worm.Bbeagle.q <br>　　//TCP 2565=Striker <br>　　//TCP 2583=WinCrash <br>　　//TCP 2600=Digital RootBeer <br>　　//TCP 2716=Prayer Trojan <br>　　TCP 2745=Worm.BBeagle.k <br>　　//TCP 2773=Backdoor,SubSeven <br>　　//TCP 2774=SubSeven2.1&amp;2.2 <br>　　//TCP 2801=Phineas Phucker <br>　　//TCP 2989=Rat <br>　　//TCP 3024=WinCrash trojan <br>　　TCP 3127=Worm.Novarg <br>　　TCP 3128=RingZero,Worm.Novarg.B <br>　　//TCP 3129=Masters Paradise <br>　　//TCP 3150=Deep Throat, The Invasor <br>　　TCP 3198=Worm.Novarg <br>　　//TCP 3210=SchoolBus <br>　　TCP 3332=Worm.Cycle.a <br>　　TCP 3333=Prosiak <br>　　TCP 3389=超级终端 <br>　　//TCP 3456=Terror <br>　　//TCP 3459=Eclipse 2000 <br>　　//TCP 3700=Portal of Doom <br>　　//TCP 3791=Eclypse <br>　　//TCP 3801=Eclypse <br>　　TCP 3996=Portal of Doom,RemoteAnything <br>　　TCP 4000=腾讯QQ客户端 <br>　　TCP 4060=Portal of Doom,RemoteAnything <br>　　TCP 4092=WinCrash <br>　　TCP 4242=VHM <br>　　TCP 4267=SubSeven2.1&amp;2.2 <br>　　TCP 4321=BoBo <br>　　TCP 4444=Prosiak,Swift remote <br>　　TCP 4500=W32.HLLW.Tufas <br>　　TCP 4567=File Nail <br>　　TCP 4590=ICQTrojan <br>　　TCP 4899=Remote Administrator服务器 <br>　　TCP 4950=ICQTrojan <br>　　TCP 5000=WindowsXP服务器,Blazer 5,Bubbel,Back Door Setup,Sockets de Troie <br>　　TCP 5001=Back Door Setup, Sockets de Troie <br>　　TCP 5002=cd00r,Shaft <br>　　TCP 5011=One of the Last Trojans (OOTLT) <br>　　TCP 5025=WM Remote KeyLogger <br>　　TCP 5031=Firehotcker,Metropolitan,NetMetro <br>　　TCP 5032=Metropolitan <br>　　TCP 5190=ICQ Query <br>　　TCP 5321=Firehotcker <br>　　TCP 5333=Backage Trojan Box 3 <br>　　TCP 5343=WCrat <br>　　TCP 5400=Blade Runner, BackConstruction1.2 <br>　　TCP 5401=Blade Runner,Back Construction <br>　　TCP 5402=Blade Runner,Back Construction <br>　　TCP 5471=WinCrash <br>　　TCP 5512=Illusion Mailer <br>　　TCP 5521=Illusion Mailer <br>　　TCP 5550=Xtcp,INsane Network <br>　　TCP 5554=Worm.Sasser <br>　　TCP 5555=ServeMe <br>　　TCP 5556=BO Facil <br>　　TCP 5557=BO Facil <br>　　TCP 5569=Robo-Hack <br>　　TCP 5598=BackDoor 2.03 <br>　　TCP 5631=PCAnyWhere data <br>　　TCP 5632=PCAnyWhere <br>　　TCP 5637=PC Crasher <br>　　TCP 5638=PC Crasher <br>　　TCP 5698=BackDoor <br>　　TCP 5714=Wincrash3 <br>　　TCP 5741=WinCrash3 <br>　　TCP 5742=WinCrash <br>　　TCP 5760=Portmap Remote Root Linux Exploit <br>　　TCP 5880=Y3K RAT <br>　　TCP 5881=Y3K RAT <br>　　TCP 5882=Y3K RAT <br>　　TCP 5888=Y3K RAT <br>　　TCP 5889=Y3K RAT <br>　　TCP 5900=WinVnc <br>　　TCP 6000=Backdoor.AB <br>　　TCP 6006=Noknok8 <br>　　TCP 6129=Dameware Nt Utilities服务器 <br>　　TCP 6272=SecretService <br>　　TCP 6267=广外女生 <br>　　TCP 6400=Backdoor.AB,The Thing <br>　　TCP 6500=Devil 1.03 <br>　　TCP 6661=Teman <br>　　TCP 6666=TCPshell.c <br>　　TCP 6667=NT Remote Control,Wise 播放器接收端口 <br>　　TCP 6668=Wise Video广播端口 <br>　　TCP 6669=Vampyre <br>　　TCP 6670=DeepThroat,iPhone <br>　　TCP 6671=Deep Throat 3.0 <br>　　TCP 6711=SubSeven <br>　　TCP 6712=SubSeven1.x <br>　　TCP 6713=SubSeven <br>　　TCP 6723=Mstream <br>　　TCP 6767=NT Remote Control <br>　　TCP 6771=DeepThroat <br>　　TCP 6776=BackDoor-G,SubSeven,2000 Cracks <br>　　TCP 6777=Worm.BBeagle <br>　　TCP 6789=Doly Trojan <br>　　TCP 6838=Mstream <br>　　TCP 6883=DeltaSource <br>　　TCP 6912=Shit Heep <br>　　TCP 6939=Indoctrination <br>　　TCP 6969=GateCrasher, Priority, IRC 3 <br>　　TCP 6970=RealAudio,GateCrasher <br>　　TCP 7000=Remote Grab,NetMonitor,SubSeven1.x <br>　　TCP 7001=Freak88 <br>　　TCP 7201=NetMonitor <br>　　TCP 7215=BackDoor-G, SubSeven <br>　　TCP 7001=Freak88,Freak2k <br>　　TCP 7300=NetMonitor <br>　　TCP 7301=NetMonitor <br>　　TCP 7306=NetMonitor,NetSpy 1.0 <br>　　TCP 7307=NetMonitor, ProcSpy <br>　　TCP 7308=NetMonitor, X Spy <br>　　TCP 7323=Sygate服务器端 <br>　　TCP 7424=Host Control <br>　　TCP 7511=聪明基因 <br>　　TCP 7597=Qaz <br>　　TCP 7609=Snid X2 <br>　　TCP 7626=冰河 <br>　　TCP 7777=The Thing <br>　　TCP 7789=Back Door Setup, ICQKiller <br>　　TCP 7983=Mstream <br>　　TCP 8000=腾讯OICQ服务器端,XDMA <br>　　TCP 8010=Wingate,Logfile <br>　　TCP 8011=WAY2.4 <br>　　TCP 8080=WWW 代理,Ring Zero,Chubo,Worm.Novarg.B <br>　　TCP 8102=网络神偷 <br>　　TCP <br>　　<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#56;&#49;&#56;&#49;&#61;&#87;&#51;&#50;&#46;&#69;&#114;&#107;&#101;&#122;&#46;&#68;&#64;&#109;&#109;">8181=W32.Erkez.D@mm</a> <br>　　TCP 8520=W32.Socay.Worm <br>　　TCP 8594=I-Worm/Bozori.a <br>　　TCP 8787=BackOfrice 2000 <br>　　TCP 8888=Winvnc <br>　　TCP 8897=Hack Office,Armageddon <br>　　TCP 8989=Recon <br>　　TCP 9000=Netministrator <br>　　TCP 9325=Mstream <br>　　TCP 9400=InCommand 1.0 <br>　　TCP 9401=InCommand 1.0 <br>　　TCP 9402=InCommand 1.0 <br>　　TCP 9872=Portal of Doom <br>　　TCP 9873=Portal of Doom <br>　　TCP 9874=Portal of Doom <br>　　TCP 9875=Portal of Doom <br>　　TCP 9876=Cyber Attacker <br>　　TCP 9878=TransScout <br>　　TCP 9989=Ini-Killer <br>　　TCP 9898=Worm.Win32.Dabber.a <br>　　TCP 9999=Prayer Trojan <br>　　TCP 10067=Portal of Doom <br>　　TCP 10080=Worm.Novarg.B <br>　　TCP 10084=Syphillis <br>　　TCP 10085=Syphillis <br>　　TCP 10086=Syphillis <br>　　TCP 10101=BrainSpy <br>　　TCP 10167=Portal Of Doom <br>　　TCP 10168=Worm.Supnot.78858.c,Worm.LovGate.T <br>　　TCP 10520=Acid Shivers <br>　　TCP 10607=Coma trojan <br>　　TCP 10666=Ambush <br>　　TCP 11000=Senna Spy <br>　　TCP 11050=Host Control <br>　　TCP 11051=Host Control <br>　　TCP 11223=Progenic,Hack &#8217;99KeyLogger <br>　　TCP 11831=TROJ_LATINUS.SVR <br>　　TCP 12076=Gjamer, MSH.104b <br>　　TCP 12223=Hack&#8217;99 KeyLogger <br>　　TCP 12345=GabanBus, NetBus 1.6/1.7, Pie Bill Gates, X-bill <br>　　TCP 12346=GabanBus, NetBus 1.6/1.7, X-bill <br>　　TCP 12349=BioNet <br>　　TCP 12361=Whack-a-mole <br>　　TCP 12362=Whack-a-mole <br>　　TCP 12363=Whack-a-mole <br>　　TCP <a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#49;&#50;&#51;&#55;&#56;&#61;&#87;&#51;&#50;&#47;&#71;&#105;&#98;&#101;&#64;&#77;&#77;">12378=W32/Gibe@MM</a> <br>　　TCP 12456=NetBus <br>　　TCP 12623=DUN Control <br>　　TCP 12624=Buttman <br>　　TCP 12631=WhackJob, WhackJob.NB1.7 <br>　　TCP 12701=Eclipse2000 <br>　　TCP 12754=Mstream <br>　　TCP 13000=Senna Spy <br>　　TCP 13010=Hacker Brazil <br>　　TCP 13013=Psychward <br>　　TCP 13223=Tribal Voice的聊天程序PowWow <br>　　TCP 13700=Kuang2 The Virus <br>　　TCP 14456=Solero <br>　　TCP 14500=PC Invader <br>　　TCP 14501=PC Invader <br>　　TCP 14502=PC Invader <br>　　TCP 14503=PC Invader <br>　　TCP 15000=NetDaemon 1.0 <br>　　TCP 15092=Host Control <br>　　TCP 15104=Mstream <br>　　TCP 16484=Mosucker <br>　　TCP 16660=Stacheldraht (DDoS) <br>　　TCP 16772=ICQ Revenge <br>　　TCP 16959=Priority <br>　　TCP 16969=Priority <br>　　TCP 17027=提供广告服务的Conducent"adbot"共享软件 <br>　　TCP 17166=Mosaic <br>　　TCP 17300=Kuang2 The Virus <br>　　TCP 17490=CrazyNet <br>　　TCP 17500=CrazyNet <br>　　TCP 17569=Infector 1.4.x + 1.6.x <br>　　TCP 17777=Nephron <br>　　TCP 18753=Shaft (DDoS) <br>　　TCP 19191=蓝色火焰 <br>　　TCP 19864=ICQ Revenge <br>　　TCP 20000=Millennium II (GrilFriend) <br>　　TCP 20001=Millennium II (GrilFriend) <br>　　TCP 20002=AcidkoR <br>　　TCP 20034=NetBus 2 Pro <br>　　TCP 20168=Lovgate <br>　　TCP 20203=Logged,Chupacabra <br>　　TCP 20331=Bla <br>　　TCP 20432=Shaft (DDoS) <br>　　TCP 20808=Worm.LovGate.v.QQ <br>　　TCP 21335=Tribal Flood Network,Trinoo <br>　　TCP 21544=Schwindler 1.82,GirlFriend <br>　　TCP 21554=Schwindler 1.82,GirlFriend,Exloiter 1.0.1.2 <br>　　TCP 22222=Prosiak,RuX Uploader 2.0 <br>　　TCP 22784=Backdoor.Intruzzo <br>　　TCP 23432=Asylum 0.1.3 <br>　　TCP 23444=网络公牛 <br>　　TCP 23456=Evil FTP, Ugly FTP, WhackJob <br>　　TCP 23476=Donald Dick <br>　　TCP 23477=Donald Dick <br>　　TCP 23777=INet Spy <br>　　TCP 26274=Delta <br>　　TCP 26681=Spy Voice <br>　　TCP 27374=Sub Seven 2.0+, Backdoor.Baste <br>　　TCP 27444=Tribal Flood Network,Trinoo <br>　　TCP 27665=Tribal Flood Network,Trinoo <br>　　TCP 29431=Hack Attack <br>　　TCP 29432=Hack Attack <br>　　TCP 29104=Host Control <br>　　TCP 29559=TROJ_LATINUS.SVR <br>　　TCP 29891=The Unexplained <br>　　TCP 30001=Terr0r32 <br>　　TCP 30003=Death,Lamers Death <br>　　TCP 30029=AOL trojan <br>　　TCP 30100=NetSphere 1.27a,NetSphere 1.31 <br>　　TCP 30101=NetSphere 1.31,NetSphere 1.27a <br>　　TCP 30102=NetSphere 1.27a,NetSphere 1.31 <br>　　TCP 30103=NetSphere 1.31 <br>　　TCP 30303=Sockets de Troie <br>　　TCP 30722=W32.Esbot.A <br>　　TCP 30947=Intruse <br>　　TCP 30999=Kuang2 <br>　　TCP 31336=Bo Whack <br>　　TCP 31337=Baron Night,BO client,BO2,Bo Facil,BackFire,Back Orifice,DeepBO,Freak2k,NetSpy <br>　　TCP 31338=NetSpy,Back Orifice,DeepBO <br>　　TCP 31339=NetSpy DK <br>　　TCP 31554=Schwindler <br>　　TCP 31666=BOWhack <br>　　TCP 31778=Hack Attack <br>　　TCP 31785=Hack Attack <br>　　TCP 31787=Hack Attack <br>　　TCP 31789=Hack Attack <br>　　TCP 31791=Hack Attack <br>　　TCP 31792=Hack Attack <br>　　TCP 32100=PeanutBrittle <br>　　TCP 32418=Acid Battery <br>　　TCP 33333=Prosiak,Blakharaz 1.0 <br>　　TCP 33577=Son Of Psychward <br>　　TCP 33777=Son Of Psychward <br>　　TCP 33911=Spirit 2001a <br>　　TCP 34324=BigGluck,TN,Tiny Telnet Server <br>　　TCP 34555=Trin00 (Windows) (DDoS) <br>　　TCP 35555=Trin00 (Windows) (DDoS) <br>　　TCP 36794=Worm.Bugbear-A <br>　　TCP 37651=YAT <br>　　TCP 40412=The Spy <br>　　TCP 40421=Agent 40421,Masters Paradise.96 <br>　　TCP 40422=Masters Paradise <br>　　TCP 40423=Masters Paradise.97 <br>　　TCP 40425=Masters Paradise <br>　　TCP 40426=Masters Paradise 3.x <br>　　TCP 41666=Remote Boot <br>　　TCP 43210=Schoolbus 1.6/2.0 <br>　　TCP 44444=Delta Source <br>　　TCP 44445=Happypig <br>　　TCP 45576=未知代理 <br>　　TCP 47252=Prosiak <br>　　TCP 47262=Delta <br>　　TCP 47878=BirdSpy2 <br>　　TCP 49301=Online Keylogger <br>　　TCP 50505=Sockets de Troie <br>　　TCP 50766=Fore, Schwindler <br>　　TCP 51966=CafeIni <br>　　TCP 53001=Remote Windows Shutdown <br>　　TCP 53217=Acid Battery 2000 <br>　　TCP 54283=Back Door-G, Sub7 <br>　　TCP 54320=Back Orifice 2000,Sheep <br>　　TCP 54321=School Bus .69-1.11,Sheep, BO2K <br>　　TCP 57341=NetRaider <br>　　TCP 58008=BackDoor.Tron <br>　　TCP 58009=BackDoor.Tron <br>　　TCP 58339=ButtFunnel <br>　　TCP 59211=BackDoor.DuckToy <br>　　TCP 60000=Deep Throat <br>　　TCP 60068=Xzip 6000068 <br>　　TCP 60411=Connection <br>　　TCP 60606=TROJ_BCKDOR.G2.A <br>　　TCP 61466=Telecommando <br>　　TCP 61603=Bunker-kill <br>　　TCP 63485=Bunker-kill <br>　　TCP 65000=Devil, DDoS <br>　　TCP 65432=Th3tr41t0r, The Traitor <br>　　TCP 65530=TROJ_WINMITE.10 <br>　　TCP 65535=RC,Adore Worm/Linux <br>　　TCP 69123=ShitHeep <br>　　TCP 88798=Armageddon,Hack Office <br>　　UDP 1=Sockets des Troie <br>　　UDP 9=Chargen <br>　　UDP 19=Chargen <br>　　UDP 69=Pasana <br>　　UDP 80=Penrox <br>　　UDP 371=ClearCase版本管理软件 <br>　　UDP 445=公共Internet文件系统(CIFS) <br>　　UDP 500=Internet密钥交换 <br>　　UDP 1025=Maverick&#8217;s Matrix 1.2 - 2.0 <br>　　UDP 1026=Remote Explorer 2000 <br>　　UDP 1027=UC聊天软件,Trojan.Huigezi.e <br>　　UDP 1028=3721上网助手(用途不明,建议用户警惕!),KiLo,SubSARI <br>　　UDP 1029=SubSARI <br>　　UDP 1031=Xot <br>　　UDP 1032=Akosch4 <br>　　UDP 1104=RexxRave <br>　　UDP 1111=Daodan <br>　　UDP 1116=Lurker <br>　　UDP 1122=Last 2000,Singularity <br>　　UDP 1183=Cyn,SweetHeart <br>　　UDP 1200=NoBackO <br>　　UDP 1201=NoBackO <br>　　UDP 1342=BLA trojan <br>　　UDP 1344=Ptakks <br>　　UDP 1349=BO dll <br>　　UDP 1561=MuSka52 <br>　　UDP 1772=NetControle <br>　　UDP 1978=Slapper <br>　　UDP 1985=Black Diver <br>　　UDP 2000=A-trojan,Fear,Force,GOTHIC Intruder,Last 2000,Real 2000 <br>　　UDP 2001=Scalper <br>　　UDP 2002=Slapper <br>　　UDP 2015=raid-cs <br>　　UDP 2018=rellpack <br>　　UDP 2130=Mini BackLash <br>　　UDP 2140=Deep Throat,Foreplay,The Invasor <br>　　UDP 2222=SweetHeart, Way <br>　　UDP 2339=Voice Spy <br>　　UDP 2702=Black Diver <br>　　UDP 2989=RAT <br>　　UDP 3150=Deep Throat <br>　　UDP 3215=XHX <br>　　UDP 3333=Daodan <br>　　UDP 3801=Eclypse <br>　　UDP 3996=Remote Anything <br>　　UDP 4128=RedShad <br>　　UDP 4156=Slapper <br>　　UDP 4500=sae-urn <br>　　UDP 5419=DarkSky <br>　　UDP 5503=Remote Shell Trojan <br>　　UDP 5555=Daodan <br>　　UDP 5882=Y3K RAT <br>　　UDP 5888=Y3K RAT <br>　　UDP 6112=Battle.net Game <br>　　UDP 6666=KiLo <br>　　UDP 6667=KiLo <br>　　UDP 6766=KiLo <br>　　UDP 6767=KiLo,UandMe <br>　　UDP 6838=Mstream Agent-handler <br>　　UDP 7028=未知木马 <br>　　UDP 7424=Host Control <br>　　UDP 7788=Singularity <br>　　UDP 7983=MStream handler-agent <br>　　UDP 8012=Ptakks <br>　　UDP 8090=Aphex&#8217;s Remote Packet Sniffer <br>　　UDP 8127=9_119,Chonker <br>　　UDP 8488=KiLo <br>　　UDP 8489=KiLo <br>　　UDP 8787=BackOrifice 2000 <br>　　UDP 8879=BackOrifice 2000 <br>　　UDP 9325=MStream Agent-handler <br>　　UDP 10000=XHX <br>　　UDP 10067=Portal of Doom <br>　　UDP 10084=Syphillis <br>　　UDP 10100=Slapper <br>　　UDP 10167=Portal of Doom <br>　　UDP 10498=Mstream <br>　　UDP 10666=Ambush <br>　　UDP 11225=Cyn <br>　　UDP 12321=Protoss <br>　　UDP 12345=BlueIce 2000 <br>　　UDP <a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#49;&#50;&#51;&#55;&#56;&#61;&#87;&#51;&#50;&#47;&#71;&#105;&#98;&#101;&#64;&#77;&#77;">12378=W32/Gibe@MM</a> <br>　　UDP 12623=ButtMan,DUN Control <br>　　UDP 15210=UDP remote shell backdoor server <br>　　UDP 15486=KiLo <br>　　UDP 16514=KiLo <br>　　UDP 16515=KiLo <br>　　UDP 18753=Shaft handler to Agent <br>　　UDP 20433=Shaft <br>　　UDP 21554=GirlFriend <br>　　UDP 22784=Backdoor.Intruzzo <br>　　UDP 23476=Donald Dick <br>　　UDP 25123=MOTD <br>　　UDP 26274=Delta Source <br>　　UDP 26374=Sub-7 2.1 <br>　　UDP 26444=Trin00/TFN2K <br>　　UDP 26573=Sub-7 2.1 <br>　　UDP 27184=Alvgus trojan 2000 <br>　　UDP 27444=Trinoo <br>　　UDP 29589=KiLo <br>　　UDP 29891=The Unexplained <br>　　UDP 30103=NetSphere <br>　　UDP 31320=Little Witch <br>　　UDP 31335=Trin00 DoS Attack <br>　　UDP 31337=Baron Night, BO client, BO2, Bo Facil, BackFire, Back Orifice, DeepBO <br>　　UDP 31338=Back Orifice, NetSpy DK, DeepBO <br>　　UDP 31339=Little Witch <br>　　UDP 31340=Little Witch <br>　　UDP 31416=Lithium <br>　　UDP 31787=Hack aTack <br>　　UDP 31789=Hack aTack <br>　　UDP 31790=Hack aTack <br>　　UDP 31791=Hack aTack <br>　　UDP 33390=未知木马 <br>　　UDP 34555=Trinoo <br>　　UDP 35555=Trinoo <br>　　UDP 43720=KiLo <br>　　UDP 44014=Iani <br>　　UDP 44767=School Bus <br>　　UDP 46666=Taskman <br>　　UDP 47262=Delta Source <br>　　UDP 47785=KiLo <br>　　UDP 49301=OnLine keyLogger <br>　　UDP 49683=Fenster <br>　　UDP 49698=KiLo <br>　　UDP 52901=Omega <br>　　UDP 54320=Back Orifice <br>　　UDP 54321=Back Orifice 2000 <br>　　UDP 54341=NetRaider Trojan <br>　　UDP 61746=KiLO <br>　　UDP 61747=KiLO <br>　　UDP 61748=KiLO <br>　　UDP 65432=The Traitor<br><br>
<hr>
<br>
<img src ="http://www.cppblog.com/momoxiao/aggbug/112189.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/momoxiao/" target="_blank">小默</a> 2010-04-10 17:36 <a href="http://www.cppblog.com/momoxiao/archive/2010/04/10/112189.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[zz]ICMP重定向</title><link>http://www.cppblog.com/momoxiao/archive/2009/12/11/103022.html</link><dc:creator>小默</dc:creator><author>小默</author><pubDate>Fri, 11 Dec 2009 15:53:00 GMT</pubDate><guid>http://www.cppblog.com/momoxiao/archive/2009/12/11/103022.html</guid><wfw:comment>http://www.cppblog.com/momoxiao/comments/103022.html</wfw:comment><comments>http://www.cppblog.com/momoxiao/archive/2009/12/11/103022.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/momoxiao/comments/commentRss/103022.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/momoxiao/services/trackbacks/103022.html</trackback:ping><description><![CDATA[<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 虽然在通常情况下，IP协议与路由信息的管理并没有关系，但它确实定义了一个小小的<strong>故障控制</strong>功能，称为ICMP重定向（ICMP redirect）。当<strong>一台路由器把一个包转发至一台计算机</strong>，而<strong>这台计算机却又在最初接收这个包的网络上</strong>的时候，就出现了明显的错误。由于<strong>发送方、路由器和下一跳的路由器都在同一网络上</strong>，所以包应该以一跳而不是两跳转发。路由器可以得出结论：<strong>发送方的路由表是不准确或者不完整的</strong>。 </p>
<p>在这种情况下，路由器可以用一个ICMP重定向包<strong>把发送方的问题通知给它</strong>。实际上，一个重定向包说：&#8220;<strong>您不应该将发往主机xxx的包发送给我，您应该把它们发送给主机yyy。</strong>&#8221;ICMP协议允许将重定向包既发送给单个主机地址也发送给整个网络。但是，许多实现只产生主机重定向包，现在，网络重定向包还没有多大用处，因为它们只能应用到A、B或者C类网络上。</p>
<p>根据接收到的重定向包，发送方就会更新它的路由表，这样一来，将来那些发往这个地址的包就能走更直接的路径。在出现多播的早期时代，有些系统会响应多播包而生成ICMP路由重定向包。现代系统已不存在这个问题。 </p>
<p>标准的ICMP应用场合并<strong>不包括身份认证的步骤</strong>。您的路由器会收到一个声称来自其他某个声誉良好的路由器的重定向包，指导您将流量发送到其他地方。您是否应该采纳呢？请注意，重定向实际上引发了一个安全问题。一般情况下，Linux内核（出于安全原因）和Cisco路由器（因为它们是路由器）都会忽略重定向包。让那些<strong>不可信的主机修改您的路由表</strong>可不是件好事。 </p>
<p>在 Linux 下，/proc 目录树下的变量 accept_redirects 控制着 ICMP 重定向包的接收。参见 12.10节了解检查和重设这个变量的指令。&nbsp; <br></p>
<img src ="http://www.cppblog.com/momoxiao/aggbug/103022.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/momoxiao/" target="_blank">小默</a> 2009-12-11 23:53 <a href="http://www.cppblog.com/momoxiao/archive/2009/12/11/103022.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>