|
此文章由 economist 原创或转贴,不代表本站立场和观点,版权归 oursteps.com.au 和作者 economist 所有!转贴必须注明作者、出处和本声明,并保持内容完整
楼上两位别吵啦。
我说一下我的理解,为什么添加了 default gateway, A 就能Ping B.
ComputerA ------- ComputerB
IP: 10.1.1.1 IP: 20.1.1.1
In the above senario,ComputerA sends a Ping packet to ComputerB, following steps will happen in sequence:
1. The Ping packet will be handed down from upper layer with encapsulation.
2. when it gets to layer 3, ComputerA will encapsulate the fragment into a IP Packet. It will put it's own IP address as source address, and ComputerB's IP address as destination address. Then it will hand the packet to layer2.
3. On layer2, computerA will encapsulate the packet into a frame, by adding it's won MAC address as source address, and CompuerB's MAC address as destination. Because it doesnt not know destination MAC address, ComputerA will first check it's own ARP cache table, if it finds a match, it will use it as destination MAC field;
3.1 If a match doesn't find, it will broadcast the ARP request within it's broadcast domain. All devices within the same broadcast domain will receive a copy of the ARP request and check against its own IP address. If it matches it's own IP, it send back it's one MAC address to the originator of the ARP Reuqest; otherwise, it will discard the ARP request. Devices from a different broadcast domain (subnet) will not receive this ARP Request!!!!
3.2 If there is no response receied by CompuerA, but there is a default gateway configured, it will forward the ARP request to it's default gateway. And the default gateway will check it's routing table and if a route matches the destination IP address, it will forward this ARP request to this particular network, with it's one Source IP/Mac address in the ARP request.
if a mach is found in this step, it will send back this ARP reply to ComputerA with it's one Source IP/MAC address as destination in the ARP reply message.
So if we go back to the original question, Computer A and Computer B sits in different networks. So when Computer A sends ARP request, if there is no default gateway configured, ComputerA doesn't know how to reach the outside network (because there is no default gateway), it will drop the ARP request. Thus Ping request will time out.
If a default gateway is configured, ComputerA will forward this ARP request to it's default gateway, hope it knows how to reach the remote network. In this case, ComputerB's IP address is used as it's default gateway, so ComputerA will forward the ARP Request to ComputerB. And because the destination IP in ARP Request matches the IP address of COmpuerB, Computer B will send back it's one IP/Mac address in the ARP Reply and forward it back to ComputerA. |
评分
-
查看全部评分
|