任务 7:配置和实施交换机之间的 Trunk 链路
步骤 1:登录到 SW2 的命令行界面,清空启动配置,删除 vlan.dat,并重启,确保 SW2 回到 初始化状态
Switch>enable Switch#erase startup-config Switch#delete vlan.dat Delete filename [vlan.dat]? Delete flash:vlan.dat? [confirm] Switch#reload Proceed with reload? [confirm] --- System Configuration Dialog --- Would you like to enter the initial configuration dialog? [yes/no]:no
步骤 2:进去全局配置模式,将主机名改为“SW2”
Switch>enable Switch#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Switch(config)#hostname SW2 SW2(config)#
步骤 3:使用 interface range 命令,进入 Fa0/5-Fa0/23 的配置模式,将这些接口全部关 闭,这些接口实验中不需要
SW2(config)#interface range fastEthernet 0/5 - 23 SW2(config-if-range)#shutdown SW2(config-if-range)#exit
步骤 4:进入 Fa0/24 口,将该接口配置为 Trunk(如果需要,先指定封装为 802.1q)
SW2(config)#interface fastEthernet 0/24 SW2(config-if)#switchport trunk encapsulation dot1q //可能您输入这条命令时 报错,说明该交换机只支持 802.1q,所有不需要再明确指定了,没问题,继续往下做 SW2(config-if)#switchport mode trunk SW2(config-if)#end SW2#
步骤 5:回到 SW1 的界面,使用 interface range 命令,进入 Fa0/5-Fa0/23 的配置模式, 将这些接口全部关闭,这些接口实验中不需要
SW1(config)#interface range fastEthernet 0/5 - 23 SW1(config-if-range)#shutdown SW1(config-if-range)#exit
步骤 6:进入 SW1 的 Fa0/24,将该接口配置为 Trunk(如果需要,先指定封装为 802.1q)
SW1(config)#interface fastEthernet 0/24 SW1(config-if)#switchport trunk encapsulation dot1q //可能您输入这条命令时 报错,说明该交换机只支持 802.1q,所有不需要再明确指定了,没问题,继续往下做 SW1(config-if)#switchport mode trunk SW1(config-if)#end SW1#
步骤 7:在 SW1 的特权模式下,使用 show interface trunk 检查 Trunk 线路的状态,需要 看到“status”显示为“Trunking”
SW1#show interfaces trunk Port Mode Encapsulation Status Native vlan Fa0/24 on 802.1q trunking 1 Port Vlans allowed on trunk Fa0/24 1-1005 Port Vlans allowed and active in management domain Fa0/24 1 Port Vlans in spanning tree forwarding state and not pruned Fa0/24 1
步骤 8:在 SW2 的特权模式下,也确认 Trunk 线路正常工作
SW2#show interfaces trunk Port Mode Encapsulation Status Native vlan Fa0/24 on 802.1q trunking 1 Port Vlans allowed on trunk Fa0/24 1-1005 Port Vlans allowed and active in management domain Fa0/24 1 Port Vlans in spanning tree forwarding state and not pruned Fa0/24 1 SW2#
步骤 9:在 SW2 上创建 vlan200
SW2#configure terminal Enter configuration commands, one per line. End with CNTL/Z. SW2(config)#vlan 200 SW2(config-vlan)#exit SW2(config)#
步骤 10:将 SW2 的 Fa0/4 配置为 vlan200 的 Access 接口
SW2(config)#interface fastEthernet 0/4 SW2(config-if)#switchport mode access SW2(config-if)#switchport access vlan 200 SW2(config-if)#exit
步骤 11:登录到 R4 的界面,将主机名改为“R4”,并配置 Fa0/1(如果没有 Fa0/1,则使用 E0/1),指定 IP 为 192.168.0.4/24
Router>enable Router#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Router(config)#hostname R4 R4(config)#interface fastEthernet 0/1 R4(config-if)#ip address 192.168.0.4 255.255.255.0 R4(config-if)#no shutdown R4(config-if)#exit R4(config)#
步骤 12:使用 ping 测试,确认 R4 现在能 ping 通 R2 和 R3,说明 Trunk 链路可以帮助同一 个 vlan 的设备跨越交换机通信
R4#ping 192.168.0.2 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 192.168.0.2, timeout is 2 seconds: .!!!! Success rate is 80 percent (4/5), round-trip min/avg/max = 0/0/0 ms
R4#ping 192.168.0.3 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 192.168.0.3, timeout is 2 seconds: .!!!! Success rate is 80 percent (4/5), round-trip min/avg/max = 0/0/0 ms
R4 没法 ping 通 R1,为什么?
R4#ping 192.168.0.1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 192.168.0.1, timeout is 2 seconds: ..... Success rate is 0 percent (0/5