三层交换机配置:
SW-R1#vlan database
SW-R1(vlan)#vlan 20 name vlan20
SW-R1(vlan)#vlan 30 name vlan30
SW-R1(vlan)#vlan 40 name vlan40
SW-R1(vlan)#exit
SW-R1#configure terminal
SW-R1(config)# ip routing
SW-R1(config)#interface FastEthernet0/1
SW-R1(config)#switchport trunk encapsulation dot1q
SW-R1(config)#switchport mode trunk
SW-R1(config-if)#exit
SW-R1(config)#interface fastEthernet 0/2
SW-R1(config-if)#no switchport
SW-R1(config-if)#ip address 1.1.1.2 255.255.255.0
SW-R1(config-if)#no shutdown
SW-R1(config-if)#exit
SW-R1(config)#interface vlan 20
SW-R1(config-if)#ip address 192.168.2.1 255.255.255.0
SW-R1(config-if)#no shutdown
SW-R1(config-if)#exit
SW-R1(config)#interface vlan 30
SW-R1(config-if)#ip address 192.168.3.1 255.255.255.0
SW-R1(config-if)#no shutdown
SW-R1(config-if)#exit
SW-R1(config)#interface vlan 40
SW-R1(config-if)#ip address 192.168.4.1 255.255.255.0
SW-R1(config-if)#no shutdown
SW-R1(config-if)#exit
SW-R1(config)#ip route 0.0.0.0 0.0.0.0 1.1.1.1
二层交换机配置:
Switch#vlan database
Switch(vlan)#vlan 20 name vlan20
Switch(vlan)#vlan 30 name vlan30
Switch(vlan)#vlan 40 name vlan40
Switch(vlan)#exit
Switch(config)#interface fastEthernet 0/1
Switch(config-if)#switchport mode trunk
Switch(config)#interface fastEthernet 0/2
Switch(config-if)#switchport access vlan 20
Switch(config-if)#exit
Switch(config)#interface fastEthernet 0/3
Switch(config-if)#switchport access vlan 30
Switch(config-if)#exit
Switch(config)#interface fastEthernet 0/4
Switch(config-if)#switchport access vlan 40
Switch(config-if)#exit