锐捷交换机、路由器常用命令
EXEC模式: 用户模式switch>
交换机信息的查看,简单测试命令 模式switch#
查看、管理交换机配置信息,测试、调试 配置模式:
全局配置模式switch(config)# 配置交换机的整体参数
接口配置模式switch(config-if)# 配置交换机的接口参数
进入全局配置模式
Switch#c onfigure terminal Switch(config)#exit Switch#
进入接口配置模式
Switch(config)#interface fastethernet 0/1 Switch(config-if)#exit Switch(config)#
从子模式下直接返回模式 Switch(config-if)#end Switch#
命令行其他功能 获得帮助
switch#? switch#show ? 命令简写
全写:switch# configure terminal 简写:Switch# config 使用历史命令 Switch# (向上键) Switch# (向下键)
配置交换机Telnet功能
配置远程登陆密码
Switch(config)#enable secret level 1 0 ruijie 配置进入模式密码
Switch (config)#enable secret level 15 0 ruijie 为交换机配置管理IP
Switch (config)#interface vlan 1 Switch (config-if)#no shutdown
Switch (config-if)#ip address 192.168.1.1 255.255.255.0 Switch (config-if)#end
配置文件的管理 保存配置
将当前运行的参数保存到flash 中用于系统初始化时初始化参数 Switch#copy running-config startup-config Switch#write memory Switch#write
删除配置
永久性的删除flash 中不需要的文件 使用命令delete flash:config.text 删除当前的配置: 在配置命令前加no 例:switch(config-if)# no ip address 查看配置文件内容
Switch#show configure 查看保存在FLASH里的配置信息 Switch#show running-config 查看RAM里当前生效的配置
配置Port VLAN
创建VLAN10,将它命名为test的例子 Switch# configure terminal Switch(config)# vlan 10 Switch(config-vlan)# name test Switch(config-vlan)# end 把接口 0/10加入VLAN10 Switch# configure terminal
Switch(config)# interface fastethernet 0/10 Switch(config-if)# switchport mode access Switch(config-if)# switchport access vlan 10 Switch(config-if)# end
将一组接口加入某一个VLAN
Switch(config)#interface range fastethernet 0/1-8,0/15,0/20
Switch(config-if-range)# switchport access vlan 20
注:连续接口 0/1-8,不连续接口用逗号隔开,但一定要写明模
块编号
配置Tag VLAN-Trunk
把Fa0/1配成Trunk口 Switch# configure terminal
Switch(config)# interface fastethernet0/1 Switch(config-if)# switchport mode trunk
把端口Fa0/20 配置为Trunk端口,但是不包含VLAN 2: Switch(config)# interface fastethernet 0/20
Switch(config-if)# switchport trunk allowed vlan remove 2 Switch(config-if)# end
Native VLAN
配置命令:
Switch(config-if)# switchport trunk native vlan 20 Switch(config-if)# end 注意:
每个Trunk口的缺省native VLAN是VLAN 1
在配置Trunk链路时,请确保连接链路两端的Trunk口属于相同的native VLAN
保存/清除VLAN 信息
将VLAN信息保存到flash中
Switch#write memory 从flash中只清除VLAN信息 Switch#delete flash:vlan.dat 从RAM中删除VLAN
Switch(config)#no vlan VLAN-id
生成树协议的配置
开启生成树协议
Switch(config)#Spanning-tree 关闭生成树协议
Switch(config)#no Spanning-tree 配置生成树协议的类型
Switch(config)#Spanning-tree mode stp/rstp 锐捷全系列交换机默认使用MSTP协议
配置交换机优先级
Switch(config)#spanning-tree priority <0-61440> (“0”或“4096”的倍数、共16个、缺省32768) 恢复到缺省值
Switch(config)# no spanning-tree priority 配置交换机端口的优先级
Switch(config)#interface interface-type interface-number Switch(config-if)#spanning-tree port-priority number
配置STP、RSTP
Spanning Tree 的缺省配置: 关闭STP
STP Priority 是32768 STP port Priority 是128
STP port cost 根据端口速率自动判断 Hello Time 2秒
Forward-delay Time 15秒 Max-age Time 20秒
可通过spanning-tree reset 命令让spanning tree参数恢复到缺省配置
查看生成树协议配置
显示生成树状态
Switch#show spanning-tree 显示端口生成树协议的状态
Switch#show spanning-tree interface fastethernet <0-2/1-24>
配置aggregate port
将该接口加入一个AP Switch#c onfigure terminal
Switch(config) # interface interface-type interface-id Switch(config-if-range)#port-group port-group-number 如果这个AP不存在,可自动创建AG端口
查看聚合端口的汇总信息
Switch#show aggregateport summary
查看聚合端口的流量平衡方式
Switch#show aggregateport load-balance
路由器上配置telnet
第一步: 配置端口地址
RouterA# configure terminal !进入全局配置模式 RouterA(config)# interface fastethernet 1/0 !进入路由器接口配置模式
RouterA(config-if)# ip address 192.168.0.1 255.255.255.0 !配置路由器管理接口IP地址
RouterA(config-if)# no shutdown !开启路由器f 1/0接口
第二步:配置远程登录密码
RouterA(config)# line vty 0 4 !进入路由器线路配置模式 RouterA(config-line)# login !配置远程登录
RouterA(config-line)# password star !设置路由器远程登录密码为 “star”
RouterA(config-line)#end 第三步:配置路由器模式密码
RouterA(config)# enable secret star !设置路由器模式密码为 “star”
或者
RouterA(config)# enable password star
查看配置文件
show version !查看版本及引导信息
show running-config !查看运行配置
show startup-config !查看用户保存在NVRAM中的配置文件 保存配置文件 Router
#copy running-config startup-config Router#write memory Router#write 删除配置文件
Router#delete flash:config.text !删除初始配置文件
查看路由信息
router#show ip route
Codes: C - connected,S – static, R – RIP, O- OSPF IA - OSPF inter area,E1-OSPF external type 1 E2 - OSPF external type 2,* - candidate default Gateway of last resort is 10.5.5.5 to network 0.0.0.0 172.16.0.0/24 is subnetted, 1 subnets
C 172.16.11.0 is directly connected, serial1/2
O E2 172.22.0.0/16 [110/20] via 10.3.3.3, 01:03:01, Serial1/2 S* 0.0.0.0/0 [1/0] via 10.5.5.5
静态路由配置命令
配置静态路由用命令ip route
router(config)#ip route [网络编号] [子网掩码] [转发路由器的IP
地址/本地接口]
例:ip route 192.168.10.0 255.255.255.0 serial 1/2 例:ip route 192.168.10.0 255.255.255.0 172.16.2.1 静态路由描述转发路径的方式有两种 指向本地接口(即从本地某接口发出)
指向下一跳路由器直连接口的IP地址(即将数据包交给X.X.X.X)
配置默认路由:
router(config)#ip route 0.0.0.0 0.0.0.0 [转发路由器的IP地址/本地接口]
RIP路由协议的版本 RIPv1
有类路由协议,不支持VLSM 以广播的形式发送更新报文 不支持认证 RIPv2
无类路由协议,支持VLSM 以组播的形式发送更新报文 支持明文和MD5的认证
配置RIP协议 配置步骤
1、开启RIP路由协议进程 Router(config)#router rip
2、申请本路由器参与RIP协议的直连网段信息 Router(config-router)#network 192.168.1.0 3、指定RIP协议的版本2(默认是version1) Router(config-router)#version 2 4、在RIPv2版本中关闭自动汇总
Router(config-router)#no auto-summary
查看RIP配置信息
验证 RIP的配置
Router#show ip protocols 显示路由表的信息 Router#show ip route 清除 IP路由表的信息 Router#clear ip route 在控制台显示 RIP的工作状态 Router#debug ip rip
OSPF协议
OSPF配置如下:
1、创建loopback接口,定义ROUTE ID routerA(config)#interface loopback 10
routerA(config)#ip address 192.168.100.1 255.255.255.0 2、开启OSPF进程
routerA(config)#router ospf 10 10代表进程编号,只具有本地意义 3、申请直连网段
routerA(config-router)#network 10.1.1.0 0.0.0.255 area 0 注意反掩码和区域号
查看OSPF配置信息
验证 OSPF的配置 Router#show ip ospf 显示路由表的信息 Router#show ip route 清除 IP路由表的信息 Router#clear ip route 在控制台显示 OSPF的工作状态 Router#debug ip ospf
三层交换的路由功能
三层交换机默认开启路由功能
Switch(config)#ip routing (开启三层交换机路由功能) 三层交换机配置路由接口的两种方法 开启三层交换机物理接口的路由功能 Switch(config)#interface fastethernet 0/5 Switch(config-if)#no switchport Switch(config-if)#ip address 192.168. 1.1 255.255.255.0
Switch(config-if)#no shutdown 关闭物理接口路由功能 Switch(config-if)# switchport
采用SVI方式(switch virtual interface)
Switch(config)#interface vlan 10
Switch(config-if)#ip address 192.168.1.1.255 255.255.0 Switch(config-if)#no shutdown
三层交换机和路由器相连的网络
方法一(SVI):
Switch(config)#interface f0/10
Switch(config-if)#switchport access vlan 10 Switch(config-if)#exit
Switch(config)#interface vlan 10 switch(config-if)#ip address 192.168.10.1 255.255.255.0
Switch(config-if)#no shutdown
方法二(路由接口):
Switch(config)#interface f0/10 Switch(config-if)#no switchport
Switch(config-if)#ip address 192.168.10.1 255.255.255.0 Switch(config-if)#no shutdown
三层交换机路由协议的配置 静态路由
Switch(config)#ip route x.x.x.x x.x.x.x [x.x.x.x/interface] RIP
Switch(config)#router rip
Switch(config-router)#network X.X.X.X Switch(config-router)#version 2
注:三层交换机不支持no auto-summary OSPF
Switch(config)#router ospf
Switch(config)#network X.X.X.X X.X.X.X area x
查看三层交换机路由配置
查看路由接口信息 Switch#show ip interface