拓扑
阐述PC1 和 PC2通信
配置过程
PC1,PC2配置
AR1配置
[Huawei]sys AR1
[AR1]inte gi 0/0/1
[AR1-GigabitEthernet0/0/1]ip addr 192.168.1.254 255.255.255.0
[AR1-GigabitEthernet0/0/1]q
[AR1]inte gi 0/0/2
[AR1-GigabitEthernet0/0/2]ip addr 192.168.2.254 255.255.255.0
阐述PC1和PC2通信全过程
第一步:PC1判断通信为二层还是三层
经过网络号的比对发现通信目的地和自己的网络号不同,所以为三层通信
1100000000.10100100.00000001.0000001(192.168.1.1)<
11100000000.10100100.0000010.0000001(192.168.2.1)
11111111111.11111111.11111111.0000000
第二步:三层通信需要找网关,PC1需要发送ARP请求获取网关的MAC地址,用来二层封装目的地
AR1的GE0/0/1接口抓包
第三步:PC1封装ICMP数据包给网关
ICMP
DATA
IP
DST:192.168.2.1
SRC:192.168.1.1
Ether
DST:192.168.1.254(MAC)
SRC:192.168.1.1(MAC)
在AR1的GE0/0/1抓包
网关MAC地址:00e0-fc63-123b
第四步:AR1接受到数据包后根据IP层的目的地进行路由选择(最长匹配规则),选择从192.168.2.254接口转发流量
AR1的路由表项
[AR1]display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 10 Routes : 10
Destination/Mask Proto Pre Cost Flags NextHop Interface
127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0
127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
192.168.1.0/24 Direct 0 0 D 192.168.1.254 GigabitEthernet
0/0/1
192.168.1.254/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
192.168.1.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
192.168.2.0/24 Direct 0 0 D 192.168.2.254 GigabitEthernet
0/0/2
192.168.2.254/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/2
192.168.2.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/2
255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
路由表项:192.168.1.0/24 Direct 0 0 D 192.168.1.254(匹配失败)
1100000000.10100100.00000001.00000000(192.168.1.0)
1100000000.10100100.00000010.00000001(192.168.2.1)
1111111111.11111111.11111111.00000000
路由表项:192.168.2.0/24 Direct 0 0 D 192.168.2.254(匹配成功24位)
1100000000.10100100.00000010.00000000(192.168.1.0)
1100000000.10100100.00000010.00000001(192.168.2.1)
1111111111.11111111.11111111.00000000
路由表项:192.168.1.0/22 Direct 0 0 D 192.168.2.254(匹配成功22位)
1100000000.10100100.00000001.00000000(192.168.1.0)
1100000000.10100100.00000010.00000001(192.168.2.1)
1111111111.11111111.11111100.00000000
第五步:AR1发送请求ARP Request请求PC2的MAC地址
第六步:重新封装ICMP数据包的二层
ICMP
DATA
IP
DST:192.168.2.1
SRC:192.168.1.1
Ether
DST:192.168.2.1(MAC)
SRC:192.168.2.254(MAC)
AR1的GE0/0/2抓包