思科Catalyst 4503交换机作为企业级核心或汇聚层设备,其配置需结合业务需求进行精细化操作,以下从基础配置、接口管理、VLAN划分、路由协议、安全策略及高可用性六个维度,详细解析常用配置命令及注意事项。

基础配置
首次登录交换机通常需通过Console线连接,使用超级用户权限(默认为enable密码)进入配置模式,基础配置包括设备名称、管理IP及登录权限设置:
Switch> enable // 进入特权模式 Switch# configure terminal // 进入全局配置模式 Switch(config)# hostname SW-Core // 设置设备名称 Switch(config)# enable secret Cisco123 // 设置加密的enable密码 Switch(config)# interface vlan1 // 进入管理接口(默认VLAN) Switch(config-if)# ip address 192.168.1.1 255.255.255.0 // 配置管理IP Switch(config-if)# no shutdown // 启用接口 Switch(config-if)# exit Switch(config)# ip default-gateway 192.168.1.254 // 设置默认网关
需注意,VLAN1是默认管理VLAN,生产环境中建议创建独立VLAN(如VLAN 100)用于管理,并通过interface vlan100
切换。
接口管理
4503支持多种接口类型(如千兆以太网、光纤模块),接口配置需根据物理类型选择命令:
// 配置千兆以太网接口(假设为模块1的端口1) Switch(config)# interface gigabitethernet 1/1 Switch(config-if)# description Link_to_Server1 // 添加接口描述 Switch(config-if)# speed 1000 // 设置速率(可选10/100/1000) Switch(config-if)# duplex full // 设置双工模式(half/full/auto) Switch(config-if)# no shutdown // 启用接口 // 配置光纤接口(SFP插槽) Switch(config)# interface gigabitethernet 2/1/1 Switch(config-if)# no negotiation auto // 关闭自协商(需两端匹配)
接口状态可通过show interface gigabitethernet 1/1
查看,若显示administratively down
,需检查no shutdown
命令是否执行。

VLAN划分
VLAN是实现网络隔离的核心技术,配置需先创建VLAN再分配端口:
// 创建VLAN Switch(config)# vlan 10 Switch(config-vlan)# name Sales // 命名VLAN(可选) Switch(config-vlan)# exit Switch(config)# vlan 20 Switch(config-vlan)# name HR // 将端口划入VLAN(以access模式为例) Switch(config)# interface range gigabitethernet 1/1-24 // 批量配置端口 Switch(config-if-range)# switchport mode access // 设置为接入模式 Switch(config-if-range)# switchport access vlan 10 // 分配到VLAN 10
若端口需连接其他交换机(Trunk模式),需配置:
Switch(config)# interface gigabitethernet 2/1 Switch(config-if)# switchport mode trunk // 设置为中继模式 Switch(config-if)# switchport trunk allowed vlan 10,20 // 允许的VLAN列表 Switch(config-if)# switchport trunk encapsulation dot1q // 封装协议(默认ISL,建议改用802.1Q)
路由协议配置
4503作为三层交换机,支持静态路由和动态路由协议(如OSPF):
// 静态路由配置 Switch(config)# ip route 0.0.0.0 0.0.0.0 192.168.1.254 // 默认路由 // OSPF配置(以区域0为例) Switch(config)# router ospf 10 Switch(config-router)# router-id 1.1.1.1 // 设置Router ID(建议手动配置) Switch(config-router)# network 192.168.1.0 0.0.0.255 area 0 // 宣告直连网段 Switch(config-router)# passive-interface vlan100 // 设置管理VLAN为被动接口(不发送OSPF报文)
OSPF网络区域划分需根据网络拓扑设计,通常核心层设备属于Area 0。

安全策略配置
为提升网络安全性,需配置端口安全、ACL及SSH登录:
// 端口安全(限制MAC地址数量) Switch(config)# interface gigabitethernet 1/1 Switch(config-if)# switchport port-security // 启用端口安全 Switch(config-if)# switchport port-security maximum 2 // 最多允许2个MAC地址 Switch(config-if)# switchport port-security violation shutdown // 违规关闭端口 // 标准ACL配置(限制VLAN 10访问服务器) Switch(config)# access-list 1 deny 192.168.10.0 0.0.0.255 Switch(config)# access-list 1 permit any Switch(config)# interface vlan 20 Switch(config-if)# ip access-group 1 in // 在入方向应用ACL // SSH登录配置(替代Telnet) Switch(config)# ip domain-example.com // 设置域名 Switch(config)# crypto key generate rsa // 生成RSA密钥 Switch(config)# line vty 0 15 Switch(config-line)# transport input ssh // 只允许SSH Switch(config-line)# login local // 使用本地用户认证 Switch(config-line)# username admin secret Admin@123 // 创建用户
高可用性配置
4503支持HSRP(热备份路由协议)实现网关冗余:
// 在VLAN 10接口配置HSRP Switch(config)# interface vlan10 Switch(config-if)# standby 10 ip 192.168.10.254 // 虚拟IP Switch(config-if)# standby 10 priority 110 // 优先级(默认100,数值高为活跃) Switch(config-if)# standby 10 preempt // 开启抢占模式 Switch(config-if)# standby 10 authentication md5 key-string CiscoHSRP // 认证密钥
另一台交换机需配置相同虚拟IP但优先级略低(如100),确保主备切换。
配置命令速查表
功能分类 | 命令示例 | 说明 |
---|---|---|
基础设置 | hostname SW-Core |
设置设备名称 |
enable secret Cisco123 |
设置加密enable密码 | |
接口管理 | interface gigabitethernet 1/1 |
进入接口模式 |
description Link_to_Server1 |
添加接口描述 | |
VLAN配置 | vlan 10 |
创建VLAN 10 |
switchport access vlan 10 |
将端口划入VLAN 10 | |
路由配置 | ip route 0.0.0.0 0.0.0.0 192.168.1.254 |
配置默认路由 |
router ospf 10 |
启动OSPF进程 | |
安全策略 | switchport port-security maximum 2 |
限制端口最大MAC数 |
username admin secret Admin@123 |
创建SSH登录用户 | |
高可用性 | standby 10 ip 192.168.10.254 |
配置HSRP虚拟IP |
相关问答FAQs
Q1: 如何查看4503交换机的VLAN配置信息?
A: 可通过以下命令查看:
show vlan brief
:显示所有VLAN及其对应端口摘要。show running-config | include vlan
:查看当前配置中与VLAN相关的命令。
若需查看特定VLAN的详细信息,使用show vlan id [VLAN号]
。
Q2: 交换机端口无法正常通信,如何排查?
A: 排查步骤如下:
- 检查物理层:确认端口
no shutdown
状态,使用show interface [接口名]
查看line protocol
是否为up
,检查网线及光模块是否正常。 - 检查VLAN配置:确认端口模式(access/trunk)及所属VLAN是否正确,
show running-config interface [接口名]
查看端口配置。 - 检查IP及路由:若为三层接口,确认IP地址配置及路由表是否可达,
show ip route
查看路由条目。 - 检查安全策略:确认ACL或端口安全未阻断流量,
show ip access-lists
或show port security
查看规则匹配情况。
通过以上步骤,可系统化定位并解决端口通信问题。