100个思科交换机常用指令
2025-10-27 09:42:36
RAIZ
enable - 进入特权模式 configure terminal - 进入全局配置模式 interface fastethernet 0/1 - 进入接口配置模式 interface vlan 1 - 进入VLAN接口 line console 0 - 进入控制台线路配置 line vty 0 4 - 进入虚拟终端配置 end - 直接退出到特权模式 exit - 返回上一级模式 disable - 返回用户模式 hostname SW1 - 设置交换机主机名 reload - 重启设备
show version - 查看IOS版本和设备信息 show running-config - 查看当前运行配置 show startup-config - 查看保存的启动配置 copy running-config startup-config - 保存交换机配置 write - 保存配置信息 configure memory - 将启动配置合并到运行配置 erase startup-config - 恢复交换机出厂设置 show clock - 查看设备时间 clock datetime - 设置时间 show user - 查看在线用户
show interfaces - 查看所有接口详细状态 show ip interface brief - 查看接口IP和状态摘要 show interface status - 查看接口简要状态 show interface stats - 查看接口流量统计 show interface summary - 查看接口流量摘要 show interface GigabitEthernet0/1 - 查看指定接口信息 show interface counters - 查看接口计数器 show controllers GigabitEthernet0/1 - 查看接口物理层信息 show interfaces usage - 查看接口带宽使用率 clear counters GigabitEthernet0/1 - 清除接口计数器
enable password cisco - 设置特权模式明文密码 enable secret cisco - 设置特权模式加密密码 username admin password cisco - 创建本地用户 service password-encryption - 对所有密码进行加密 login - 要求口令验证 aaa new-model - 启用AAA认证 no enable secret - 取消特权加密密码 ip domain-name test.com - 配置域名 crypto key generate rsa - 生成RSA密钥对 transport input ssh - 设置只允许SSH登录
vlan 10 - 创建VLAN 10 name SALES - 为VLAN命名 switchport mode access - 设置端口为接入模式 switchport access vlan 10 - 将端口加入VLAN switchport mode trunk - 设置端口为中继模式 switchport trunk allowed vlan 10,20 - 设置Trunk允许的VLAN switchport trunk encapsulation dot1q - 设置Trunk封装协议 show vlan brief - 查看VLAN摘要信息 show vlan 10 - 查看指定VLAN信息 show interface trunk - 查看所有Trunk端口
spanning-tree mode rapid-pvst - 启用快速PVST+模式 spanning-tree vlan 1 root primary - 设置VLAN根桥 spanning-tree vlan 1 priority 24576 - 修改STP优先级 spanning-tree portfast - 在接入端口启用PortFast spanning-tree uplinkfast - 配置上行链路快速 show spanning-tree - 查看生成树全局状态 show spanning-tree vlan 1 - 查看指定VLAN的STP信息 show spanning-tree root - 查看生成树根位置 show spanning-tree detail - 查看STP详细信息 spanning-tree bpduguard enable - 启用BPDU保护 spanning-tree guard root - 启用根保护
interface port-channel 1 - 创建端口通道 channel-group 1 mode desirable - 配置端口聚合 show etherchannel summary - 查看端口聚合状态 show etherchannel port-channel - 查看端口通道信息 show etherchannel load-balance - 查看负载均衡方式 port-channel load-balance dst-mac - 设置负载均衡算法
show cdp neighbors - 查看CDP邻居设备 show cdp neighbors detail - 查看CDP邻居详细信息 show cdp traffic - 查看CDP流量统计 show cdp interface - 查看接口CDP配置 cdp run - 全局启用CDP no cdp run - 全局禁用CDP show lldp neighbors - 查看LLDP邻居设备 访问控制列表(ACL) access-list 1 permit 192.168.1.0 0.0.0.255 - 创建标准ACL access-list 101 permit tcp any any eq 80 - 创建扩展ACL ip access-group 1 in - 在接口应用ACL show access-lists - 查看所有ACL规则 show ip access-list - 查看IP访问列表 ip access-list extended WEB_TRAFFIC - 创建命名扩展ACL permit tcp any any eq 443 - 在命名ACL中添加规则 show ip interface - 查看接口IP配置
vtp domain COMPANY - 设置VTP域名 vtp password SECRET - 设置VTP密码 vtp mode server - 设置VTP服务器模式 vtp mode client - 设置VTP客户端模式 show vtp status - 查看VTP配置状态 show vtp password - 查看VTP密码 vtp version 2 - 设置VTP版本
show processes cpu - 查看CPU负载 show processes memory - 查看内存使用 show env all - 查看环境状态(温度、电源等) show inventory - 查看设备库存信息 show logging - 查看系统日志 show ip route - 查看路由表 show arp - 查看ARP表 show mac address-table - 查看MAC地址表 clear mac address-table - 清除MAC地址表 show port-security - 查看端口安全配置 show ip protocols - 查看路由协议信息 show firewall - 检查防火墙工作模式