拓扑如下:
【1】、设置pc的IP地址
【2】、配置交换机SW1
Switch>enSwitch#conf tSwitch(config)#vlan 2Switch(config-vlan)#exit Switch(config)#vlan 3Switch(config-vlan)#exitSwitch(config)#int f0/1Switch(config-if)#switchport mode access Switch(config-if)#switchport access vlan 2Switch(config-if)#no shutdown Switch(config-if)#int f0/2Switch(config-if)#switchport mode access Switch(config-if)#switchport access vlan 3Switch(config-if)#no shutdown Switch(config-if)#int f0/24Switch(config-if)#switchport mode trunk Switch(config-if)#switchport trunk allowed vlan all Switch(config-if)#no shutdown Switch(config-if)#
【3】、配置交换机SW2
Switch>enSwitch#conf tSwitch(config)#vlan 2Switch(config-vlan)#exit Switch(config)#vlan 3Switch(config-vlan)#exit Switch(config)#int f0/1Switch(config-if)#switchport mode access Switch(config-if)#switchport access vlan 2Switch(config-if)#no shutdown Switch(config)#int f0/2Switch(config-if)#switchport mode access Switch(config-if)#switchport access vlan 3Switch(config-if)#no shutdown Switch(config-if)#int f0/3Switch(config-if)#switchport mode access Switch(config-if)#switchport access vlan 2Switch(config-if)#no shutdown Switch(config-if)#int f0/24Switch(config-if)#switchport mode trunk Switch(config-if)#switchport trunk allowed vlan all Switch(config-if)#no shutdown Switch(config-if)#
【4】、配置三层交换机SW3
Switch>enSwitch#conf tSwitch(config)#ip routing Switch(config)#vlan 2Switch(config-vlan)#exit Switch(config)#vlan 3Switch(config-vlan)#exitSwitch(config)#int g0/1Switch(config-if)#switchport mode trunk Switch(config-if)#switchport trunk allowed vlan all Switch(config-if)#no shutdown Switch(config-if)#int g0/2Switch(config-if)#switchport mode trunk Switch(config-if)#switchport trunk allowed vlan allSwitch(config-if)#no shutdown Switch(config-if)#exitSwitch(config)#int vlan 2Switch(config-if)#ip add 192.168.100.100 255.255.255.0Switch(config-if)#no shutdown Switch(config-if)#exitSwitch(config)#int vlan 3Switch(config-if)#ip add 10.100.100.100 255.255.255.0Switch(config-if)#no shutSwitch(config-if)#
【5】、实验结果(发现vlan2 中的pc1可以ping通vlan3中的pc4)