I have a Cisco router, and I want to remove a few lines from startup-config. How could I do it? Do I need to copy it over to a PC, edit it there, then copy it back, or can I do it through the serial console somehow?
2 Answers
Edit: Karl Billington's method is superior and should be used when possible
The other (extremely painful) way is:
Setup a console connection if you don't already have one. The rest of the steps below are over the console connection
Reboot the switch, stop it at the rommon/bootloader (usually Control-C or break)
Configure the rommon/bootloader to ignore the startup Boot the IOS. It should come up with a default config after ignoring the startup-config
Run
show startup-config
. This will print the entire startup-config, including the undesirable lines that you want to remove.Now do a
conf term
and start pasting the output ofshow startup-config
, excluding the undesirable lines that you want to excludeIssue the command
wr mem
. This will save your edited config.Reboot. This time configure the rommon/bootloader to not ignore the startup-config
As you can see this is extremely messy, and is error-prone especially if your config is large. But if the real solution (editing it off-box and then copying it to the device) won't work for whatever reason, and you're in a "desperate times call for desperate measures" situation, you can give this a shot.
Yes, only real way is to copy the startup-config file to a PC and edit on there, then copy back. Of course the commands will not take effect until the next reload and you will have to be careful you don't corrupt the config in any way. Make sure you use a proper text editor like Notepad++ and not a word processor when you edit to make sure you don't insert any odd character codes.
-
I used a USB drive, but after connecting it to a PC ios won't recognize it. Apr 8, 2018 at 19:20
-
What filesystem is it formatted with? Needs to be FAT– user27899Apr 8, 2018 at 19:38
-
It's formatted on the router, it works perfectly, then I plug it into a windows PC, and even if I do nothing with it and connect it back to the router it won't work anymore Apr 8, 2018 at 19:43
-
Try another drive, or you could use TFTP - try Solarwinds free TFTP server– user27899Apr 8, 2018 at 19:54