网络报文在传输中,必然是需要知道通讯四元组,缺一不可,因此在不知道的情况下会发送arp广播来寻找,当寻找到之后就能获取到了四元组的信息,而后开始发送。
现在有一个问题,当A发起请求,到达B,MAC地址会变吗?相信这是一个简单的问题,那么很有可能你并不是在意
答案是:网络ip地址没有发生变化,而mac地址在一直发生变化
ensp模拟一下这个环境,拓扑如下
我们利用路由器来做,分别配置不同的lo接口来模拟客户端,并且在配置不同的网段来查看一次ping请求携带的mac地址
AR1
配置如下
system-view
sysname AR1
int GigabitEthernet 0/0/0
ip a 10.100.1.10 24
dis th
int l0
ip a 1.1.1.1 32
dis th
配置OSPF,并宣告网段
ospfv3
q
ospf router-id 1.1.1.1
area 0
network 0.0.0.0 255.255.255.255
查看
dis ip int b
配置如下:
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]
[Huawei]sysname AR1
[AR1]
[AR1]int GigabitEthernet 0/0/0
[AR1-GigabitEthernet0/0/0]
[AR1-GigabitEthernet0/0/0]ip a 10.100.1.10 24
Feb 26 2022 16:35:13-08:00 AR1 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP
on the interface GigabitEthernet0/0/0 has entered the UP state.
[AR1-GigabitEthernet0/0/0]
[AR1-GigabitEthernet0/0/0]dis th
[V200R003C00]
#
interface GigabitEthernet0/0/0
ip address 10.100.1.10 255.255.255.0
#
return
[AR1-GigabitEthernet0/0/0]int l0
[AR1-LoopBack0]
[AR1-LoopBack0]ip a 1.1.1.1 32
[AR1-LoopBack0]
[AR1-LoopBack0]dis th
[V200R003C00]
#
interface LoopBack0
ip address 1.1.1.1 255.255.255.255
#
return
[AR1-LoopBack0]ospf
[AR1-ospf-1]ospf router-id 1.1.1.1
Info: The configuration succeeded. You need to restart the OSPF process to valid
ate the new router ID.
[AR1-ospf-1]
[AR1-ospf-1]area 0
[AR1-ospf-1-area-0.0.0.0]
[AR1-ospf-1-area-0.0.0.0]network 0.0.0.0 255.255.255.255
[AR1-ospf-1-area-0.0.0.0]dis ip int b
*down: administratively down
^down: standby
(l): loopback
(s): spoofing
The number of interface that is UP in Physical is 3
The number of interface that is DOWN in Physical is 1
The number of interface that is UP in Protocol is 3
The number of interface that is DOWN in Protocol is 1
Interface IP Address/Mask Physical Protocol
GigabitEthernet0/0/0 10.100.1.10/24 up up
GigabitEthernet0/0/1 unassigned down down
LoopBack0 1.1.1.1/32 up up(s)
NULL0 unassigned up up(s)
如下
AR2
system-view
sysname AR2
int GigabitEthernet 0/0/0
ip a 10.100.1.11 24
dis thi
int l0
ip a 2.2.2.2 32
dis th
配置ospf和宣告网段
ospf router-id 2.2.2.2 32
area 0
network 0.0.0.0 255.255.255.255
查看
dis ip int b
配置
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]
[Huawei]sysname AR2
[AR2]
[AR2]int GigabitEthernet 0/0/0
[AR2-GigabitEthernet0/0/0]
[AR2-GigabitEthernet0/0/0]ip a 10.100.1.11 24
[AR2-GigabitEthernet0/0/0]
Feb 26 2022 16:38:06-08:00 AR2 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP
on the interface GigabitEthernet0/0/0 has entered the UP state.
[AR2-GigabitEthernet0/0/0]
[AR2-GigabitEthernet0/0/0]dis thi
[V200R003C00]
#
interface GigabitEthernet0/0/0
ip address 10.100.1.11 255.255.255.0
#
return
[AR2-GigabitEthernet0/0/0]
[AR2-GigabitEthernet0/0/0]
[AR2-GigabitEthernet0/0/0]
[AR2-GigabitEthernet0/0/0]int l0
[AR2-LoopBack0]
[AR2-LoopBack0]ip a 2.2.2.2 32
[AR2-LoopBack0]
[AR2-LoopBack0]dis th
[V200R003C00]
#
interface LoopBack0
ip address 2.2.2.2 255.255.255.255
#
return
[AR2-LoopBack0]
[AR2-LoopBack0]
[AR2-LoopBack0]ospf router-id 2.2.2.2 32
[AR2-ospf-32]
[AR2-ospf-32]area 0
[AR2-ospf-32-area-0.0.0.0]
[AR2-ospf-32-area-0.0.0.0]network 0.0.0.0 255.255.255.255
[AR2-ospf-32-area-0.0.0.0]dis ip int b
*down: administratively down
^down: standby
(l): loopback
(s): spoofing
The number of interface that is UP in Physical is 4
The number of interface that is DOWN in Physical is 0
The number of interface that is UP in Protocol is 3
The number of interface that is DOWN in Protocol is 1
Interface IP Address/Mask Physical Protocol
GigabitEthernet0/0/0 10.100.1.11/24 up up
GigabitEthernet0/0/1 unassigned up down
LoopBack0 2.2.2.2/32 up up(s)
NULL0 unassigned up up(s)
配置完成进行协商
[AR2-GigabitEthernet0/0/1]int GigabitEthernet 0/0/0
[AR2-GigabitEthernet0/0/0]ip a 10.100.1.11 24
Feb 26 2022 16:43:45-08:00 AR2 %%01IFNET/4/LINK_STATE(l)[2]:The line protocol IP
on the interface GigabitEthernet0/0/0 has entered the UP state.
[AR2-GigabitEthernet0/0/0]
Feb 26 2022 16:43:50-08:00 AR2 %%01OSPF/4/NBR_CHANGE_E(l)[3]:Neighbor changes ev
ent: neighbor status changed. (ProcessId=8192, NeighborAddress=10.1.100.10, Neig
hborEvent=HelloReceived, NeighborPreviousState=Down, NeighborCurrentState=Init)
[AR2-GigabitEthernet0/0/0]
Feb 26 2022 16:43:50-08:00 AR2 %%01OSPF/4/NBR_CHANGE_E(l)[4]:Neighbor changes ev
ent: neighbor status changed. (ProcessId=8192, NeighborAddress=10.1.100.10, Neig
hborEvent=2WayReceived, NeighborPreviousState=Init, NeighborCurrentState=2Way)
[AR2-GigabitEthernet0/0/0]
Feb 26 2022 16:43:50-08:00 AR2 %%01OSPF/4/NBR_CHANGE_E(l)[5]:Neighbor changes ev
ent: neighbor status changed. (ProcessId=8192, NeighborAddress=10.1.100.10, Neig
hborEvent=AdjOk?, NeighborPreviousState=2Way, NeighborCurrentState=ExStart)
[AR2-GigabitEthernet0/0/0]
Feb 26 2022 16:43:50-08:00 AR2 %%01OSPF/4/NBR_CHANGE_E(l)[6]:Neighbor changes ev
ent: neighbor status changed. (ProcessId=8192, NeighborAddress=10.1.100.10, Neig
hborEvent=NegotiationDone, NeighborPreviousState=ExStart, NeighborCurrentState=E
xchange)
[AR2-GigabitEthernet0/0/0]
Feb 26 2022 16:43:50-08:00 AR2 %%01OSPF/4/NBR_CHANGE_E(l)[7]:Neighbor changes ev
ent: neighbor status changed. (ProcessId=8192, NeighborAddress=10.1.100.10, Neig
hborEvent=ExchangeDone, NeighborPreviousState=Exchange, NeighborCurrentState=Loa
ding)
[AR2-GigabitEthernet0/0/0]
Feb 26 2022 16:43:50-08:00 AR2 %%01OSPF/4/NBR_CHANGE_E(l)[8]:Neighbor changes ev
ent: neighbor status changed. (ProcessId=8192, NeighborAddress=10.1.100.10, Neig
hborEvent=LoadingDone, NeighborPreviousState=Loading, NeighborCurrentState=Full)
如下图
可以查看dis ospf peer b
[AR2-GigabitEthernet0/0/0]dis ospf per be
OSPF Process 32 with Router ID 2.2.2.2
Peer Statistic Information
----------------------------------------------------------------------------
Area Id Interface Neighbor id State
0.0.0.0 GigabitEthernet0/0/0 10.100.1.10 Full
----------------------------------------------------------------------------
l0口来模拟的是客户端电脑
AR3
system-view
sysname AR3
int GigabitEthernet 0/0/0
ip a 10.100.2.20 24
int l0
ip a 3.3.3.3 32
dis thi
dis ip int b
ospf
ospf router-id 3.3.3.3
area 0
network 0.0.0.0 255.255.255.255
AR2配置下连接AR3的接口配置
int g0/0/1
ip a 10.100.2.10 24
dis ip int b
在AR3上ping AR2的1接口
[AR3-ospf-1]ping 10.100.2.10
PING 10.100.2.10: 56 data bytes, press CTRL_C to break
Reply from 10.100.2.10: bytes=56 Sequence=1 ttl=255 time=70 ms
Reply from 10.100.2.10: bytes=56 Sequence=2 ttl=255 time=20 ms
Reply from 10.100.2.10: bytes=56 Sequence=3 ttl=255 time=20 ms
Reply from 10.100.2.10: bytes=56 Sequence=4 ttl=255 time=30 ms
Reply from 10.100.2.10: bytes=56 Sequence=5 ttl=255 time=20 ms
--- 10.100.2.10 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 20/32/70 ms
查看
dis ospf peer brief
[AR3-ospf-1]dis ospf peer brief
OSPF Process 1 with Router ID 10.100.2.20
Peer Statistic Information
----------------------------------------------------------------------------
Area Id Interface Neighbor id State
0.0.0.0 GigabitEthernet0/0/0 2.2.2.2 Full
----------------------------------------------------------------------------
回到AR2可以看到ospf已经学习到两条邻居
[AR2-GigabitEthernet0/0/1]display ospf peer brief
OSPF Process 32 with Router ID 2.2.2.2
Peer Statistic Information
----------------------------------------------------------------------------
Area Id Interface Neighbor id State
0.0.0.0 GigabitEthernet0/0/0 10.100.1.10 Full
0.0.0.0 GigabitEthernet0/0/1 10.100.2.20 Full
----------------------------------------------------------------------------
因此,我们在AR2ping AR3的地址也是没有问题的
[AR2-GigabitEthernet0/0/1]ping 10.100.2.20
PING 10.100.2.20: 56 data bytes, press CTRL_C to break
Reply from 10.100.2.20: bytes=56 Sequence=1 ttl=255 time=60 ms
Reply from 10.100.2.20: bytes=56 Sequence=2 ttl=255 time=40 ms
Reply from 10.100.2.20: bytes=56 Sequence=3 ttl=255 time=50 ms
Reply from 10.100.2.20: bytes=56 Sequence=4 ttl=255 time=20 ms
Reply from 10.100.2.20: bytes=56 Sequence=5 ttl=255 time=20 ms
--- 10.100.2.20 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 20/38/60 ms
同时我们在AR1 ping 2.2.2.2和3.3.3.3
<AR1>system-view
Enter system view, return user view with Ctrl+Z.
[AR1]ping 2.2.2.2
PING 2.2.2.2: 56 data bytes, press CTRL_C to break
Reply from 2.2.2.2: bytes=56 Sequence=1 ttl=255 time=50 ms
Reply from 2.2.2.2: bytes=56 Sequence=2 ttl=255 time=40 ms
Reply from 2.2.2.2: bytes=56 Sequence=3 ttl=255 time=30 ms
Reply from 2.2.2.2: bytes=56 Sequence=4 ttl=255 time=40 ms
Reply from 2.2.2.2: bytes=56 Sequence=5 ttl=255 time=40 ms
--- 2.2.2.2 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 30/40/50 ms
[AR1]ping 3.3.3.3
PING 3.3.3.3: 56 data bytes, press CTRL_C to break
Reply from 3.3.3.3: bytes=56 Sequence=1 ttl=254 time=70 ms
Reply from 3.3.3.3: bytes=56 Sequence=2 ttl=254 time=30 ms
Reply from 3.3.3.3: bytes=56 Sequence=3 ttl=254 time=30 ms
Reply from 3.3.3.3: bytes=56 Sequence=4 ttl=254 time=30 ms
Reply from 3.3.3.3: bytes=56 Sequence=5 ttl=254 time=30 ms
--- 3.3.3.3 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 30/38/70 ms
抓包
同时我们在AR1的0/0/0接口上抓包,右击抓包即可
我们在AR1上查看她的0/0/0的MAC地址是00e0-fc93-3157
如下
GigabitEthernet0/0/0 current state : UP
Line protocol current state : UP
Last line protocol up time : 2022-02-26 16:35:13 UTC-08:00
Description:HUAWEI, AR Series, GigabitEthernet0/0/0 Interface
Route Port,The Maximum Transmit Unit is 1500
Internet Address is 10.100.1.10/24
IP Sending Frames' Format is PKTFMT_ETHNT_2, Hardware address is 00e0-fc93-3157
Last physical up time : 2022-02-26 16:30:42 UTC-08:00
Last physical down time : 2022-02-26 16:30:19 UTC-08:00
Current system time: 2022-02-26 17:15:13-08:00
Port Mode: COMMON COPPER
Speed : 1000, Loopback: NONE
Duplex: FULL, Negotiation: ENABLE
Mdi : AUTO
Last 300 seconds input rate 72 bits/sec, 0 packets/sec
Last 300 seconds output rate 72 bits/sec, 0 packets/sec
Input peak rate 1144 bits/sec,Record time: 2022-02-26 16:44:04
Output peak rate 1032 bits/sec,Record time: 2022-02-26 16:44:04
我们在查看AR2
- 你会发现AR2的0/0/0的MAC地址是
00e0-fce5-3cb4
GigabitEthernet0/0/0 current state : UP
Line protocol current state : UP
Last line protocol up time : 2022-02-26 16:43:45 UTC-08:00
Description:HUAWEI, AR Series, GigabitEthernet0/0/0 Interface
Route Port,The Maximum Transmit Unit is 1500
Internet Address is 10.100.1.11/24
IP Sending Frames' Format is PKTFMT_ETHNT_2, Hardware address is 00e0-fce5-3cb4
Last physical up time : 2022-02-26 16:30:42 UTC-08:00
Last physical down time : 2022-02-26 16:30:34 UTC-08:00
Current system time: 2022-02-26 17:14:23-08:00
Port Mode: COMMON COPPER
Speed : 1000, Loopback: NONE
Duplex: FULL, Negotiation: ENABLE
Mdi : AUTO
Last 300 seconds input rate 72 bits/sec, 0 packets/sec
Last 300 seconds output rate 64 bits/sec, 0 packets/sec
Input peak rate 1192 bits/sec,Record time: 2022-02-26 16:44:08
Output peak rate 1128 bits/sec,Record time: 2022-02-26 16:44:08
这时候你会看到在AR1发起ping的GigabitEthernet0/0/0的mac地址是00e0-fc93-3157
,而目标是GigabitEthernet0/0/0接口的MAC地址则是AR2的00e0-fce5-3cb4
我们在AR3上仍然进行了抓包、如下
我们在AR2的GigabitEthernet0/0/1接口查看MAC地址是00e0-fce5-3cb5
GigabitEthernet0/0/1 current state : UP
Line protocol current state : UP
Last line protocol up time : 2022-02-26 16:54:46 UTC-08:00
Description:HUAWEI, AR Series, GigabitEthernet0/0/1 Interface
Route Port,The Maximum Transmit Unit is 1500
Internet Address is 10.100.2.10/24
IP Sending Frames' Format is PKTFMT_ETHNT_2, Hardware address is 00e0-fce5-3cb5
Last physical up time : 2022-02-26 16:53:02 UTC-08:00
Last physical down time : 2022-02-26 16:52:09 UTC-08:00
Current system time: 2022-02-26 17:22:03-08:00
Port Mode: COMMON COPPER
Speed : 1000, Loopback: NONE
Duplex: FULL, Negotiation: ENABLE
Mdi : AUTO
Last 300 seconds input rate 64 bits/sec, 0 packets/sec
Last 300 seconds output rate 56 bits/sec, 0 packets/sec
Input peak rate 832 bits/sec,Record time: 2022-02-26 16:55:08
Output peak rate 792 bits/sec,Record time: 2022-02-26 16:55:08
我们在去AR3 GigabitEthernet0/0/0接口查看的MAC地址是00e0-fc66-73ea
GigabitEthernet0/0/0 current state : UP
Line protocol current state : UP
Last line protocol up time : 2022-02-26 16:53:11 UTC-08:00
Description:HUAWEI, AR Series, GigabitEthernet0/0/0 Interface
Route Port,The Maximum Transmit Unit is 1500
Internet Address is 10.100.2.20/24
IP Sending Frames' Format is PKTFMT_ETHNT_2, Hardware address is 00e0-fc66-73ea
Last physical up time : 2022-02-26 16:53:01 UTC-08:00
Last physical down time : 2022-02-26 16:52:53 UTC-08:00
Current system time: 2022-02-26 17:22:54-08:00
Port Mode: COMMON COPPER
Speed : 1000, Loopback: NONE
Duplex: FULL, Negotiation: ENABLE
Mdi : AUTO
Last 300 seconds input rate 64 bits/sec, 0 packets/sec
Last 300 seconds output rate 56 bits/sec, 0 packets/sec
Input peak rate 736 bits/sec,Record time: 2022-02-26 16:55:07
Output peak rate 792 bits/sec,Record time: 2022-02-26 16:55:07
由此可见,在网络环境中,MAC地址会随着网络的跳跃点一直发生变化,而只有IP和目标IP不会发生变化。
这些信息可以在路由表查看
<AR1>dis ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 11 Routes : 11
Destination/Mask Proto Pre Cost Flags NextHop Interface
1.1.1.1/32 Direct 0 0 D 127.0.0.1 LoopBack0
2.2.2.2/32 OSPF 10 1 D 10.100.1.11 GigabitEthernet
0/0/0
3.3.3.3/32 OSPF 10 2 D 10.100.1.11 GigabitEthernet
0/0/0
10.100.1.0/24 Direct 0 0 D 10.100.1.10 GigabitEthernet
0/0/0
10.100.1.10/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
10.100.1.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
10.100.2.0/24 OSPF 10 2 D 10.100.1.11 GigabitEthernet
0/0/0
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
255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
其他
二层网络ARP报文(基础一)