liurhyme 发表于 2011-12-21 08:43

ARP(地址解析协议)

<font class="Apple-style-span" face="arial, 宋体, sans-serif"><span class="Apple-style-span" style="line-height: 24px;"><font class="Apple-style-span" color="#F00000">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<span class="Apple-style-span" style="font-size: large;"><font class="Apple-style-span" color="#000000"><b>ARP简介</b></font></span></font></span></font><div><font class="Apple-style-span" face="arial, 宋体, sans-serif"><span class="Apple-style-span" style="line-height: 24px;"><font class="Apple-style-span" color="#F00000">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<b><span class="Apple-style-span" style="font-size: medium;">ARP</span></b>(Address Resolution Protocol)是地址解析协议</font>,<div class="text_pic" style="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(232, 232, 232); border-right-color: rgb(232, 232, 232); border-bottom-color: rgb(232, 232, 232); border-left-color: rgb(232, 232, 232); background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(246, 246, 246); padding-top: 5px; padding-right: 5px; padding-bottom: 3px; padding-left: 5px; margin-top: 5px; margin-right: 5px; margin-bottom: 5px; margin-left: 5px; text-align: center; float: right; position: relative; width: 199px; visibility: visible; background-position: initial initial; background-repeat: initial initial; "><a class=" pic-handle" title="查看图片" href="http://baike.baidu.com/image/27d647ee1cc1abb8b3fb9555" target="_blank" style="text-decoration: none; color: rgb(19, 110, 194); background-image: url(http://img.baidu.com/img/baike/s/zoom.gif); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; width: 14px; height: 14px; font-size: 0px; line-height: 0; display: block; position: absolute; right: 4px; bottom: 4px; 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(246, 246, 246); border-right-color: rgb(246, 246, 246); border-bottom-color: rgb(246, 246, 246); border-left-color: rgb(246, 246, 246); background-position: 0px 0px; background-repeat: no-repeat no-repeat; ">&nbsp;&nbsp;</a><a href="http://baike.baidu.com/image/27d647ee1cc1abb8b3fb9555" target="_blank" style="text-decoration: underline; color: rgb(19, 110, 194); " target="_blank"><img class="editorImg nslog:1232" title="" src="http://imgsrc.baidu.com/baike/abpic/item/27d647ee1cc1abb8b3fb9555.jpg" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; display: block; "></a><p class="pic-info" style="margin-top: 3px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 10px; padding-bottom: 0px; padding-left: 0px; color: rgb(102, 102, 102); font-size: 12px; font-family: 宋体; font-weight: normal; display: inline; word-wrap: break-word; word-break: break-all; font-style: normal; line-height: 18px; min-height: 18px; zoom: 1; "></p></div>是一种<font class="Apple-style-span" color="#800080">将IP地址转化成物理地址</font>的协议。</span></font><div><font class="Apple-style-span" face="arial, 宋体, sans-serif"><span class="Apple-style-span" style="line-height: 24px;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;从IP地址到物理地址的映射有两种方式:<font class="Apple-style-span" color="#800080">表格方式</font>和<font class="Apple-style-span" color="#800080">非表格方式</font>。 &nbsp; &nbsp; &nbsp; &nbsp; ARP具体说来就是将<font class="Apple-style-span" color="#F00000">网络层</font>(也就是相当于OSI的第三层)<font class="Apple-style-span" color="#F00000">地址解析为数据链路层</font>(也就是相当于OSI的第二层)<font class="Apple-style-span" color="#F00000">的物理地址</font>(注:此处物理地址并不一定指MAC地址)。</span></font></div></div><div><font class="Apple-style-span" face="arial, 宋体, sans-serif"><span class="Apple-style-span" style="line-height: 24px;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span></font></div><div><font class="Apple-style-span" face="arial, 宋体, sans-serif"><span class="Apple-style-span" style="line-height: 24px;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<span class="Apple-style-span" style="font-size: large;"> </span><span class="Apple-style-span" style="font-family: Arial; line-height: 22px; font-weight: bold; "><span class="Apple-style-span" style="font-size: large;">ARP原理</span></span></span></font></div><div><font class="Apple-style-span" face="arial, 宋体, sans-serif"><span class="Apple-style-span" style="line-height: 24px;"><span class="Apple-style-span" style="font-family: Arial; line-height: 22px; font-weight: bold; "><span class="Apple-style-span" style="font-size: large;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<span class="Apple-style-span" style="font-family: arial, 宋体, sans-serif; font-weight: normal; line-height: 24px; font-size: 14px; ">某机器A要向主机B发送报文,会查询本地的ARP缓存表,找到B的IP地址对应的MAC地址后,就会进行数据传输。如果未找到,则广播A一个ARP请求报文(携带主机A的IP地址Ia——物理地址Pa),请求IP地址为Ib的主机B回答物理地址Pb。网上所有主机包括B都收到ARP请求,但只有主机B识别自己的IP地址,于是向A主机发回一个ARP响应报文。其中就包含有B的MAC地址,A接收到B的应答后,就会更新本地的ARP缓存。接着使用这个MAC地址发送数据(由网卡附加MAC地址)。因此,本地高速缓存的这个ARP表是本地网络流通的基础,而且这个缓存是动态的。</span></span></span></span></font></div><div><font class="Apple-style-span" face="arial, 宋体, sans-serif"><span class="Apple-style-span" style="line-height: 24px;"><span class="Apple-style-span" style="font-family: Arial; line-height: 22px; font-weight: bold; "><span class="Apple-style-span" style="font-size: large;"><span class="Apple-style-span" style="font-family: arial, 宋体, sans-serif; font-weight: normal; line-height: 24px; font-size: 14px; "><span class="headline-content">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="Apple-style-span" style="font-size: large;">ARP协议</span></span>   &nbsp; ARP协议并不只在发送了ARP请求才接收ARP应答。当计算机接收到ARP应答数据包的时候,就会对本地的ARP缓存进行更新,将应答中的IP和MAC地址存储在ARP缓存中。因此,当局域网中的某台机器B向A发送一个自己伪造的ARP应答,而如果这个应答是<font class="Apple-style-span" color="#F00000">B冒充C伪造来的,即IP地址为C的IP,而MAC地址是伪造的</font>,则当A接收到B伪造的ARP应答后,就会更新本地的ARP缓存,这样在A看来C的IP地址没有变,而它的MAC地址已经不是原来那个了。</span></span></span></span></font></div><div><font class="Apple-style-span" face="arial, 宋体, sans-serif"><span class="Apple-style-span" style="line-height: 24px;"><span class="Apple-style-span" style="font-family: Arial; line-height: 22px; font-weight: bold; "><span class="Apple-style-span" style="font-size: large;"><span class="Apple-style-span" style="font-family: arial, 宋体, sans-serif; font-weight: normal; line-height: 24px; font-size: 14px; "><br></span></span></span></span></font></div><div><font class="Apple-style-span" face="arial, 宋体, sans-serif"><span class="Apple-style-span" style="line-height: 24px;"><br></span></font></div><div><font class="Apple-style-span" face="arial, 宋体, sans-serif"><span class="Apple-style-span" style="line-height: 24px;"><span class="Apple-style-span" style="font-family: Arial; line-height: 22px; font-weight: bold; "><span class="Apple-style-span" style="font-size: large;"><span class="Apple-style-span" style="font-family: arial, 宋体, sans-serif; font-weight: normal; line-height: 24px; font-size: 14px; ">&nbsp;&nbsp; &nbsp; &nbsp; </span><span class="Apple-style-span" style="font-family: arial, 宋体, sans-serif; line-height: 24px; ">ARP协议的工作原理&nbsp;&nbsp;</span></span></span></span></font></div><span class="Apple-style-span" style="line-height: 24px; font-family: arial, 宋体, sans-serif; "><span class="headline-content">&nbsp;&nbsp; &nbsp; &nbsp; 都有一个ARP缓存表</span></span><span class="Apple-style-span" style="line-height: 24px; font-family: arial, 宋体, sans-serif; ">  <font class="Apple-style-span" color="#F000F0">在每台装有tcp/ip协议的电脑里都有一个ARP缓存表,表里的ip地址与mac地址是一一对应的</font>,如图。<div class="spctrl" style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; "></div>  <div class="text_pic" style="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(232, 232, 232); border-right-color: rgb(232, 232, 232); border-bottom-color: rgb(232, 232, 232); border-left-color: rgb(232, 232, 232); background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(246, 246, 246); padding-top: 5px; padding-right: 5px; padding-bottom: 3px; padding-left: 5px; margin-top: 5px; margin-right: 5px; margin-bottom: 5px; margin-left: 5px; text-align: center; float: right; position: relative; width: 200px; visibility: visible; background-position: initial initial; background-repeat: initial initial; "><a class=" pic-handle" title="查看图片" href="http://baike.baidu.com/image/95afee1f2c1146efe0fe0bf7" target="_blank" style="text-decoration: none; color: rgb(19, 110, 194); background-image: url(http://img.baidu.com/img/baike/s/zoom.gif); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; width: 14px; height: 14px; font-size: 0px; line-height: 0; display: block; position: absolute; right: 4px; bottom: 4px; 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(246, 246, 246); border-right-color: rgb(246, 246, 246); border-bottom-color: rgb(246, 246, 246); border-left-color: rgb(246, 246, 246); background-position: 0px 0px; background-repeat: no-repeat no-repeat; ">&nbsp;&nbsp;</a><a href="http://baike.baidu.com/image/95afee1f2c1146efe0fe0bf7" target="_blank" style="text-decoration: underline; color: rgb(19, 110, 194); " target="_blank"><img class="editorImg nslog:1232" title="arp缓存表" src="http://imgsrc.baidu.com/baike/abpic/item/95afee1f2c1146efe0fe0bf7.jpg" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; display: block; "></a><p class="pic-info" style="margin-top: 3px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 10px; padding-bottom: 0px; padding-left: 0px; color: rgb(102, 102, 102); font-size: 12px; font-family: 宋体; font-weight: normal; display: inline; word-wrap: break-word; word-break: break-all; font-style: normal; line-height: 18px; min-height: 18px; zoom: 1; ">arp缓存表</p></div>以主机A(192.168.1.5)向主机B(192.168.1.1)发送数据为例。当发送数据时,主机A会在自己的ARP缓存表中寻找是否有目标IP地址。如果找到了,也就知道了目标的mac地址,直接把目标的mac地址写入帧里面发送就可以了;如果在ARP缓存表里面没有目标的IP地址,主机A就会在网络上发送一个广播,目标mac地址是“ff-ff-ff-ff-ff-ff”,这表示向同一网段的所有主机发出这样的询问:“192.168.1.1的mac地址是什么呀?”网络上的其他主机并不回应这一询问,只有主机B接受到这个帧时才向A作出回应:“192.168.1.1的mac地址是00-aa-0-62-c6-09。(如上表)”这样,主机A就知道了主机B的mac地址,就可以向主机B发送信息了。同时,它还更新了自己的ARP缓存表,下次再向B发送数据时,直接在ARP缓存表找就可以了。ARP缓存表采用老化的机制,在一段时间里表中的某一行没有使用,就会被删除,这样可以大大减少ARP缓存表的长度,加快查询的速度。<a name="3_2" style="text-decoration: underline; color: rgb(19, 110, 194); "></a><span class="headline-content">&nbsp;&nbsp; &nbsp; &nbsp;如何查看ARP缓存表</span>  ARP缓存表示可以查看的,也可以添加和修改。在命令提示符下,输入“arp -a”就可以查看arp缓存表的内容了。<div class="spctrl" style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; "></div>  用“arp -d”可以删除arp缓存表里的所有内容。<div class="spctrl" style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; "></div>  用“arp -s“可以手动在arp表中制定ip地址与mac地址的对应关系。</span><div><font class="Apple-style-span" face="arial, 宋体, sans-serif"><span class="Apple-style-span" style="line-height: 24px;"><span class="Apple-style-span" style="font-family: Arial; line-height: 22px; font-weight: bold; "><span class="Apple-style-span" style="font-size: large;"><span class="Apple-style-span" style="font-family: arial, 宋体, sans-serif; font-weight: normal; line-height: 24px; font-size: 14px; ">&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;</span></span></span></span></font></div>
页: [1]
查看完整版本: ARP(地址解析协议)