ARP命令参数详解
<span class="Apple-style-span" style="color: rgb(27, 113, 155); font-family: 微软雅黑, 黑体; font-size: 18px; font-weight: 300; line-height: 20px; "> ARP命令参数详解</span><div><span class="Apple-style-span" style="color: rgb(27, 113, 155); font-family: 微软雅黑, 黑体; font-size: 18px; font-weight: 300; line-height: 20px; "><span class="Apple-style-span" style="color: rgb(70, 70, 70); font-family: simsun; font-size: 14px; line-height: 21px; font-weight: normal; "><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 21px; ">Arp<br>显示和修改“地址解析协议 (ARP)”缓存中的项目。ARP 缓存中包含一个或多个表,它们用于存储 IP 地址及其经过解析的以太网或令牌环物理地址。计算机上安装的每一个以太网或令牌环网络适配器都有自己单独的表。如果在没有参数的情况下使用,则 arp 命令将显示帮助信息。<br>语法<br>arp[-a [-N IfaceAddr]] [-g [-N IfaceAddr]] [-d InetAddr ] [-s InetAddr EtherAddr ]<br>参数<br>-a[ InetAddr] [ -N IfaceAddr] <br>显示所有接口的当前 ARP 缓存表。要显示特定 IP 地址的 ARP 缓存项,请使用带有 InetAddr 参数的 arp -a,此处的 InetAddr 代表 IP 地址。如果未指定 InetAddr,则使用第一个适用的接口。要显示特定接口的 ARP 缓存表,请将 -N IfaceAddr 参数与 -a 参数一起使用,此处的 IfaceAddr 代表指派给该接口的 IP 地址。-N 参数区分大小写。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 21px; ">-g[ InetAddr] [ -N IfaceAddr] <br>与 -a 相同。<br>-d InetAddr <br>删除指定的 IP 地址项,此处的 InetAddr 代表 IP 地址。对于指定的接口,要删除表中的某项,请使用 IfaceAddr 参数,此处的 IfaceAddr 代表指派给该接口的 IP 地址。要删除所有项,请使用星号 (*) 通配符代替 InetAddr。<br>-s InetAddr EtherAddr <br>向 ARP 缓存添加可将 IP 地址 InetAddr 解析成物理地址 EtherAddr 的静态项。要向指定接口的表添加静态 ARP 缓存项,请使用 IfaceAddr 参数,此处的 IfaceAddr 代表指派给该接口的 IP 地址。<br>/?<br>在命令提示符下显示帮助。<br>注释<br>" InetAddr 和 IfaceAddr 的 IP 地址用带圆点的十进制记数法表示。 <br>" EtherAddr 的物理地址由六个字节组成,这些字节用十六进制记数法表示并且用连字符隔开(比如,00-AA-00-4F-2A-9C)。 <br>" 通过 -s 参数添加的项属于静态项,它们不会 ARP 缓存超时。如果终止 TCP/IP 协议后再启动,这些项会被删除。要创建永久的静态 ARP 缓存项,请将适当的 arp 命令置于批处理文件中,并使用“任务计划”在启动时运行该批处理文件。 <br>示例<br>要显示所有接口的 ARP 缓存表,可键入:<br>arp -a<br>对于指派的 IP 地址为 10.0.0.99 的接口,要显示其 ARP 缓存表,可键入:<br>arp -a -N 10.0.0.99<br>要添加将 IP 地址 10.0.0.80 解析成物理地址 00-AA-00-4F-2A-9C 的静态 ARP 缓存项,可键入:<br>arp -s 10.0.0.80 00-AA-00-4F-2A-9C</p><p align="left" style="margin-top: 0px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 21px; ">处理系统的 <b>ARP</b> 缓存,可以清除缓存中的地址映射,建立新的地址映射; </p><p align="left" style="margin-top: 0px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 21px; ">语法:<b>arp</b> [-v][-n][-H type][-i if] -a </p><p align="left" style="margin-top: 0px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 21px; "> <b>arp</b> [-v][-i if] -d hostname </p><p align="left" style="margin-top: 0px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 21px; "> <b>arp</b> [-v][-H type][-i if] -s hostname hw_addr </p><p align="left" style="margin-top: 0px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 21px; "> <b>arp</b> [-v][-H type][-i if] -s hostname hw_addr pub</p><p align="left" style="margin-top: 0px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 21px; "> <b>arp</b> [-v][-H type][-i if] -Ds hostname ifa pub</p><p align="left" style="margin-top: 0px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 21px; "> <b>arp</b> [-v][-n][-D][-H type][-i if] -f </p><p align="left" style="margin-top: 0px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 21px; "><b>该命令的各选项含义如下:</b> </p><p align="left" style="margin-top: 0px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 21px; ">-v 显示详细信息;</p><p align="left" style="margin-top: 0px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 21px; ">-n 以数字地址形式显示;</p><p align="left" style="margin-top: 0px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 21px; ">-i If选择界面;</p><p align="left" style="margin-top: 0px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 21px; ">-H type设置和查询<b>arp</b>缓存时检查 type 类型的地址;</p><p align="left" style="margin-top: 0px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 21px; ">-a 显示指定 hostname 的所有入口;</p><p align="left" style="margin-top: 0px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 21px; ">-d hostname 删除指定 hostname 的所有入口;</p><p align="left" style="margin-top: 0px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 21px; ">-D 使用ifa硬件地址界面;</p><p align="left" style="margin-top: 0px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 21px; ">-s hostname hw_addr 手工加入 hostname 的地址映射;</p><p align="left" style="margin-top: 0px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 21px; ">-f filename 从指定文件中读入 hostname 和硬件地址信息</p><p align="left" style="margin-top: 0px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 21px; ">-s hostname hw_addr 手工加入 hostname 的地址映射;</p><p align="left" style="margin-top: 0px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 21px; "> 采用双向绑定的方法解决并且防止ARP欺骗。 </p><p align="left" style="margin-top: 0px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 21px; "> 1、在PC上绑定安全网关的IP和MAC地址: </p><p align="left" style="margin-top: 0px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 21px; "> 1)首先,获得安全网关的内网的MAC地址(例如HiPER网关地址192.168.16.254的MAC地址为0022aa0022aa)。 </p><p align="left" style="margin-top: 0px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 21px; "> 2)编写一个批处理文件rarp.bat内容如下: </p><p align="left" style="margin-top: 0px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 21px; "> @echo off </p><p align="left" style="margin-top: 0px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 21px; "> arp -d </p><p align="left" style="margin-top: 0px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 21px; "> arp -s 192.168.16.254 00-22-aa-00-22-aa </p><p align="left" style="margin-top: 0px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 21px; "> 将文件中的网关IP地址和MAC地址更改为实际使用的网关IP地址和MAC地址即可。 </p><p align="left" style="margin-top: 0px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 21px; "> 将这个批处理软件拖到“windowsà开始à程序à启动”中。 </p><p align="left" style="margin-top: 0px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 21px; "> 3)如果是网吧,可以利用收费软件服务端程序(pubwin或者万象都可以)发送批处理文件rarp.bat到所有客户机的启动目录。Windows2000的默认启动目录为“C:\Documents and Settings\All Users「开始」菜单程序启动”。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 21px; ">ARp(地址转换协议)的使用技巧<br> ARp是一个重要的TCp/Ip协议,并且用于确定对应Ip地址的网卡物理地址。实用arp命令,我们能够查看本地计算机或另一台计算机的ARp高速缓存中的当前内容。此外,使用arp命令,也可以用人工方式输入静态的网卡物理/Ip地址对,我们可能会使用这种方式为缺省网关和本地服务器等常用主机进行这项作,有助于减少网络上的信息量。<br> 按照缺省设置,ARp高速缓存中的项目是动态的,每当发送一个指定地点的数据报且高速缓存中不存在当前项目时,ARp便会自动添加该项目。一旦高速缓存的项目被输入,它们就已经开始走向失效状态。例如,在Windows NT/2000网络中,如果输入项目后不进一步使用,物理/Ip地址对就会在2至10分钟内失效。因此,如果ARp高速缓存中项目很少或根本没有时,请不要奇怪,通过另一台计算机或路由器的ping命令即可添加。所以,需要通过arp命令查看高速缓存中的内容时,请最好先ping 此台计算机(不能是本机发送ping命令)。<br> ARp常用命令选项:<br> ·arp -a或arp –g<br> 用于查看高速缓存中的所有项目。-a和-g参数的结果是一样的,多年来-g一直是UNIX平台上用来显示ARp高速缓存中所有项目的选项,而Windows用的是arp -a(-a可被视为all,即全部的意思),但它也可以接受比较传统的-g选项。<br> ·arp -a Ip<br> 如果我们有多个网卡,那么使用arp -a加上接口的Ip地址,就可以只显示与该接口相关的ARp缓存项目。<br> ·arp -s Ip 物理地址<br> 我们可以向ARp高速缓存中人工输入一个静态项目。该项目在计算机引导过程中将保持有效状态,或者在出现错误时,人工配置的物理地址将自动更新该项目。<br> ·arp -d Ip<br> 使用本命令能够人工删除一个静态项目。<br> 例如我们在命令提示符下,键入 Arp –a;如果我们使用过 ping 命令测试并验证从这台计算机到 Ip 地址为 10.0.0.99 的主机的连通性,则 ARp 缓存显示以下项:<br> Interface:10.0.0.1 on interface 0x1<br> Internet Address physical Address Type<br> 10.0.0.99 00-e0-98-00-7c-dc dynamic<br> 在此例中,缓存项指出位于 10.0.0.99 的远程主机解析成 00-e0-98-00-7c-dc 的媒体访问控制地址,它是在远程计算机的网卡硬件中分配的。媒体访问控制地址是计算机用于与网络上远程 TCp/Ip 主机物理通讯的地址。<br> 至此我们可以用ipconfig和ping命令来查看自己的网络配置并判断是否正确、可以用netstat查看别人与我们所建立的连接并找出ICQ使用者所隐藏的Ip信息、可以用arp查看网卡的MAC地址。 <br> netstat<br>netstat命令是一个监控TCP/IP网络的非常有用的工具,它可以显示路由表、实际的网络连接以及每一个网络接口设备的状态信息,在我的计算机上执行netstat后,其输出结果为:<br>Active Internet connections (w/o servers)<br>Proto Recv-Q Send-Q Local Address Foreign Address State<br>tcp 0 2 210.34.6.89:telnet 210.34.6.96:2873 ESTABLISHED<br>tcp 296 0 210.34.6.89:1165 210.34.6.84:netbios-ssn ESTABLISHED<br>tcp 0 0 localhost.localdom:9001 localhost.localdom:1162 ESTABLISHED<br>tcp 0 0 localhost.localdom:1162 localhost.localdom:9001 ESTABLISHED<br>tcp 0 80 210.34.6.89:1161 210.34.6.10:netbios-ssn CLOSE<br>Active UNIX domain sockets (w/o servers)<br>Proto RefCnt Flags Type State I-Node Path<br>unix 1 [ ] STREAM CONNECTED 16178 @000000dd<br>unix 1 [ ] STREAM CONNECTED 16176 @000000dc<br>unix 9 [ ] DGRAM 5292 /dev/log<br>unix 1 [ ] STREAM CONNECTED 16182 @000000df<br>从整体上看,netstat的输出结果可以分为两个部分,一个是Active Internet connections,称为有源TCP连接,另一个是Active UNIX domain sockets,称为有源Unix域套接口。在上面的输出结果中,第一部分有5个输出结果,显示有源TCP连接的情况,而第二部分的输出结果显示的是Unix域套接口的连接情况。Proto显示连接使用的协议;RefCnt表示连接到本套接口上的进程号;Types显示套接口的类型;State显示套接口当前的状态;Path表示连接到套接口的其它进程使用的路径名。<br>事实上,netstat是若干个工具的汇总。<br><br>◆ 显示路由表<br>在随- r标记一起调用n e t s t a t时,将显示内核路由表,就像我们利用r o u t e命令一样。产生的输出如下:<br>$ netstat -nr<br>Kernel IP routing table<br>Destination Gateway Genmask Flags MSS Window irtt Iface<br>210.34.6.0 0.0.0.0 255.255.255.128 U 0 0 0 eth0<br>192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1<br>127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo<br>0.0.0.0 210.34.6.2 0.0.0.0 UG 0 0 0 eth0<br>- n 选项令netstat以点分四段式的形式输出IP地址,而不是象征性的主机名和网络名。如果想避免通过网络查找地址(比如避开DNS或NIS服务器),这一点是特别有用的。<br>netstat输出结果中,第二列展示的是路由条目所指的网关,如果没有使用网关,就会出现一个星号(*)或者0.0.0.0;第三列展示路由的概述,在为具体的I P地址找出最恰当的路由时,内核将查看路由表内的所有条目,在对找到的路由与目标路由比较之前,将对I P地址和genmask进行按位“与”计算;第四列显示了不同的标记,这些标记的说明如下:<br>■ G 路由将采用网关。<br>■ U 准备使用的接口处于“活动”状态。<br>■ H 通过该路由,只能抵达一台主机。<br>■ D 如果路由表的条目是由ICMP重定向消息生成的,就会设置这个标记。<br>■ M 如果路由表条目已被ICMP重定向消息修改,就会设置这个标记。<br>netstat输出结果的Iface显示该连接所用的物理网卡,如eth0表示用第一张,eth1表示用第二张。<br><br>◆ 显示接口特性<br><br>在随- i标记一起调用时, netstat将显示网络接口的当前配置特性。除此以外,如果调用时还带上-a选项,它还将输出内核中所有接口,并不只是当前配置的接口。netstat-i的输出结果是这样的:<br>$ netstat -i<br>Kernel Interface table<br>Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg<br>eth0 1500 0 787165 0 0 1 51655 0 0 0 BRU<br>eth1 1500 0 520811 0 0 0 1986 0 0 0 BRU<br>lo 3924 0 1943 0 0 0 43 0 0 0 LRU<br>MTU和Met字段表示的是接口的MTU和度量值值;RX和TX这两列表示的是已经准确无误地收发了多少数据包( RX - OK / TX - OK)、产生了多少错误( RX-ERR/TX-ERR)、丢弃了多少包(RX-DRP/TX-DRP),由于误差而遗失了多少包(RX-OVR/TX-OVR);最后一列展示的是为这个接口设置的标记,在利用ifconfig显示接口配置时,这些标记都采用一个字母。它们的说明如下:<br>■ B 已经设置了一个广播地址。<br>■ L 该接口是一个回送设备。<br>■ M 接收所有数据包(混乱模式)。<br>■ N 避免跟踪。<br>■ O 在该接口上,禁用A R P。<br>■ P 这是一个点到点链接。<br>■ R 接口正在运行。<br>■ U 接口处于“活动”状态。<br><br>◆ 显示链接<br>netstat支持用于显示活动或被动套接字的选项集。选项- t、- u、- w和- x分别表示TCP、UDP、RAW和UNIX套接字连接。如果你另外还提供了一个- a标记,还会显示出等待连接(也就是说处于监听模式)的套接字。这样就可以得到一份服务器清单,当前所有运行于系统中的所有服务器都会列入其中。<br>调用netstat -ta时,输出结果如下:<br>$ netstat -ta<br>Active Internet connections (servers and established)<br>Proto Recv-Q Send-Q Local Address Foreign Address State<br>tcp 0 2 210.34.6.89:telnet 210.34.6.96:2873 ESTABLISHED<br>tcp 0 0 210.34.6.89:1165 210.34.6.84:netbios-ssn ESTABLISHED<br>tcp 0 0 localhost.localdom:9001 localhost.localdom:1162 ESTABLISHED<br>tcp 0 0 localhost.localdom:1162 localhost.localdom:9001 ESTABLISHED<br>tcp 0 0 *:9001 *:* LISTEN<br>tcp 0 0 *:6000 *:* LISTEN<br>tcp 0 0 *:socks *:* LISTEN<br>tcp 0 80 210.34.6.89:1161 210.34.6.10:netbios-ssn CLOSE<br>上面的输出表明部分服务器处于等待接入连接状态。利用- a选项的话,netstat还会显示出所有的套接字。注意根据端口号,可以判断出一条连接是否是外出连接。对呼叫方主机来说,列出的端口号应该一直是一个整数,而对众所周知服务(well known service)端口正在使用中的被呼叫方来说,netstat采用的则是取自/etc/services文件的象征**名。</p><p align="left" style="margin-top: 0px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 21px; ">Netstat用于显示与IP、TCP、UDP和ICMP协议相关的统计数据,一般用于检验本机各端口的网络连接情况。<br><br> 如果我们的计算机有时候接受到的数据报会导致出错数据删除或故障,我们不必感到奇怪,TCP/IP可以容许这些类型的错误,并能够自动重发数据报。但如果累计的出错情况数目占到所接收的IP数据报相当大的百分比,或者它的数目正迅速增加,那么我们就应该使用Netstat查一查为什么会出现这些情况了。<br><br> 1、netstat 的一些常用选项<br> ·netstat –s<br> 本选项能够按照各个协议分别显示其统计数据。如果我们的应用程序(如Web浏览器)运行速度比较慢,或者不能显示Web页之类的数据,那么我们就可以用本选项来查看一下所显示的信息。我们需要仔细查看统计数据的各行,找到出错的关键字,进而确定问题所在。<br> ·netstat –e<br> 本选项用于显示关于以太网的统计数据。它列出的项目包括传送的数据报的总字节数、错误数、删除数、数据报的数量和广播的数量。这些统计数据既有发送的数据报数量,也有接收的数据报数量。这个选项可以用来统计一些基本的网络流量)。<br> ·netstat –r<br> 本选项可以显示关于路由表的信息,类似于后面所讲使用route print命令时看到的信息。除了显示有效路由外,还显示当前有效的连接。<br> ·netstat –a<br> 本选项显示一个所有的有效连接信息列表,包括已建立的连接(ESTABLISHED),也包括监听连接请求(LISTENING)的那些连接。<br> ·netstat –n<br> 显示所有已建立的有效连接。<br> 下面是 netstat 的输出示例:<br> C:\>netstat -e<br> Interface Statistics<br> ReceivedSent<br> Bytes399583794047224622<br> Unicast packets120099131015<br> Non-unicast packets7579544 3823<br> Discards 0 0 Errors 0 0<br> Unknown protocols363054211<br> C:\>netstat -a<br> Active Connections<br> Proto Local AddressForeign Address State<br> TCPCORP1:1572 172.16.48.10:nbsession ESTABLISHED<br> TCPCORP1:1589 172.16.48.10:nbsession ESTABLISHED<br> TCPCORP1:1606 172.16.105.245:nbsession ESTABLISHED<br> TCPCORP1:1632 172.16.48.213:nbsessionESTABLISHED<br> TCPCORP1:1659 172.16.48.169:nbsessionESTABLISHED<br> TCPCORP1:1714 172.16.48.203:nbsessionESTABLISHED<br> TCPCORP1:1719 172.16.48.36:nbsession ESTABLISHED<br> TCPCORP1:1241 172.16.48.101:nbsessionESTABLISHED<br> UDPCORP1:1025 *:*<br> UDPCORP1:snmp *:*<br> UDPCORP1:nbname *:*<br> UDPCORP1:nbdatagram *:*<br> UDPCORP1:nbname *:*<br> UDPCORP1:nbdatagram *:*<br> C:\>netstat -s<br> IP Statistics<br> Packets Received = 5378528<br> Received Header Errors = 738854<br> Received Address Errors= 23150<br> Datagrams Forwarded= 0<br> Unknown Protocols Received = 0<br> Received Packets Discarded = 0<br> Received Packets Delivered = 4616524<br> Output Requests= 132702<br> Routing Discards = 157<br> Discarded Output Packets = 0<br> Output Packet No Route = 0<br> Reassembly Required= 0<br> Reassembly Successful = 0<br> Reassembly Failures =<br> Datagrams Successfully Fragmented = 0<br> Datagrams Failing Fragmentation = 0<br> Fragments Created = 0<br> ICMP Statistics<br> ReceivedSent<br> Messages 693 4<br> Errors 0 0<br> Destination Unreachable685 0f</p><p align="left" style="margin-top: 0px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 21px; "> Time Exceeded0 0<br> Parameter Problems 0 0<br> Source Quenches0 0<br> Redirects0 0<br> Echoes 4 0<br> Echo Replies 0 4<br> Timestamps 0 0<br> Timestamp Replies0 0<br> Address Masks0 0<br> Address Mask Replies 0 0<br> TCP Statistics<br> Active Opens = 597<br> Passive Opens= 135<br> Failed Connection Attempts = 107<br> Reset Connections= 91<br> Current Connections= 8<br> Segments Received= 106770<br> Segments Sent= 118431<br> Segments Retransmitted = 461<br> UDP Statistics<br> Datagrams Received = 4157136<br> No Ports = 351928<br> ReceiveErrors = 2<br> Datagrams Sent = 13809<br> 2、Netstat的妙用<br> 经常上网的人一般都使用ICQ的,不知道我们有没有被一些讨厌的人骚扰,想投诉却又不知从和下手?其实,我们只要知道对方的IP,就可以向他所属的ISP投诉了。但怎样才能通过ICQ知道对方的IP呢?如果对方在设置ICQ时选择了不显示IP地址,那我们是无法在信息栏中看到的。其实,我们只需要通过Netstat就可以很方便的做到这一点:当他通过ICQ或其他的工具与我们相连时(例如我们给他发一条ICQ信息或他给我们发一条信息),我们立刻在DOS 命令提示符下输入netstat -n或netstat -a就可以看到对方上网时所用的IP或ISP域名了,甚至连所用Port都完全暴露了。</p></span></span></div>
页:
[1]