今天在一个国外站点上看到这么一篇文章。作者介绍说,当你删除Cisco Catalyst交换机的startup-config配置文件之后,再reload交换机,你会发现交换机上的vlan信息仍然存在,并没有被删除。
我用Packet Tracer 5.0亲自做了下实验假设有三个用户自建vlan 10/20/30,结果如下:
AS01#show vlan brief
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa0/4, Fa0/5, Fa0/6, Fa0/7
Fa0/8, Fa0/9, Fa0/10, Fa0/11
Fa0/12, Fa0/13, Fa0/14, Fa0/15
Fa0/16, Fa0/17, Fa0/18, Fa0/19
Fa0/20, Fa0/21, Fa0/22, Fa0/23
Fa0/24, Gig1/2
10 dianjixi active Fa0/1
20 caihuaxi active Fa0/2
30 zihuanxi active Fa0/3
100 admin active
1002 fddi-default active
1003 token-ring-default active
1004 fddinet-default active
1005 trnet-default active
AS01#erase startup-config (PS:这里用write erase命令效果一样!)
Erasing the nvram filesystem will remove all configuration files! Continue? [confirm]
[OK]
Erase of nvram: complete
%SYS-7-NV_BLOCK_INIT: Initialized the geometry of nvram
AS01#reload
Proceed with reload? [confirm]
%SYS-5-RELOAD: Reload requested by console. Reload Reason: Reload Command.
Switch>en
Switch#show vlan brief
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa0/1, Fa0/2, Fa0/3, Fa0/4
Fa0/5, Fa0/6, Fa0/7, Fa0/8
Fa0/9, Fa0/10, Fa0/11, Fa0/12
Fa0/13, Fa0/14, Fa0/15, Fa0/16
Fa0/17, Fa0/18, Fa0/19, Fa0/20
Fa0/21, Fa0/22, Fa0/23, Fa0/24
Gig1/2
10 dianjixi active
20 caihuaxi active
30 zihuanxi active
100 admin active
1002 fddi-default active
1003 token-ring-default active
1004 fddinet-default active
1005 trnet-default active
不过,startup-config文件删除,没有任何端口加入vlan,因此对于vlan 10/20/30没有相关端口信息。
但是,从以上例子中,可以清楚地看到之前创建并激活的vlan并没有随startup-config的删除而删除。这是为什么呢?文章作者解释,自建的vlan信息实际上保存在交换机Flash的vlan.dat文件内,该文件不会在删除startup-config的时候被删除,也不会在reload之后清空内容或被删除。以致当重启交换机后,仍然可以从该文件中读取之前保存的vlan信息。该文件需要被手工删除。
这里还需要注意的是,删除该文件时,需要确认两遍,提示是否删除文件时,无需输入y,直接按回车即可。如果你输入y,则相当于告诉系统你要删除的是名为y的文件,删除会失败。如下所示:
Switch#delete vlan.dat
Delete filename [vlan.dat]?y
Delete flash:/y? [confirm]
%Error deleting flash:/y (No such file or directory)
正确的做法就是:
Switch#delete vlan.dat
Delete filename [vlan.dat]?
Delete flash:/vlan.dat? [confirm]
好了,现在重启,之后再来show一把:
Switch#sh vlan b
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa0/1, Fa0/2, Fa0/3, Fa0/4
Fa0/5, Fa0/6, Fa0/7, Fa0/8
Fa0/9, Fa0/10, Fa0/11, Fa0/12
Fa0/13, Fa0/14, Fa0/15, Fa0/16
Fa0/17, Fa0/18, Fa0/19, Fa0/20
Fa0/21, Fa0/22, Fa0/23, Fa0/24
Gig1/2
1002 fddi-default active
1003 token-ring-default active
1004 fddinet-default active
1005 trnet-default active
此时,vlan 10/20/30才真正被删除了。老实说,关于这个问题,本人以前也从来没有考虑过,注意细小的地方,往往会帮助你更多地了解设备,希望本文对大家的日常工作以及备考思科认证有所帮助。
原文链接: http://www.akirajobs.com/2009/01/09/ccna-ccnp-home-lab-tutorial-the-vlandat-file/
(Catalyst 2960 Series真机实验出现以上问题)