三层交换机是现代企业网络中常用的设备之一,它能够实现高速转发和智能路由功能,为企业提供高效、稳定的网络服务。本次实训内容为对一台三层交换机进行配置和管理,通过学习掌握三层交换机的基本操作和命令,以及了解VLAN划分、静态路由和ACL等概念和应用。
一、环境搭建
1.硬件环境:Cisco Catalyst 3650系列三层交换机
2.软件环境:SecureCRT终端模拟器、TFTP服务器
3.实验拓扑图:
二、基础配置
- 进入用户 EXEC 模式:
Switch>enable Switch#
- 进入特权 EXEC 模式:
Switch#configure terminal Enter configuration commands, one per line. End with CNTL/Z.
- 配置主机名:
Switch(config)#hostname S1
- 配置密码:
S1(config)#enable secret class S1(config)#line console 0 S1(config-line)#password cisco S1(config-line)#login
- 设置端口IP地址:
S1(config)#interface vlan 10 S1(config-if)#ip address 192.168.10.254 255.255.255.0 S1(config-if)#no shutdown
6.VLAN设置:
创建 VLAN20 和 VLAN30,并将 FastEthernet0/2 接口划分到 VLAN20 中,将 FastEthernet0/3 接口划分到 VLAN30 中。
S1(config)#vlan 20 S1(config-vlan)#name Sales
S1(config)#vlan 30 S1(config-vlan)#name HR
S1(config-if)#interface FastEthernet0/2 S1(config-if)#switchport mode access S1(config-if)#switchport access vlan 20
S1(config-if)#interface FastEthernet0/3 S1(config-if)#switchport mode access S1(config-if)#switchport access vlan 30
- 配置端口描述:
将 FastEthernet0/2 的描述设置为 Sales_Department,FastEthernet0/3 的描述设置为 HR_Department。
S1(config-if)#interface FastEthernet0/2 S1(config-if)#description Sales_Department
S1(config-if)#interface FastEthernet0/3 S1(config-if)#description HR_Department
- 禁止不需要的端口:
将所有未使用的端口全部禁用。
Switch#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Switch (config) # interface range fa0/4-24 Switch (config-int-range) # shutdown
- 设置时钟和时区:
设置设备的时钟和时区。
Switch# configure terminal Enter configuration commands, one per line. End with CNTL/Z. Switch (config) # clock timezone EST -5 Switch (config) # clock summer-time EDT recurring
三、静态路由配置
静态路由是手动配置的路由,通过手动配置来实现数据包在网络中的转发。当出现网络故障或者链路发生变化时,需要重新配置。在实际应用中,静态路由常用于小型网络或者特定的网络环境中。下面是静态路由的配置过程。
- 配置路由:
设置默认网关。
S1(config)#ip route 0.0.0.0 0.0.0.0 192.168.10.1
2.VLAN间互通:
为了使 VLAN20 和 VLAN30 能够相互通信,需要添加一条静态路由。
S1(config)#ip routing S1(config)#interface vlan 20 S1(config-if)#ip address 192.168.20.254 255.255.255.0 S1(config-if)#no shutdown
S1(config-if)#interface vlan 30 S1(config-if)#ip address 192.168.30.254 255.255.255.
3.Switch# configure terminal Enter configuration commands, one per line.End with CNTL/Z. Switch (config) # ip route 192 .168 .40 .0 /24 192 .168 .50 .2
4.Switch#show ip route Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D- EIGRP , EX - EIGRP external, O- OSPF, IA- OSPF inter area N1- OSPF NSSA external type 1,N2- OSPF NSSA external type2 E1-EIGRP external type l,E2-EIGRP external type2 i - IS-IS Ll-L level-l IS-IS,L2-L level-2 IS-IS ia - IS-IS inter area su-SUBNET,DG-GATEWAY,DHCP,-MANUAL Gateway of last resort is 192.168.10.1 to network 0.0.0.0
S* 0.0.0.0/0 [1⁄0] via 192.168.10 .1
192 .168 .10 .0 /24 is directly connected, Vlan10
192 .168 .20 .0 /24 is directly connected, Vlan20
C 192 .168 .30 .254 /24 is directly connected, Vlan30
四、ACL配置
访问控制列表(ACL)是一种用于控制网络流量的机制,它可以实现对进入或者离开网络的数据包进行过滤和限制。通过配置 ACL,可以提高网络安全性和管理效率。下面是 ACL 的配置过程。
- 配置 ACL:
为 VLAN20 和 VLAN30 分别创建一个名为 Sales_ACL 和 HR_ACL 的 ACL,并设置允许和拒绝不同类型的流量。
S1(config)#access-list 101 permit ip any any S1(config)#access-list 102 deny tcp any host 192.168.20.100 eq www S1(config)#access-list 102 permit ip any any
2.VLAN应用ACL:
将 Sales_ACL 应用到 VLAN20 上,将 HR_ACL 应用到 VLAN30 上。
S1(config-if)#interface vlan 20 S1(config-if)#ip access-group Sales_ACL in
S1(config-if)#interface vlan 30 S1(config-if)#ip access-group HR_ACL in
3.Switch# configure terminal Enter configuration commands, one per line.End with CNTL/Z. Switch (config) # access-list 101 permit tcp host 192 .168 .50.2 any eq ssh Switch (config) # access-list 101 permit icmp any any
五、总结
通过本次实训,我学习了三层交换机的基础配置和管理,掌握了 VLAN 划分、静态路由和 ACL 等重要概念和应用。在实践操作中,我遇到了不少问题,但通过查阅资料和请教老师同学的帮助,最终成功完成了各项任务。在今后的工作中,我将进一步加强对网络知识的学习和掌握,为企业提供更加高效、稳定的网络服务。