先上拓扑图
PC1配置
PC2配置
SW1配置
<Huawei>u t m
Info: Current terminal monitor is off.
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname SW1
[SW1]vlan batch 10 20
Info: This operation may take a few seconds. Please wait for a moment...done.
[SW1]interface Vlanif 10
[SW1-Vlanif10]ip address 192.168.1.254 24
[SW1-Vlanif10]q
[SW1]interface Vlanif 20
[SW1-Vlanif20]ip address 192.168.12.1 30
[SW1-Vlanif20]q
[SW1]interface GigabitEthernet 0/0/1
[SW1-GigabitEthernet0/0/1]port link-type access
[SW1-GigabitEthernet0/0/1]port default vlan 10
[SW1-GigabitEthernet0/0/1]q
[SW1]interface GigabitEthernet 0/0/2
[SW1-GigabitEthernet0/0/2]port link-type trunk
[SW1-GigabitEthernet0/0/2]port trunk allow-pass vlan 20
[SW1-GigabitEthernet0/0/2]q
SW2配置
<Huawei>u t m
Info: Current terminal monitor is off.
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sysn SW2
[SW2]vlan batch 10 20
Info: This operation may take a few seconds. Please wait for a moment...done.
[SW2]interface Vlanif 10
[SW2-Vlanif10]ip add 192.168.2.254 24
[SW2-Vlanif10]q
[SW2]interface Vlanif 20
[SW2-Vlanif20]ip add 192.168.12.2 30
[SW2-Vlanif20]q
[SW2]int g0/0/2
[SW2-GigabitEthernet0/0/2]port link-type trunk
[SW2-GigabitEthernet0/0/2]port trunk allow-pass vlan 20
[SW2-GigabitEthernet0/0/2]q
[SW2]int g0/0/1
[SW2-GigabitEthernet0/0/1]port link-type access
[SW2-GigabitEthernet0/0/1]port default vlan 10
[SW2-GigabitEthernet0/0/1]q
配置静态路由
SW1配置
[SW1]ip route-static 192.168.2.0 24 192.168.12.2
SW2配置
[SW2]ip route-static 192.168.1.0 24 192.168.12.1
PC1 ping PC2
在SW1 G0/0/1口进行抓包查看 PC1到SW1
源mac Source: PC1 (54:89:98:b1:14:62)
目的mac Destination: SW1 (4c:1f:cc:0f:6d:ef)源IP Source: 192.168.1.1
目的IP Destination: 192.168.2.1
在SW2 G0/0/2口进行抓包查看 SW1到SW2
源mac Source: SW1 (4c:1f:cc:0f:6d:ef)
目的mac Destination: SW2(4c:1f:cc:92:71:c6)源IP Source: 192.168.1.1
目的IP Destination: 192.168.2.1
在PC2 e0/0/1口进行抓包查看SW2到PC2
源mac Source: SW2 (4c:1f:cc:92:71:c6)
目的mac Destination:PC2 (54:89:98:d5:4c:46)
源IP Source: 192.168.1.1
目的IP Destination: 192.168.2.1
PC2 ping PC1
PC2-SW2
SW2-SW1
SW1-PC1
MAC地址表
结论:无NAT情况下通信过程中,数据包中源、目的IP不会发生改变,会发生变化的是源、目的mac地址。