当前位置: 首页 > article >正文

路由器配置命令

路由器配置命令

小明啊,你不是学计算机的嘛,叔叔家的路由器坏了,可以过来帮叔叔看看吗

命令可以用缩写,造就一堆容易造成歧义的缩写,比如addaddress的缩写,shshutdown的缩写。

视图模式介绍

普通视图 router>
特权视图 router#     #在普通模式下输入enable
全局视图 router(config)#   #在特权模式下输入config t
接口视图 router(config-if)#   #在全局模式下输入int 接口名称 例如int f0/0或int e0
路由协议视图 router(config-route)#  #在全局模式下输入router 动态路由协议名称
exit #从接口、协议、line等视图模式下退回到全局配置模式,或从全局配置模式退回到特权模式
end #回到特权模式
router#reload #重新启动路由器

1、基本配置

router>en	 					#enable的缩写,进入特权模式
router#conf t 					#进入全局配置模式
router(config)# hostname xxx 	#设置设备名称
router(config)#enable password XXX  #设置进入特权模式密码(低级密码,密码可逆)
Router(config)#enable secret XXX    #设置进入特权模式密码(高级密码,密码不可逆)

router(config)#no ip domain lookup #不允许路由器缺省使用DNS解析命令
router(config)# Service password-encrypt 
	#对所有在路由器上输入的口令进行暗文加密
router(config)#security

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 #开启密码

2、接口配置

router(config)#int s0 
	#进入接口配置模式。serial 0端口配置(如果是模块化的路由器前面加上槽位编号,
	#例如serial0/0 代表这个路由器的0槽位上的第一个接口)
router(config-if)#ip add 10.9.9.1 255.255.255.0   
	#这里的add是address的缩写,设置s0接口的ip地址,子网掩码
router(config-if)#nameif outside
	#设置接口命名为outside
router(config-if)# security-level 0
	#设置接口的安全级别为0
router(config-if)#enca hdlc/ppp 
	#捆绑链路协议 hdlc 或者 ppp。
	#思科缺省串口封装的链路层协议是HDLC,所以在show run中不会显示enca hdlc
	#如果要封装为别的链路层协议例如PPP/FR/X25,show run才会显示enca ppp等配置
	
router(config)# int e0 #进入e0接口配置
router(config-if)# ip add 10.9.9.1 255.255.255.0 #设置e0接口的ip,netmask
router(config-if)# nameif inside #接口命名为inside,表示内部网络
router(config-if)# end #回到特权模式
router# conf t #进入全局模式
router(config)# nat (inside) 101 10.9.9.0 255.255.255.0
	#配置内部网络源地址10.9.9.0,穿越防火墙时将进行地址转换,NAT标识ID为101
router(config)# global (outside) 101 192.168.9.101 netmask 255.255.255.255
	#配置外部接口的全局地址池,转换NAT标识ID为101的源地址,共享IP地址192.168.9.101
router(config)# route outside 0 0 10.9.9.13
	#配置默认路由为10.9.9.13

router(config)#int loopback 
	#建立环回口(逻辑接口)模拟不同的本机网段
router(config-if)#ip add 192.168.1.1 255.255.255.255  
	#添加ip 地址和掩码给环回口
router(config-if)#no sh  		#sh是shutdown的缩写,开启接口
router(config-if)#shutdown 		#管理性的关闭接口

3、路由配置

(1)静态路由

router(config)#ip route 192.168.2.0 255.255.255.0 192.168.3.1
 #设置目的IP地址为192.168.2.0,子网掩码为255.255.255.0,下一跳地址192.168.3.1
 #注意与ip add命令区分

(2)动态路由

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 接口名 
	#启动本路由器的那个接口为被动接口,该接口不会发送RIP更新
router(config-router)# nei xxx.xxx.xxx.xxx 
	#neighbor的缩写,广播转单播报文,指定邻居的接收ip
igrp协议
router(config)#router igrp xxx #启动igrp协议 
router(config-router)#network xxx.xxx.xxx.xxx #宣告自己的网段
router(config-router)#variance xxx #调整倍数因子,使用不等价的负载均衡
eigrp协议
router(config)router eigrp xxx #启动协议
router(config-router)#network xxx.xxx.xxx.xxx #宣告自己的网段
router(config-router)#variance xxx #调整倍数因子,使用不等价的负载均衡
router(config-router)#no auto-summary #关闭自动汇总功能
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)aera xxx stub 
	#配置xxx区域为末梢区域,加入这个区域的路由器全部要配置这个条命令
router(config-router)aera xxx stub no-summary  
	#配置xxx区域为完全末梢区域,只在ABR上配置
router(config-router)aera xxx nssa 
	#配置xxx区域为非纯末梢区域(NSSA)加入这个区域的路由器全部要配置这个条命令
router(config-router)aera xxx nssa no-summary  
	#配置xxx区域为完全非纯末梢区域,只在ABR上配置,
	#并发布缺省路由信息给进入这个区域内的路由器

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

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

5、一般的常用命令

router#Logout  #退出当前路由器登陆模式相对与windows的注销
router#reload #重新启动路由器(热启动)冷启动就是关闭路由器再打开电源开关 
特权模式下:
router#show config #查看防火墙配置
router#show cpu #查看cpu信息
router#show version #查看版本
router#show ip address #查看接口ip信息
router#show nameif #查看接口命名信息
router#show ip int br 
	#brief的缩写,查看当前的路由器的接口ip地址启用情况

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

http://www.kler.cn/a/585736.html

相关文章:

  • 完善机器人:让 DeepSeek 生成 API 接口,并在网页上调用
  • MySQL 的 innodb_buffer_pool_size 参数配置指南
  • [AI QA] strace | 探索 a.out
  • 正则表达式 - 修饰符
  • 书籍品读:我的世界(陈州)
  • C语言实现括号匹配检查及栈的应用详解
  • 【综述】An Introduction to Vision-Language Modeling【二】
  • 【linux驱动开发】创建proc文件系统中的目录和文件实现
  • Python 中 lambda 表达式、推导式和其他函数用法对比
  • QT中读取QSetting文件
  • Ubuntu 访问 Windows 共享文件夹
  • vue2升级Vue3--native、对inheritAttrs作用做以解释、声明的prop属性和未声明prop的属性
  • C语言内容
  • jupyter无法转换为PDF,HTMLnbconvert failed: Pandoc wasn‘t found.
  • 【sql靶场】第11、12关-post提交注入
  • 使用GitHub Actions实现Git推送自动部署到服务器
  • Python实现邮件发送功能,邮箱验证码发送(详细功能实现及环境搭建)
  • 【学习笔记】LLM技术基础
  • C++相关基础概念之入门讲解(上)
  • Qt QML实现弹球消砖块小游戏