ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

Cisco的Router,Switch常用命令

2021-01-03 11:29:32  阅读:165  来源: 互联网

标签:vlan Cisco show 配置 Switch trunk interface Router config


Cisco命令大全

1. Switch配置命令

1.1模式转换命令

用户模式----------特权模式, 使用命令"enable"
特权模式----全局配置模式, 使用命令"configt"
全局配置模式----接口模式, 使用命令"interface+接口类型+接口号"
全局配置模式----线控模式, 使用命令"line+接口类型+接口号"
注:
用户模式:查看初始化的信息.
特权模式:查看所有信息、调试、保存配置信息
全局模式:配置所有信息、针对整个路由器或交换机的所有接口
接口模式:针对某一个接口的配置
线控模式:对路由器进行控制的接口配置

1.2配置命令

show running config--------------------显示所有的配置
show versin ------------------------------显示版本号和寄存器值
shut down --------------------------------关闭接口
no shutdown -----------------------------打开接口
ip add +ip----------------------------------配置IP地址
secondary+IP-----------------------------地址为接口配置第二个IP地址
show interface----------------------------接口类型+接口号, 查看接口管理性
show controllers interface------------- 查看接口是否有DCE电缆
show history-------------------------------查看历史记录
show terminal-----------------------------查看终端记录大小
hostname----------------------------------主机名配置路由器或交换机的标识
config memory ---------------------------修改保存在NVRAM中的启动配置
exec timeout 0 ---------------------------设置控制台会话超时为0
service password-encryptin ----------手工加密所有密码
enable password ------------------------配置明文密码
ena sec ------------------------------------配置密文密码
line vty 0 4/15 ----------------------------进入telnet接口
password ----------------------------------配置telnet密码
line aux 0 ----------------------------------进入AUX接口
password ----------------------------------配置AUX接口密码
line con 0 ----------------------------------进入CON接口
password ----------------------------------配置CON接口密码
bandwidth----------------------------------配置带宽
no ip address -----------------------------删除已配置的IP地址
show startup config ---------------------查看NVRAM中的配置信息
copy run-config atartup config --------保存信息到NVRAM
write -----------------------------------------保存信息到NVRAM
erase startup-config ---------------------清除NVRAM中的配置信息
show ip interface brief -------------------查看接口的摘要信息
banner motd -------------------------------配置路由器或交换机的描素信息
description----------------------------------配置接口听描素信息
vlan database -----------------------------进入VLAN数据库模式
vlan ------------------------------------------创建VLAN
switchport access vlan ------------------为VLAN为配接口
interface vlan-------------------------------进入VLAN接口模式
ip add ----------------------------------------为VLAN配置管理IP地址
vtp+service/tracsparent/client ---------配置SW的VTP工作模式
vtp +domain---------------------------------配置SW的VTP域名
vtp +password -----------------------------配置SW的密码
switchport mode trunk--------------------启用trunk模式
no vlan ---------------------------------------删除VLAN
show spamming-tree vlan ---------------查看VLA怕生成树议

2. 路由器配置命令

ip route-----------------------------------------配置静态/默认路由
show ip route --------------------------------查看路由表
show protocols ------------------------------显示出所有的被动路由协议和接口上哪些协议被设置
show ip protocols ---------------------------显示了被配置在路由器上的路由选择协议
router rip---------------------------------------激活RIP协议
network ----------------------------------------发布直连网段
interface lookback 0 ------------------------激活逻辑接口
passive-interface ----------------------------配置接口为被动模式
debug ip ---------------------------------------查看路由更新信息
undebug all -----------------------------------关闭所有debug信息
router eigrp ------------------------------------激活EIGRP路由协议
network------------------------------------------发布直连网段
show ip eigrp neighbors --------------------查看邻居表
show ip eigrp topology ----------------------查看拓扑表
show ip eigrp traffic --------------------------查看发送包数量
router ospf --------------------------------------激活ospf协议
show ip ospf------------------------------------显示ospf的进程号和touter-id
encapsulation----------------------------------更改封装格式
no ip admain-lookup -------------------------关闭路由器的域名查找
ip routing ----------------------------------------在三层交换机上启用路由功能
show user ---------------------------------------查看sw的在线用户
clear line -----------------------------------------清除线路

