网络设备类似于我们常用的电脑,同样拥有主板、CPU、内存、存储等,其只有在安装了操作系统(IOS)后才能产生生产力,它的启动过程也与电脑无二。
网络设备启动过程
网络设备的启动过程如下:
- 主板加电自检,自检通过则启动Bootstrap程序。
- 启动Bootstrap后,去读取NVRAM中的寄存器的值,若为0则进入Rom monitor模式,若不为0则进入下一步。
- 检查寄存器值是否为1,若等于1检测是否有Mini ios存在,若存在则进入ios,若不存在则进入Rom monitor模式,若干寄存器值不为1,进入下一步。
- 检查寄存器值是否介于2~F之间,若是,系统会去NVRAM读取start-up-config文件中的指令,读取完毕后系统会在这个文件中寻找是否有Boot system command。如果有,则照指令去执行加载系统,如果没有,则进入下一步。
- 系统没有找到boot system指令后,系统会去往flash中寻找ios,如果有的话正常启动系统,如果没有,进入下一步。
- Flash中没有能够正常启动的IOS的话,路由器尝试查找网络中的tftp服务器并尝试连接服务器加载系统,如果成功则尝试从网络启动,若失败则进入下一步。
- 路由器判断寄存器第13位(由于二进制表示且首位为0,即需要判断右往左第14位)是否为1,不为1则返回tftp服务器继续进行上一步操作,使IOS启动变为死循环,要尽量避免。如果为1进入下一步。
- 路由器判断启动次数是否为5,如果不等于5(数值依型号可能不同)则返回继续tftp网络启动过程,直至达到5次进入下一步
- 路由器查找是否有Mini ios如果有就加载,没有则加载Rom monitor。
- 路由器顺利加载本地flash中的IOS,系统判断寄存器的第六位(从右往左第7位)是否为1,为1则进入setup初始化配置对话,如果不为1则载入startup-config配置文件来配置系统。
流程图如下:(图片来自51CTO.COM)

image.png
网络设备中的存储
思科网络设备中,共有如下几种存储类型
RAM:相当于PC中的内存,断电丢失所有数据,存取速度快,设备启动时由启动配文件拷贝来的运行配置文件running-config,解压后的IOS以及学习到的路由以及包队列等,均加载至RAM。
NVRAM:存放路由器的启动配置文件startup-config的硬件。还存储寄存器(Configuration Register,设备通过次寄存器选择需要启动的程序)
ROM:存储着一个用于维护路由器的应用程序硬件。里面存储有POST、bootstrap以及Mini IOS。
FLASH:相当于电脑的硬盘,存放完整的主IOS,是网络设备的操作系统。
通用基础命令
R1#show version #查看版本信息
R1#show running-config #查看running-config
R1#show startup-config # 查看启动配置文件
R1#debug all # 开启所有debug
R1#debug ip packet detail # IP包debug信息
R1(config)#service timestamps debug datetime msec # 配置debug细节
R1#undebug all #取消全部debug
R1#reload #重启网络设备
R1#copy running-config startupconfig #存储运行配置信息到启动文件
R1#wr
R1#write
R1#write memory
R1# erase startup-config #清空启动配置信息
R1#show clock #查看时钟
R1#clock set 13:00:00 March 30 2022 #设置时钟
R1(config)#clock timezone GMT +8 #配置时区
R1(config)#ip domain-name cisco # 设置ip域名
R1(config)#ip name-server 114.114.114.114 # 配置DNS服务器
R1#terminal monitor #开启远程网管监控信息
网络设备预配置命令
R1(config)#line console 0
R1(config-line)#logging synchronous #启用输入同步
R1(config-line)#exec-timeout 0 0 #设置永不退出
R1(config)#no ip domain lookup #关闭ip域名解析
配置接口ip
R1(config)#interface e0/2
R1(config-if)#ip address 12.1.1.1 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#description Connectted to R2
R1(config-if)#keepalive 1
配置telnet网管网络设备
R1(config)#enable password P@ssword!
R1(config)#line vty 0 4
R1(config-line)#password P@ssword!
R1(config-line)#login
tR1(config-line)#transport input all
配置ssh网管
R1(config)#username admin password P@ssword!
R1(config)#ip domain-name cisco.com
R1(config)#crypto key generate rsa
The name for the keys will be: R1.cisco.com
Choose the size of the key modulus in the range of 360 to 4096 for your
General Purpose Keys. Choosing a key modulus greater than 512 may take
a few minutes.
How many bits in the modulus [512]: 1024
% Generating 1024 bit RSA keys, keys will be non-exportable...
[OK] (elapsed time was 1 seconds)
R1(config)#ip ssh version 2
R1(config)#line vty 0 4
R1(config-line)#transport input all
R1(config-line)#login local
#网络设备使用ssh登录其它网络设备
R2#ssh -v 2 -l admin 12.1.1.1
#删除ssh密钥
R1(config)#crypto key zeroize rsa
SDM管理网络设备
R1(config)#ip http server
R1(config)#ip http secure-server
R1(config)#ip http authentication local
R1(config)#username admin privilege 15 password P@ssword!
R1(config)#line vty 0 4
R1(config-line)#login local
R1(config-line)#transport input all