|
思科交换机配置命令(陆小马公众号) | |||
|
简写命令 |
完整命令 | ||
|
1 |
用户模式: |
用户模式: | |
|
switch> |
switch> | ||
|
2 |
特权模式: |
特权模式: | |
|
switch>en |
switch>enable | ||
|
switch# |
switch# | ||
|
3 |
全局配置模式 |
全局配置模式 | |
|
switch#conf t |
switch#config terminal | ||
|
switch(config)# |
switch(config)# | ||
|
4 |
接口配置模式 |
接口配置模式 | |
|
switch(config)#in f0/1 |
switch(config)#interface f0/1 | ||
|
switch(config-if)# |
switch(config-if)# | ||
|
5 |
line模式: |
line模式: | |
|
switch(config)#lin c 0 |
switch(config)#line console 0 | ||
|
switch(config-line)# |
switch(config-line)# | ||
|
6 |
更改交换机主机名 |
更改交换机主机名 | |
|
switch(config)#ho benet |
switch(config)#hostname benet | ||
|
benet(config)# |
benet(config)# | ||
|
7 |
配置进入特权模式的明文口令 |
配置进入特权模式的明文口令 | |
|
switch(config)#en pass 123 |
switch(config)#enable password 123 | ||
|
8 |
删除进入特权模式的明文口令 |
删除进入特权模式的明文口令 | |
|
switch(config)#no ena pass |
switch(config)#no enable password | ||
|
9 |
配置进入特权模式的加密口令 |
配置进入特权模式的加密口令 | |
|
switch(config)#en se 456 |
switch(config)#enable secret 456 | ||
|
10 |
删除进入特权模式的加密口令 |
删除进入特权模式的加密口令 | |
|
switch(config)#no ena se |
switch(config)#no enable secret | ||
|
11 |
查看交换机配置 |
查看交换机配置 | |
|
switch#sh run |
switch#show running-config | ||
|
12 |
配置console口令 |
配置console口令 | |
|
switch(config)#lin cons 0 |
switch(config)#line console 0 | ||
|
switch(config-line)#pass 123 |
switch(config-line)#password 123 | ||
|
switch(config-line)#logi |
switch(config-line)#login | ||
|
13 |
配置交换机IP地址 |
配置交换机IP地址 | |
|
switch(config)#in vl 1 |
switch(config)#interface vlan 1 | ||
|
switch(config-if)#ip ad 192.168.0.2 255.255.255.0 |
switch(config-if)#ip address 192.168.0.2 255.255.255.0 | ||
|
switch(config-if)#no sh |
switch(config-if)#no shutdown | ||
|
14 |
删除交换机接口IP地址 |
删除交换机接口IP地址 | |
|
switch(config-if)#no ip ad |
switch(config-if)#no ip address | ||
|
15 |
配置交换机默认网关 |
配置交换机默认网关 | |
|
switch(config)#ip default-g 192.168.0.1 |
switch(config)#ip default-gateway 192.168.0.1 | ||
|
16 |
查看交换机的MAC地址表 |
查看交换机的MAC地址表 | |
|
switch#sh mac-a |
switch#show mac-address-table | ||
|
17 |
查看思科交换机相邻设备的详细信息 |
查看思科交换机相邻设备的详细信息 | |
|
switch#sh cdp nei de |
switch#show cdp neighbors detail | ||
|
18 |
保存交换机配置 |
保存交换机配置 | |
|
1:switch#cop run st |
1:switch#copy running-config startup-config | ||
|
2:switch#wr |
2:switch#write | ||
|
19 |
恢复交换机出厂配置 |
恢复交换机出厂配置 | |
|
switch#er st |
switch#erase startup-config | ||
|
switch#relo |
switch#reload | ||
|
20 |
创建VLAN |
创建VLAN | |
|
switch#vl da |
switch#vlan database | ||
|
switch(vlan)#vl 30 |
switch(vlan)#vlan 30 | ||
|
switch(vlan)#exit |
switch(vlan)#exit | ||
|
21 |
VLAN重命名 |
VLAN重命名 | |
|
switch(vlan)#vl 20 n benet |
switch(vlan)#vlan 20 name benet | ||
|
VLAN 20 modified: |
VLAN 20 modified: | ||
|
Name: benet |
Name: benet | ||
|
22 |
删除VLAN |
删除VLAN | |
|
switch(vlan)#n vl 20 |
switch(vlan)#no vlan 20 | ||
|
Deleting VLAN 2... |
Deleting VLAN 2... | ||
|
switch(vlan)#e |
switch(vlan)#exit | ||
|
|
简写命令 |
完整命令 | |
|
23 |
将端口加入到VLAN |
将端口加入到VLAN | |
|
switch(config)#in f0/2 |
switch(config)#interface f0/2 | ||
|
switch(config-if)#sw a v 30 |
switch(config-if)#switchport access vlan 30 | ||
|
24 |
验证VLAN配置信息 |
验证VLAN配置信息 | |
|
switch#sh vlan b |
switch#show vlan brief | ||
|
switch#sh vlan-s |
switch#show vlan-switch | ||
|
25 |
删除VLAN中的端口 |
删除VLAN中的端口 | |
|
1:switch(config-if)#no sw a v 3 |
1:switch(config-if)#no switchport access vlan 3 | ||
|
switch(config-if)#end |
switch(config-if)#end | ||
|
2:switch(config-if)#def interface f0/2 |
2:switch(config-if)#default interface f0/2 | ||
|
Building configuration... |
Building configuration... | ||
|
Interface FastEthernet0/2 set to default configuration |
Interface FastEthernet0/2 set to default configuration | ||
|
switch(config)#end |
switch(config)#end | ||
|
26 |
同时将多个端口加入VLAN并验证 |
同时将多个端口加入VLAN并验证 | |
|
switch(config)#in r f0/3 - 10 |
switch(config)#interface range f0/3 - 10 | ||
|
switch(config-if-range)#sw a v 3 |
switch(config-if-range)#switchport access vlan 3 | ||
|
switch(config)#end |
switch(config)#end | ||
|
switch#sh vlan-s |
switch#show vlan-switch | ||
|
27 |
配置VLAN TRUHK 并添加协议 |
配置VLAN TRUHK 并添加协议 | |
|
switch(config)#in f0/15 |
switch(config)#interface f0/15 | ||
|
switch(config-if)#sw m t |
switch(config-if)#switchport mode trunk | ||
|
Switch(config-if)#sw tr en do |
Switch9config-if)#switchport trunk encapsulatinon dotlq | ||
|
28 |
从TRUNK中添加某个VLAN |
从TRUNK中添加某个VLAN | |
|
switch(config)#in f0/15 |
switch(config)#interface f0/15 | ||
|
switch(config-if)#sw t a v ad 3 |
switch(config-if)#switchport trunk allowed vlan add 3 | ||
|
switch(config-if)#end |
switch(config-if)#end | ||
|
29 |
从TRUNK中删除某个VLAN |
从TRUNK中删除某个VLAN | |
|
switch(config)#in f0/15 |
switch(config)#interface f0/15 | ||
|
switch(config-if)#sw t a v r 3 |
switch(config-if)#switchport trunk allowed vlan remove 3 | ||
|
switch(config-if)#end |
switch(config-if)#end | ||
|
30 |
验证接口模式(检查中断端口允许的VLAN列表) |
验证接口模式(检查中断端口允许的VLAN列表) | |
|
switch#sh int f0/15 switchp |
switch#show interface f0/15 switchport | ||
|
31 |
查看用过的命令 |
查看用过的命令 | |
|
|