3. 三层交换机配置命令

3.1配置一组二层端口

configure terminal ------------------------------进入配置状态
nterface range -----------------------------------进入组配置状态

3.2配置三层端口

configureterminal --------------------------------进入配置状态
interface fa gi 0-24 | vlan ----------------------进入端口配置状态
no switchport --------------------------------------把物理端口变成三层口
ip address ------------------------------------------配置IP地址和掩码
no shutdown ---------------------------------------激活端口

例:

Switch(config)# interface gigabitethernet0/2
Switch(config-if)# no switchport
Switch(config-if)# ip address 192.20.135.21 255.255.255.0
Switch(config-if)# no shutdown

3.3配置Vlan

configure terminal --------------------------------进入配置状态
vlan vlan-id -----------------------------------------创建vlan
name vlan-name-----------------------------------给vlan命名
mtu mtu-size ---------------------------------------改变MTU大小

Switch# configure terminal
Switch(config)# vlan 20
Switch(config-vlan)# name test20
Switch(config-vlan)# end
或
Switch# vlan database
Switch(vlan)# vlan 20 name test20
Switch(vlan)# exit

3.4将端口分配给某个Vlan

configure terminal --------------------------------进入配置状态
interface interface-id -----------------------------进入要分配的端口
switchport mode access ------------------------定义二层口
switchport access vlan vlan-id ----------------把端口分配给某一VLAN

Switch# configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)# interface fastethernet0/1
Switch(config-if)# switchport mode access
Switch(config-if)# switchport access vlan 2
Switch(config-if)# end
Switch#

3.5配置Vlan trunk

configure terminal-----------------------------------------------进入配置状态
interface interface-id--------------------------------------------进入端口配置状态
switchport trunk encapsulation dot1q/ negotiate--------配置trunk封装isl或 802.1Q 或自动协商
switchport mode trunk------------------------------------------配置为trunk模式
dynamic auto-----------------------------------------------------自动协商是否成为trunk
dynamic desirable-----------------------------------------------把端口设置为trunk如果对方端口是trunk, desirable, 配置Native VLAN(802.1q)或自动模式,trunk—设置端口为强制的trunk方式,而不理会对方端口是否为trunk
switchport access vlan vlan-id (可选)-----------------------指定一个缺省VLAN, 如果此端口不再是trunk
switchport trunk native vlan vlan-id -------------------------指定802.1Q native VLAN号

例:

Switch# configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)# interface fastethernet0/4
Switch(config-if)# switchport mode trunk
Switch(config-if)# switchport trunk encapsulation dot1q
Switch(config-if)# end

3.5定义Trunk允许的Vlan

configure terminal--------------------------------进入配置状态
interface interface-id-----------------------------进入端口配置
switchport mode trunk---------------------------配置二层口为trunk模式
switchport trunk allowed vlan(add/ all / except / remove) vlan-list----配置trunk允许的VLAN.使用add, all, except, remove关健字
no switchport trunk allowed vlan --------------允许所有VLAN通过

Switch(config)# interface fastethernet0/1
Switch(config-if)# switchport trunk allowed vlan remove 2
Switch(config-if)# end

3.6配置NativeVlan(802.1q)

configure terminal--------------------------------进入配置状态
interface interface-id ----------------------------进入配置成802.1q trunk的端口
switchport trunk native vlan vlan-Id----------配置native Vlan号
no switchport trunk native vlan ---------------端口配置命令回到默认的状态

3.7配置基于端口权值的负载均衡

configure terminal --------------------------------进入配置状态
vtp domain domain-name ----------------------配置VTP域
vtp mode server ----------------------------------将Switch 1配置成VTP server.
show vtp status -----------------------------------查看VTP的配置
show vlan ------------------------------------------查看Vlan的配置
configure terminal --------------------------------进入配置状态
interface fastethernet 0/1 -----------------------进入fa 0/1端口
switchport trunk encapsulation ----------------配置trunk封装协议
switchport mode trunk ---------------------------配置成trunk模式
show interfaces fa 0/1 switchport--------------查看Vlan配置

