《思科路由器常用配置命令》学习笔记(更新中)

版权声明: https://blog.csdn.net/lionkas/article/details/84927186

1、视图模式介绍

router> //用户模式
router#  //特权模式,在普通模式下输入enable
router(config)#  //全局模式,在特权模式下输入configure terminal
router(config-if)# //接口视图,在全局模式下输入int 接口名称 例如 int s0 或 int e0
router(config-route)# //路由协议视图,在全局模式下输入router 动态路由协议名称

2、基本配置

router>enable //进入特权模式
router#configure terminal //进入全局配置模式
router(config)#hostname xxx //设置设备名称
router(config)#no ip domain-lookup //不允许路由器缺省使用DNS解析命令

router(config)#enable password  //设置特权口令
router(config)# Service password-encrypt //对所有在路由器上输入的口令进行暗文加密
router(config)#line vty 0 4 //进入设置telnet服务模式
router(config-line)#password xxx //设置telnet的密码
router(config-line)#login //使能可以登陆
router(config)#line con 0 //进入控制口的服务模式
router(config-line)#password xxx //要设置console的密码
router(config-line)#login //使能可以登陆

3、接口配置

router(config)#int s0 //进入接口配置模式 serial 0 端口配置(如果是模块化的路由器前面加上槽位编号,例如serial0/0 代表这个路由器的0槽位上的第一个接口)
router(config-if)#ip address xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx  //添加ip 地址和掩码
router(config-if)#no shutdown //开启端口

router(config-if)#enca hdlc/ppp 捆绑链路协议 hdlc 或者 ppp 思科缺省串口封装的链路层协议是HDLC所以在show run配置的时候接口上的配置没有,如果要封装为别的链路层协议例如PPP/FR/X25就是看到接口下的enca ppp或者enca fr
router(config)#int loopback //建立环回口(逻辑接口)模拟不同的本机网段
router(config-if)#ip add xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx  //添加ip 地址和掩码给环回口
router(config-if)#no shutdown //在物理接口上配置了ip地址后用no shutdown启用这个物理接口反之可以用shutdown管理性的关闭接口

4、静态路由配置

router(config)#ip route xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx //下一条或自己的接口
router(config)#ip route 0.0.0.0 0.0.0.0 s 0 //添加缺省路由

5、RIP动态路由协议

router(config)#router rip //启动rip协议
router(config-router)#network xxx.xxx.xxx.xxx //宣告自己的网段
router(config-router)#version 2 // 转换为rip 2版本
router(config-router)#no auto-summary //关闭自动汇总功能,rip V2才有作用
router(config-router)# passive-int 接口名 //启动本路由器的那个接口为被动接口
router(config-router)# nei xxx.xxx.xxx.xxx //广播转单播报文,指定邻居的接ip

6、IGRP动态路由协议

igrp协议-----内部网关路由协议(IGRP:Interior Gateway Routing Protocol)
router(config)#router igrp xxx //启动igrp协议
router(config-router)#network xxx.xxx.xxx.xxx //宣告自己的网段
router(config-router)#variance xxx //调整倍数因子,使用不等价的负载均衡

7、EIGRP动态路由协议

//eigrp---Enhanced Interior Gateway Routing Protocol(增强网关内部路由线路协议)
router(config)#router eigrp xxx //启动协议
router(config-router)#network xxx.xxx.xxx.xxx //宣告自己的网段
router(config-router)#variance xxx //调整倍数因子,使用不等价的负载均衡
router(config-router)#no auto-summary //关闭自动汇总功能
router#show ip eigrp neighbors //查看eigrp协议的邻居表
router#show ip eigrp top  //查看eigrp协议的拓朴表
router#show ip eigrp interface //查看当前路由器运行eigrp协议的接口情况

8、OSPF动态路由协议

router(config)#router ospf xxx //启动协议启动一个OSPF协议进程
router(config-router)#network xxx.xxx.xxx.xxx area xxx //宣告自己的接口或网段在ospf的区域中,可以把不同接口
宣告在不同区域中
router(config-router)#router-id xxx.xxx.xxx.xxx //配置路由的id
router(config-router)#area xxx stub //配置xxx区域为末梢区域,加入这个区域的路由器全部要配置这个条命令
router(config-router)#area xxx stub no-summary //配置xxx区域为完全末梢区域,只在ABR上配置
router(config-router)#area xxx nssa //配置xxx区域为非纯末梢区域,加入这个区域的路由器全部要配置这个条命令
router(config-router)#area xxx nssa no-summary  //配置xxx区域为完全非纯末梢区域,只在ABR上配置,并发布缺省路由信息进入这个区域内的路由器
router#show ip ospf neighbor //查看当前路由器的ospf协议的邻居表
router#show ip ospf interface //查看当前路由器运行ospf协议的接口情况
router#clear ip ospf process //清楚当前路由器ospf协议的进程

