## 划分VLAN
S1(config)#vlan 10
S1(config-vlan)#exit
S1(config)#int f0/1
S1(config-if)#switchport access vlan 10
S1(config-if)#int f0/2
S1(config-if)#switchport access vlan 20## 配置VLAN10和VLAN20网关
S1(config)#int vlan 10
S1(config-if)#no shutdown
S1(config-if)#ip address 192.168.1.254 255.255.255.0
S1(config)#int vlan 20
S1(config-if)#no shutdown
S1(config-if)#ip address 192.168.2.254 255.255.255.0## 配置三层交换,配置命令为
S1(config)#ip routing## 检查S1 上的路由表,配置命令为
S1#show ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR
P - periodic downloaded static route
Gateway of last resort is not set
C 192.168.1.0/24 is directly connected, Vlan10
C 192.168.2.0/24 is directly connected, Vlan20
## 第一个ICMP包被丢弃后,路由器通过ARP广播更新ARP缓存表,找到PC1和PC2的MAC地址
Switch#show arp
Protocol Address Age (min) Hardware Addr Type Interface
Internet 192.168.1.1 20 0003.E450.039D ARPA Vlan10
Internet 192.168.1.254 - 00D0.974B.4301 ARPA Vlan10
Internet 192.168.2.1 20 0001.971C.AAD1 ARPA Vlan20
Internet 192.168.2.254 - 00D0.974B.4302 ARPA