思科交换机配置命令归纳

1、基本命令
switch> 用户模式
switch>enable 进入特权模式
switch# 特权模式
switch#configure terminal 进入配置模式
switch(config)# 配置模式
switch(config)#enable password [需要设置的密码] 设置特权模式密码为[需要设置的密码]
switch(config)#enable secret [需要设置的密码] 设置特权模式密码为加密的密码[需要设置的密码]
switch(config)#hostname sw1 设置主机名为sw1
sw1(config)# 主机名变为sw1
sw1(config)#end 退回到特权模式
sw1# 特权模式
sw1#exit 退回到上一个模式
sw1> 用户模式
2、常用命令
switch(config)#enable password 密码 配置交换机进入特权模式密码
switch(config)#no enable secret 取消特权模式加密密码
switch#show version 查看系统中的所有版本信息
switch#show ip int b 查看各接口状态
switch#show vlan 10 查看交换机有关vlan10配置信息
switch#show vlan int b 查看交换机所有vlan信息
switch#show running-configure 查看交换机当前起作用的配置信息
switch#show interface fastethernet0/1 查看交换机接口1具体配置和统计信息
switch#show mac address-table 查看mac地址转发表
switch#write 保存配置信息(写入配置信息)
switch#show vtp 查看vtp配置信息
switch#show run 查看当前配置信息
switch#show vlan brief 查看vlan配置信息
switch#show interface brief 查看端口信息
switch#show int f0/0 查看指定端口信息
switch#copy running-config startup-config 保存交换机配置
switch(config-if)#speed 100 设置速率
switch(config-if)#duplex full 设置该端口为全双工,full全双工 half半双工 auto为自动
switch#show ip route 查看是否有路由表,是否开启路由功能
在配置模式中无法使用show命令,如果要使用的话show前必须加do和空格例:do show ip int b
3、交换机恢复出厂配置
switch> enable
switch# erase startup-configure
switch# write erase
switch# reload
4、telnet 远程登录设置
switch>enable
switch#configure terminal
swich(conf)#enable password abc123 abc123特权模式密码(明文加密)
swich(conf)#enable secret abc123 密文加密
swich(conf)#interface vlan 1 以vlan 1端口作为远程登录的接口,其他端口亦可
swich(conf-if)#ip address 192.168.1.1 255.255.255.0
swich(conf-if)#no shut
swich(conf-if)#exit
swich(conf)line vty 0 4 设置0-4个用户可以telnet 远程登陆
swich(conf-line)#password 123456
swich(conf-line)#login 设置完成后使用
5、交换机VLAN设置
(1)添加,删除 vlan
switch#vlan database 进入vlan设置
switch(vlan)#vlan 2 建立vlan2
switch(vlan)#no vlan 2 删除vlan 2
(2)命名vlan
switch(config)# valn 2
switch(config-vlan)# name 名字
(3)将端口加入vlan
switch(config)# interface range fastethernet 0/1 – 5 进入同种类型多端口配置
switch(config)#interface range fastethernet 0/1 – 5,gigabitethernet 0/1 – 2 进入不同类型多端口配置
switch(config-if)#switchport access vlan 2 当前端口加入vlan 2
6、交换机设置VLAN IP地址
switch(config)#interface vlan 1 进入vlan 1
switch(config-if)#ip address ip地址 设置IP地址
switch(config-if)#exit
switch(config)#ip default-gateway 网关地址 设置交换机默认网关,telnet交换机时可以使用vlan ip地址连接
7、Trunk的配置
switch(config-if)#switchport trunk encap dot1q 设置vlan中继执行的协议
switch(config-if)#switchport mode trunk 将接口设置为中继
switch(config-if)#switchport trunk allowed vlan 1,2 设置允许通过的vlan
switch(config-if)#switchport trunk allowed vlan remove vlan号 禁止trunk中某个VLAN的传输
8、以太网通道配置(二层口)
switch1(config)#int range f0/1 -2 进入接口f0/1和f0/2
switch1(config-if-range)#channel-group 1 mode on 绑定
switch#show etherchannel summary 查看绑定的接口
9、以太网通道配ip地址(三层口)
switch1(config)#int port-channel 1
switch1(config-if)#ip add ip地址 子网掩码
10、VTP的配置
sw1(config)#vtp domain 域名 设置域名
sw1(config)#vtp mode server或client或transparent 设置交换机VTP模式
sw1(config)#vtp password 密码 设置服务器密码,需要同步vtp的交换机需要设相同的密码
VTP修剪

