What is a VLAN database and how to delete VLAN.dat in Cisco to remove VLANs?
VLAN database is used to store VLAN information in the Cisco switch. Vlan.dat is a database file that contains all the configuration of the VLAN.
To completely delete the VLANs, we have to delete the Vlan.dat file.
Usually, when we have to erase the switch configuration, we can delete the startup configuration file and then reboot the switch. However, if we have configured the VLANs on the switch then VLAN information will not be removed by deleting the configuration file.
It’s easy to forget about the VLAN database file as all other configurations can be removed by removing the configuration files and the network administrator may not realize that VLAN configuration is still present on the switch.
To completely delete all present configurations on the switch, we have to delete the startup configuration and VLAN database file.
We can see in the animation below that the switch has two VLANs created and ports are assigned to these VLANs however, in the running configuration and startup configuration, VLAN information is not available.
Now, after deleting the startup configuration and rebooting the switch, we can see that all other configuration has been removed however the VLANs are still showing up. The difference here is that the interfaces assigned to those VLANs are removed now.
How to delete the VLAN database on the Cisco switch
The Vlan.dat file is stored in the flash storage of the switch and we will use the following command to delete the VLAN database file vlan.dat to remove the VLAN configuration.
Switch#delete flash:vlan.dat
Delete filename [vlan.dat]?
Delete flash:/vlan.dat? [confirm]
After deleting this file, VLAN configuration will be removed and we will not have any VLAN available apart from default VLAN 1.
Create Vlan.dat file
Once deleted, the vlan.dat file will not show up in the flash storage so whenever we will create the VLANs again, this file will be created automatically by the switch.
Using old switch in a working network
When we have to use the old switch within the production network, the configuration of the old switch should be removed completely.
Removing the VLAN configuration is a must because VTP can sync the VLAN database with the other switch on the network and this can cause a big issue for the production network.
VTP is Cisco proprietary protocol so if we are using switches of some other vendor then replication of the VLANs will not happen however it’s always a good practice to clear up the configuration before using the old switch in the production network.