(注:图片看不清,请点击放大)
每当一个网络项目完成后,日后的日常网络维护就交给了网络管理员来维护。一般对网络设备的维护,小T我大概总结为,备份和还原网络设备的操作系统,备份和还原设备的配置文件,网络设备密码遗忘了如何恢复,对telnetSSHWeb等管理设置密码及身份认证,根据新增的需求配置网络设备等。<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

作为一名网络维护人员,在新接手一台已经调试好网络设备的时候,首先要做的事情,就是将网络的设备的配置文件保存。这样的做的好处,是为以后设备出问题了,还有一招最后的解救方法。所以,备份网络设备的配置文件,对每位网络维护人员来说是很重要的。若网络设备的操作系统cisco的是IOSH<?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" />3CVRP可以导出来的话,我们就将网络设备操作系统备份。备份网络操作系统,这是为了防止哪天网络操作不小心操作失误,把网络设备操作系统给弄“坏”了,好有地方找到网络操作系统给它还原。谁都会有忘记一些东西的时候,作为网络维护人员,忘记网络设备的密码的情况也是避免不了的,但必须学会密码恢复。所以,小T我个人对每位网络维护人员的建议就是,要了解你们所掌管的网络设备如何做密码恢复的。如果我上面说的这几点,你没做到话!网络设备出问题了,那就打卖设备给的你公司,叫他们给你维护,每次多花点钱而已。

在开始今天的实验之前,小T先讲讲实验思路。在这次试验中,我还是采用通过TFTP的备份方法,当然你也可以用TFP等。首先,讲讲cisco设备的配置文件,常看到的是:startup-configrunning-configRuning-configcisco设备的当前运行文件,断电是不保存的,我们配置完了cisco设备,都是在的文件中。startup-configcisco的启动配置文件,也就是说cisco的设备在启动经历了加电自检,加载IOS,再加载startup-config文件。所以,我们在配置完cisco的设备的时候,记住敲上copy running-config startup-configwrite在保存配置文件,不然,你重启后,你的网络设备啥东西也没有了!当我们遗忘了密码,通过了解网络设备启动过程,我们只要想办法让设备不加载startup-config文件,就有办法恢复密码。(cisco的路由器是通过路由器修改寄存值;而交换机则是采取将这个文件名修改一下,由于模拟器不支持,故小T我只给大家描述下)。

先让大家看看我的实验拓扑:

通过模拟一个小小的局域网,便于让大家来理解。PC0PC1TFTP服务器不在同一个网段,解决相互通信采用了单臂路由。

IP 的规划如下:

PC0 192.168.2.1/24

PC1:192.168.3.1/24

TFTP:192.168.1.2/24

交换机管理IP192.168.1.1/24

实验的基本连通性配置:

路由器的配置:

enable

config t

line console 0

logg sy

exec-time 0 0

exit

hostname R1

interface FastEthernet0/0

 ip address 192.168.1.254 255.255.255.0

 no shut

interface FastEthernet0/0.1

 encapsulation dot1Q 2

 ip address 192.168.2.254 255.255.255.0

 no shut

interface FastEthernet0/0.3

 encapsulation dot1Q 3

 ip address 192.168.3.254 255.255.255.0

 no shut

交换机的配置:

 

enable

conf t

line console 0

logg sy

exec-time 0 0

exit

vlan 2 name vlan2

vlan 3 name vlan3

interface range fastEthernet 0/1 -5

switchport mode access

switchport access vlan 2

spanning-tree portfast

exit

interface range fastEthernet 0/6 -10

switchport mode access

switchport access vlan 3

spanning-tree portfast

exit

interface fastEthernet 0/24

switchport mode turnk

exit

interface Vlan1

 ip address 192.168.1.1 255.255.255.0

 no shut

exit

ip default-gateway 192.168.1.254 (不同网段要想能ping和访问必须为交换机配置网关)

所有网络设备和PC、服务器的联通性解决了,那么我们先从登入的密码身份认证开始试验。

登入cisco网络设备,常用的是通过console口直接连接,远程telnet,安全的远程SSH,以及web访问。由于模拟器不支持Web,故本实验演示前面三种。

一、 密码访问登入

Console

line console 0

password xiaot

login

当你配置上这些命令的时候,你console口登入就会如下提示输入密码。

Password:

R1>

telnet

line vty 0 4 (这表示从0-4,有五个用户可以同时登入)

password xiaot

login

 

enable password 123 (此密码必须配置,不然你就只能停留在用户模式) 

测试在PCCMDtelnet,效果如下图:

一、 基于用户名密码认证:

Console