sw1(config)#vtp pruning 启动VTP修剪
sw1(config)#vtp version 2 配置VTP版本,默认1
sw1(config)#switchport trunk pruning vlan remove vlan号 从可修剪列表中去除某VLAN
例:switchport trunk pruning vlan remove 2-4,6,8
sw1#show interface pruning 查看哪些接口以及哪几个vlan被修剪了
sw1#show vtp status 查看vtp配置信息
11、三层交换机配置
(1)配置虚拟接口IP地址
switch(config)# interface vlan vlan号
switch(config-if)# ip address ip地址 子网掩码
switch(config-if)# no shutdown
(2)配置物理接口IP地址
switch(config)#ip routing 启用路由功能
switch(config)# interface f0/1
switch(config-if)#no switchport 将物理二层接口转换为物理三层接口
switch(config-if)#ip address ip地址 子网掩码
switch(config-if)# no shutdown
(3)配置DHCP中继
switch(config)#service dhcp 开启DHCP服务
switch(config-if)#ip helper-address dhcp服务器ip地址
12、STP生成树配置
启用stp生成树switch(config)#spanning-tree vlan vlan号
设置网桥优先级,值小的优先级高switch(config)#spanning-tree vlan vlan号 priority 32768{默认32768,范围0~65535}
指定根网桥switch(config)#spanning-tree vlan vlan号 root primary (primary优先级为24576,secondary优先级为28672)
指定端口成本switch(config-if)#spanning-tree vlan vlan号 cost 成本
指定交换机端口优先级switch(config-if)#spanning-tree vlan vlan号 port-prioty 优先级 {优先级0~255,默认128}
配置速端口switch(config-if)#spanning-tree portfast
查看生成树配置信息switch#show spanning-tree
查看详细生成树配置信息switch#show spanning-tree vlan detail
查看详细生成树端口配置信息switch#show spanning-tree interface f0/1 detail
查看某个VLAN生成树配置信息switch#show spanning-tree vlan vlan号 brief
13、HSRP(热备份)配置
sw1(config)#int vlan 10
sw1(config-if)#ip add 192.168.10.1 255.255.255.0
sw1(config-if)#standby hsrp组号{组号默认0,范围0~255} ip 网段网关地址 配置为hsrp成员
sw1(config-if)#standby hsrp组号 priority 200{默认100,范围0~255} 配置端口优先级
sw1(config-if)#standby hsrp组号 preempt 配置抢占权
sw1(config-if)#standby hsrp组号 track 端口类型 端口号 优先级 配置端口跟踪和减去的优先级
例:sw1(config-if)#standby 10 track fastethernet 1/1 100
sw1#show standby brief 查看hsrp的状态
sw1#show standby 端口类型 端口号 hsrp组号 brief 查看指定端口hsrp的状态

思科交换机巡检命令

show interface stats #查看交换机所有接口当前接口流量。

show running-config #查看当前设备配置。

show version #查看IOS版本信息及设备正常运行时间

show clock #查看设备时钟信息

show vtp status #查看交换机vtp配置模式

show vtp password #查看交换机vtp配置口令

show environment 查看设备环境

show environment temperature –查设备温度

show environment fans –查看设备风扇

show cpu usage 查看CPU利用率

show memory 查看内存

show perfmon 查看性能

show logging –查日志

show version  –查看系统中的所有版本信息

show processes cpu-usage –查CPU详细进程

show processes memory –查内存详细进程

show route –查路由表

show failover 查备援助线路

show nameif 查看接口

show int ip brief 查看接口状态

show vlan –查看vlan信息

show inventory #调取设备内部板卡出厂模块型号及序列号

show spanning-tree root #查看交换机生成树根位置

show cdp neighbors #查看邻接cisco设备基本信息

show cdp neighbors detail #查看邻接cisco设备详细信息

show interface status #查看交换机接口状态是否存在error disable接口disable接口

show interface summary #查看交换机所有接口当前接口流量

show interface |ierrors|FastEthernet|GigabitEthernet #查看接口是否存在大量input或output errors包错误

show processes cpu #查看设备cpu负载

show processes mem #查看设备mem负载

show access-list #查看访问控制列表配置及匹配数据包数量

show logging #查看本机内部日志记录情况

show ip route #查看路由表

show firewall #检查防火墙的工作模式

show conn count #检查防火墙并发数

show xlate count #检查防火墙nat工作状态

请登录后发表评论

    没有回复内容