在另一个交换机上进行此配置
show vlan -------------------------------------------在switch2上查看已经学到的vlan配置
configure terminal ---------------------------------进入配置状态
interface fastethernet0/1-------------------------进入要配置的端口
spanning-tree vlan 8 port-priority 10 ---------将端口权值10赋与Vlan 8
spanning-tree vlan 9 port-priority 10 ----------将端口权值10赋与Vlan 9
spanning-tree vlan 10 port-priority 10 --------将端口权值10赋与Vlan 10
interface fastethernet0/2 -------------------------进入要配置的端口
spanning-tree vlan 3 port-priority 10 ----------将端口权值10赋与Vlan 3
spanning-tree vlan 4 port-priority 10 ---------- 将端口权值10赋与Vlan 4
spanning-tree vlan 6 port-priority 10 ---------- 将端口权值10赋与Vlan 6
end -----------------------------------------------------退出
show running-config -------------------------------查看运行的配置
copy running-config startup-config -------------保存配置

3.8配置STP路径值的负载均衡

Trunk1走VLAN8-10,Trunk2走VLAN2-4
configure terminal --------------------------------进入配置状态
interface fastethernet 0/1 -----------------------进入要配置的端口
switchport trunk encapsulation isl/ dot1q----配置trunk封装isl或 802.1Q 或自动协商协议
switchport mode trunk----------------------------配置为Trunk模式
exit-----------------------------------------------------退出
interface fastethernet 0/2------------------------进入fa 0/2
重复上面的步骤
show running-config-------------------------------查看配置
show vlan--------------------------------------------查看已经学到的Vlan
configure terminal ---------------------------------进入配置状态
interface fastethernet 0/1 ------------------------进入F0/1
spanning-tree vlan 2 cost 30 -------------------配置Vlan2生成树路径值为30
spanning-tree vlan 3 cost 30 -------------------配置Vlan3生成树路径值为30
spanning-tree vlan 4 cost 30 -------------------配置Vlan4生成树路径值为30
exit-----------------------------------------------------退出
interface fastethernet 0/2------------------------进入fa 0/2
重复上面的步骤设置VLAN8,9,10生成树路径值为30
exit-----------------------------------------------------退出
show running-config-------------------------------查看配置
copy running-config startup-config-------------保存配置

4:路由选择协议及排障

4.1 ip route命令

例:

Router(config)#ip route

ip route <目录网络或子网号> [子网掩码] <下一路由器IP地址 | 从本地出口的地址> [管理距离0~255,默认为1] (注:静态地址配置)

4.2 ip default-network命令

例:

Router(config)#ip default-network <目标网络号>
Router(config)# ip route 0.0.0.0 0.0.0.0 <下一路由器IP地址 | 从本地出口的地址>

注:配合路由协使用,用其中的一个动态路由号作默认路由配置
注:只有一个公网地址时,在出口路由器上的配置

4.3排除网络故障

-4.3.1排除网络故障的总体思路

ping故障终端设备的ip地址,查看故障终端设备接口信息

例:

Router# ping<有故障的主机 | 有故障的IP地址>
Router# show ip route
Router# show interface <有故障的接口>
Router# show run

4.4 IP故障的排除

-4.4.1检查可用的路由

Router# show iproute <有故障的IP地址>

-4.4.2跟踪路由(Tracing the Route)

Router> traceroute <有故障的主机 | 有故障的IP地址>

或者在电脑端跟踪路由
C:\windows> ipconfig / all
C:\windows> tracert <有故障的主机 | 有故障的IP地址>

-4.4.3使用扩展的ping来跟踪连接性

Router# ping

4.5其它可能的故障

一个地址解析(ARP)的故障
 Router# show arp
 Router# show interface <有故障的接口>
 电脑端
C:\windows\> arp -a

4.6验证终端系统的路由表

电脑端
C:\windows\> netstat –rn
C:\windows\> route –f add 0.0.0.0 mask 0.0.0.0<需要添加入的网关地址>
C:\windows\> route [–f ] [[print | add | delete | change] [destination][mask netmask] [gateway]]
C:\windows\> route add mask <网络掩码> <网关ip地址>
C:\windows\> route delete mask <网络掩码> <网关ip地址>
C:\windows\> nbtstat <相应的参数>

标签:vlan,Cisco,show,配置,Switch,trunk,interface,Router,config
来源: https://blog.csdn.net/weixin_45610143/article/details/112131671

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有