目的:实现一个三层交换机两个二层交换机同VLAN下的互访
四台PC机,配置如下:
PC0 IP 192.168.1.10 255.255.255.0 192.168.1.1 与1口连属VLAN 2
PC1 IP 192.168.1.20 255.255.255.0 192.168.1.1 与6口连属VLAN 3
PC2 IP 192.168.1.30 255.255.255.0 192.168.1.1 与1口连属VLAN 2
PC3 IP 192.168.1.40 255.255.255.0 192.168.1.1 与6口连属VLAN 3
两台二层交换机配置如下:
添加两个VLAN,分别为VLAN 2 有1-5口,VLAN 3 有6-10口,24口设置为TRUNK口,允许所有
VLAN的数据通过,并与三层交换机1、2口相连。
在此状态下,四台PC机是不通的。当数据包到达三层交换机时,就不会再转发了。
下面对三层交换机做如下配置
Switch>
Switch>enable
Switch#config
Configuring from terminal, memory, or network [terminal]?
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#interface range fa0/1-2
Switch(config-if-range)#switch mode trunk
Command rejected: An interface whose trunk encapsulation is \"Auto\" can not be configured to \"trunk\" mode.
Command rejected: An interface whose trunk encapsulation is \"Auto\" can not be configured to \"trunk\" mode.
Switch(config-if-range)#switch mode acces ‘三层交换机的口在默认情况下是
AUTO类型,只有先设置为ACCESS型,才能再设置为TRUNK型,
Switch(config-if-range)#switch mode trunk
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/2, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/2, changed state to up
Switch(config-if-range)#switch trunk allowed vlan all ‘允许所有的VLAN通过
Switch(config-if-range)#
此时再测试四台pc机的联通性。
192.168.1.10与192.168.1.30通 192.168.1.20与192.168.1.40通
因篇幅问题不能全部显示,请点此查看更多更全内容