9、保存当前修改//运行的配置

router#write //将RAM中的当前配置存储到NVRAM中,下次路由器启动就是执行保存的配置
router#Copy running-config startup-config //命令与write效果一样

10、exit命令:从接口、协议、line等视图模式下退回到全局配置模式,或从全局配置模式退回到特权模式

router(config-if)#exit
router(config)#
router(config-router)#exit
router(config)#
router(config-line)#exit
router(config)#
router(config)#exit
router#

11、end命令:从任何视图直接回到特权模式

router(config-if)#end
router(config-router)#end
router(config-line)#end
router#

12、注销和热启动命令

router#Logout //退出当前路由器登陆模式相对与windows的注销
router#reload //重新启动路由器(热启动)冷启动就是关闭路由器再打开电源开关

13、查看当前路由表

router#show ip route //查看当前的路由表
router#clear ip route * //清除当前的路由表
router#show ip protocol //查看当前路由器运行的动态路由协议情况
router#show ip int brief //查看当前的路由器的接口ip地址启用情况
router#show running-config //查看当前运行配置
router#show startup-config //查看启动配置
router#debug ip pack //打开ip报文的调试
router#terminal monitor //输出到终端上显示调试信息
router#Show interfaces //显示设置在路由器和访问服务器上所有接口的统计信息. 显示路由器上配置的所有接口的状态
router#Show interfaces serial //显示关于一个串口的信息
router#Show ip interface //列出一个接口的IP信息和状态的小结, 列出接口的状态和全局参数

14、show命令

router#show running config //显示所有的配置
router#show versin //显示版本号和寄存器值
router#show interface+接口类型+接口号 //查看接口管理性
router#show controllers interface //查看接口是否有 DCE 电缆
router#show history //查看历史记录
router#show terminal //查看终端记录大小
router#show ip interface brief //查看接口的谪要信息
router#show spamming-tree vlan +vlan号 //查看 VLAN生成树议

15、接口配置

shutdown //关闭接口
no shutdown //打开接口
ip add +ip地址 //配置 IP 地址
secondary+IP地址 //为接口配置第二个 IP 地址
hostname+主机名 //配置路由器或交换机的标识
config memory //修改保存在 NVRAM 中的启动配置
exec timeout 0 0 //设置控制台会话超时为 0
no ip address //删除已配置的 IP 地址

16、密码设置

service password-encryptin //手工加密所有密码
enable password +密码 //配置明文密码
ena sec +密码 //配置密文密码
line vty 0 4/15 //进入 telnet 接口
password +密码 //配置 telnet 密码
line aux 0 //进入 AUX 接口
password +密码 //配置密码
line con 0 //进入 CON 接口
password +密码 //配置密码
bandwidth+数字 //配置带宽

17、在Cisco设备上修改控制端口密码

R1(config)# line console 0
R1(config-line)# login
R1(config-line)# password Lisbon
R1(config)# enable password Lilbao
R1(config)# login local
R1(config)# username student password cisco

18、在Cisco设备上设置控制台及vty端口的会话超时

R1(config)# line console 0
R1(config-line)# exec-timeout 5 10
R1(config)# line vty 0 4
R1(config-line)# exec-timeout 5 2

19、NVRAM

show startup config 查看 NVRAM 中的配置信息
copy run-config atartup config 保存信息到 NVRAM
write 保存信息到 NVRAM
erase startup-config 清除 NVRAM 中的配置信息
description+信息 配置接口听描素信息

19、三层交换机配置命令

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

Switch# configure terminal
Switch(config)# interface fastethernet0/1
Switch(config-if)# switchport mode access
Switch(config-if)# switchport access vlan 2
Switch(config-if)# end
Switch#

Switch# configure terminal
Switch(config)# interface fastethernet0/4
Switch(config-if)# switchport mode trunk
Switch(config-if)# switchport trunk encapsulation dot1q
Switch(config-if)# end

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

猜你喜欢

转载自blog.csdn.net/lionkas/article/details/84927186