username xiaot password  tang (这是本地用户名密码,你也可以采用AAA服务器,关于AAA服务器的见我的博客《PacketTracer 5.2基于AAA认证的Easy ×××实验》

line con 0

login local

这是你从console登入,将会看到如下的提示:

Username: xiaot

Password:

 

R1>

Telnet

username xiaot password  tang

line vty 0 4

login local

enable password 123

测试的效果图如下:

SSH 登入:

hostname R1

ip domain-name cicso.com

(这两条语句很关键,因为路由要以设备名称和这个域名为材料进行RSA算法,产生一对公私密钥对,客户机SSH登入时,路由器会将公钥发给客户机,客户机用公钥加密,路由器用私钥解密)

crypto key generate rsa

The name for the keys will be: R1.cicso.com

Choose the size of the key modulus in the range of 360 to 2048 for your

  General Purpose Keys. Choosing a key modulus greater than 512 may take

  a few minutes.

How many bits in the modulus [512]: (产生密钥对的长度)

% Generating 512 bit RSA keys, keys will be non-exportable...[OK]

*?? 1 1:35:20.548:  %SSH-5-ENABLED: SSH 1.99 has been enabled (当出现这个提示的SSH服务也随之开启了!)

line vty 0 4

 login local

 transport input ssh

enable password 123

SSH 的测试结果如下:

接下来,我们开始对网络的设备的IOS,及配置文件备份。IOS的备份还原在我的博客一文中PacketTracer 5.2之路由器IOS升级实验指南》有说明,还原的命令跟升级的是一样的。那么备份的命令如下:

R1#show flash: (先查看我们需要备份的IOS

System flash directory:

File  Length   Name/status

  3   50938004 c2800nm-advipservicesk9-mz.124-15.T1.bin

  2   28282    sigdef-category.xml

  1   227537   sigdef-default.xml

[51193823 bytes used, 12822561 available, 64016384 total]

63488K bytes of processor board System flash (Read/Write)

 

R1#copy flash: tftp: (从路由器的FLASH中,将文件备份到tftp中)

Source filename []? c2800nm-advipservicesk9-mz.124-15.T1.bin (原文件)

Address or name of remote host []? 192.168.1.2 TFTP服务器地址)

Destination filename [c2800nm-advipservicesk9-mz.124-15.T1.bin]? (存放名称,可以自己命名)

.!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

[OK - 50938004 bytes]

50938004 bytes copied in 59.468 secs (856000 bytes/sec)

 

TFTP服务器中,就可以看到你所备份好的IOS。配置文件的备份,更IOS的备份的思路是一样的。从路由器将startup-configrunning-config备份到TFTP服务器上,还原的时候,要千万注意啊,startup-config还原了,是不需要在保存到路由器,而running-config还原了,必须要保存到启动配置文件中。备份和还原命令如下:

R1#copy running-config tftp:

Address or name of remote host []? 192.168.1.2

Destination filename [R1-confg]? running-config (我命名为running-config,如果不命名这是R1-confg

!!

[OK - 686 bytes]

686 bytes copied in 0.125 secs (5000 bytes/sec)

 

R1#copy startup-config tftp:

Address or name of remote host []? 192.168.1.2

Destination filename [R1-confg]? startup-config (我命名为startup-config,如果不命名这是R1-confg

!!

[OK - 684 bytes]

684 bytes copied in 0.11 secs (6000 bytes/sec)

 

这时在TFTP服务器上的备份效果如如图:

 
还原的配置命令如下:(以 startup-config 为例)

R1#copy tftp: flash:

Address or name of remote host []? 192.168.1.2

Source filename []? startup-config (服务器上的文件名)

Destination filename [startup-config]? (还原到flash中名称,可以命名,建议默认)

Accessing tftp://192.168.1.2/startup-config...

Loading startup-config from 192.168.1.2: !

[OK - 684 bytes]

684 bytes copied in 0.062 secs (11032 bytes/sec)

 

(注意:还原running-config后,在使用copy running-config startup-configwrite保存。)

 

最后,给大家演示的是路由器的密码恢复实验(由于模拟器不支持做交换机的密码恢复,故小T我在这给大家描述一下思路)。在前面我说了,只要在cisco网络设备启动后,不让它加载startup-config文件就可以了。路由器只要修改寄存值,如:0x2102是默认的加载startup-config文件;0x2142是不加载startup-config文件的。演示实验如下:

把电源关了再开一下,模拟器支持电源的开关(《 【交流】浅谈 PacketTracer   5.2 模拟器》一文中有说明)。在路由器重启的时候,出现“ #### ”的时候按下 Ctrl+Break 键盘,加入路由器的 ROM 模式,修改寄存值,效果如下:

Self decompressing the p_w_picpath :

############

monitor: command "boot" aborted due to user interrupt

rommon 1 > confreg 0x2142

rommon 2 > boot

 

启动后就如见到如下信息,这个信息室询问式配置,我们选择“no”。就进入到了路由器的命令行配置。密码恢复思路是在这里修改密码,再讲当前的running-config保存到startup-config中,修改寄存值为默认加载的startup-config的。

Continue with configuration dialog? [yes/no]: no
 

Router#copy startup-config running-config

R1(config)#enable password 456
R1(config)#config-register 0x2102

R1r#copy running-config startup-config

R1#reload

 

这样就完成了密码恢复,telnetssh的密码,也在这里配置,后保存到startup-config,修改寄存值,最后重启。

交互机的密码恢复,小T我给大家描述下。以cisco 2950为例,在重启交换机的时候,按住交换机上的Modem键,然后操作命令先后顺序如下:

flash_init (初始化交换机)

load helper (加载帮助文件)

dir flash: (查看flash中文件,你会看到config.text文件,这就是交换机的启动文件)

rename flash:config.text flash:config.old (重新命个名,这样交换机就不会加载启动文件了)

boot (启动交换机)

 

Continue with configuration dialog? [yes/no]: no

Switch#rename flash:config.old flash:config.text (将名字改回到启动文件)

Switch#copy flash:config.text system:running-config (讲启动文件加载到当前运行环境)

Switch config#enable password xiaot

Switch#copy running-config startup-config (修改后的密码保存到启动文件中)

 

(附件:基本连通的PKT文件,大家可以下载实验)