【网络拓扑】
【实验环境】
(1)在交换机1端口1上接PC1,端口2上接PC2
(2)配置PC1和PC2两台主机的IP地址:
PC1为:192.168.10.1
PC2为:192.168.20.1
(3)同理在交换机2的端口1上接PC3,端口2上接PC4
(4)配置PC3和PC4两台主机的IP地址:
PC3为:192.168.10.3
PC4为:192.168.20.4
(5)将交换机1和交换机2的24号端口连接起来(用交叉线,若能自识别,也可用直通线)
图示
左边交换机配置:
Switch#configure terminal//进入全局模式
Switch(config)#vlan 10//划分vlan 10
Switch(config-vlan)#exit
Switch(config)#vlan 20//划分vlan 20
Switch(config-vlan)#exit
Switch(config)#interface fastEthernet 0/1//进入接口模式
Switch(config-if)#switchport access vlan 10//将接口加入到vlan 10
Switch(config-if)#interface fastEthernet 0/2
Switch(config-if)#switchport access vlan 20
Switch(config)#interface fastEthernet 0/24
Switch(config-if)#switchport mode trunk//设置trunk
配置结果:
Switch#show vlan
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa0/3, Fa0/4, Fa0/5, Fa0/6
Fa0/7, Fa0/8, Fa0/9, Fa0/10
Fa0/11, Fa0/12, Fa0/13, Fa0/14
Fa0/15, Fa0/16, Fa0/17, Fa0/18
Fa0/19, Fa0/20, Fa0/21, Fa0/22
Fa0/23
10 VLAN0010 active Fa0/1
20 VLAN0020 active Fa0/2
1002 fddi-default act/unsup
1003 token-ring-default act/unsup
1004 fddinet-default act/unsup
1005 trnet-default act/unsup
右边交换机配置:
Switch#configure terminal//进入全局模式
Switch(config)#vlan 10//划分vlan 10
Switch(config-vlan)#exit
Switch(config)#vlan 20//划分vlan 20
Switch(config-vlan)#exit
Switch(config)#interface fastEthernet 0/1//进入接口模式
Switch(config-if)#switchport access vlan 10//将接口加入到vlan 10
Switch(config-if)#interface fastEthernet 0/2
Switch(config-if)#switchport access vlan 20
Switch(config)#interface fastEthernet 0/24
Switch(config-if)#switchport mode trunk//设置trunk
配置结果:
Switch#show vlan
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa0/3, Fa0/4, Fa0/5, Fa0/6
Fa0/7, Fa0/8, Fa0/9, Fa0/10
Fa0/11, Fa0/12, Fa0/13, Fa0/14
Fa0/15, Fa0/16, Fa0/17, Fa0/18
Fa0/19, Fa0/20, Fa0/21, Fa0/22
Fa0/23
10 VLAN0010 active Fa0/1
20 VLAN0020 active Fa0/2
1002 fddi-default act/unsup
1003 token-ring-default act/unsup
1004 fddinet-default act/unsup
1005 trnet-default act/unsup
按照要求从左往右依次配上相应的ip
验证结果: