[SW1]dis cur
#
sysname SW1
#
undo info-center enable //关闭信息中心,即关闭日志同步
#
vlan batch 10 //把native vlan 设为vlan10
#
interface Vlanif1
#
interface Vlanif10
ip address 192.168.1.1 255.255.255.0
#
interface MEth0/0/1
#
interface GigabitEthernet0/0/1
port link-type access
[SW2]dis cur
#
sysname SW2
#
undo info-center enable
#
vlan batch 10
#
interface Vlanif1
#
interface Vlanif10
ip address 192.168.1.2 255.255.255.0
#
interface MEth0/0/1
#
interface GigabitEthernet0/0/1
port link-type access
1.SW1能否ping通192.168.1.2?能否ping通192.168.1.1?
2.如果交换机之间的链路换成Trunk呢?
3.Why?
其实两个IP都无法ping通,只有换成trunk链路才能ping通。
当发送数据包时,路由器和3层交换机首先要查看routing-table。
当链路为access时,我们查看路由表
[SW1]dis ip rou
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 2 Routes : 2
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
而链路为Trunk时,查看路由表
[SW1]dis ip rou
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 4 Routes : 4
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
192.168.1.0/24 Direct 0 0 D 192.168.1.1 Vlanif10
192.168.1.1/32 Direct 0 0 D 127.0.0.1 Vlanif10
所以,只有当链路为Trunk时,交换机才能启用三层功能,进而把接口IP与直连IP放入路由表里。