Hi, and welcome to this CertificationKits CCNA Training video on Router IOS Recovery. I am going to talk a little bit about the errors you might get when you are booting up your router such a Bad File Magic Number. We will also look at the commands Boot Flash which allows us to choose a particular file in Flash to boot to from ROM Monitor mode, the TFTP Download command which allows us to load a new IOS with IP connectivity and installing an IOS through the Line Console if you cannot establish IP connectivity using the Xmodem command. We will also go over a couple little troubleshooting tips if you run into problems using the TFTP Download or the Xmodem command when you install through ROM Monitor mode.
Now when you are booting up your router and you get an error Bad File Magic Number and the router takes you to ROM Monitor mode, ROM Monitor mode is like a safe mode for your router. There are two reasons you might get this error Bad File Magic Number. The first one is you have got something in Flash, but there is more than one file in Flash and the first file is not a valid IOS. So what’s happening is it’s trying to load an invalid file as the IOS. That’s the first problem you might run into. The second problem you might run into is the IOS in Flash itself is corrupted. Flash is corrupted, no longer working or somebody went in and accidentally erased Flash. Not a good idea to do. And the IOS is missing so the router can’t load the operating system. So it comes up to ROM Monitor mode.
Remember ROM Monitor mode looks something like this and it’s basically a safe mode for your router that you can go in and access and load an IOS and go and repair your router. So it’s like a safe mode. Let’s take a look at what you are going to do when you run into this problem here. So again, the IOS is there but there is more than one file in Flash and the router is trying to load the wrong file as the IOS. Since I don’t have the appropriate version of ROM Monitor on the router I have and my CCNA stimulator doesn’t have the appropriate version that won’t let me to get into the ROM Monitor mode, I just basically typed up an example of what it’s going to look like and what you are going to want to do.
Now the dir command basically is a listing command. We can use this command to list what’s in a particular area of the router. So dir Flash will show me what’s in Flash. This is one of the first things I want to check if I get into the ROM Monitor mode and I get that Bad File Magic Number. Maybe the IOS is in Flash, but there is another file it’s trying to load. If I do a dir Flash and I see the IOS in there and there is another file in there; I can go in and I can use the boot flash command, this guy right here. What this allows me to do is it allows me to go in and specify the file that’s in Flash that I want the router to boot to. Once I have specified the appropriate file in Flash to boot to, the router will go ahead and try to load that file. And as long as it’s a valid IOS, we will go ahead and decompress the IOS, move it into RAM and the router will load appropriately.
Then I can go into Flash and get rid of those bad files or I can use what’s called a boot system command. Now a boot system command allows me to specify what file in Flash I want to boot to. Let’s take a look at that. I am going to bring up my router and we go in and we take a look at these boot system commands. So we will pretend that the router booted successfully. I loaded the IOS, and if I want to, I can go in and specify what file in Flash I want to boot to. So the first thing I want to do is see what is in it, what is inside of Flash. So I do show Flash, see what’s in there. Again, there might be more than one file as opposed to just the IOS. Then I can go in and specify, “Hey, this is the file in Flash I want to boot to with this boot system command.”
Configure terminal, in the privilege or a global mode, boot system, question mark. Now what I can specify is a TFTP filename or a URL, Universal Resource Locator. Flash, I can specify Flash and then the filename in Flash that I want to boot to. So I could specify, “Hey, boot to this filename in Flash.” So what I would do is I go boot system Flash and I can just copy and paste this filename there. And then we will go ahead and boot to that particular filename. I can also boot to mop, rcp as well as a regular tftp server. I just have to specify the file in tftp server and things like that. So there is more than one file in Flash and I want to control which one my router is going to boot to. Then I can use this boot system command that is stored in Startup configuration, and that will go ahead and solve that problem, or I can go in and try to clean those invalid files out of Flash.
I have exited out of there and if there were additional files in Flash, and if I did a show Flash and I see additional files in there that shouldn’t be there, I can use the delete command, do not erase Flash. Notice it says carriage returned. If you do this, it will erase the file system and get rid of everything in Flash. So I put no on that or basically your IOS will be gone. So it’s always a good idea to make a backup of your operating system just in case you don’t want to erase Flash. Delete Flash is a different thing. I can go delete and then the filename in Flash to delete. I could if I wanted to store like the startup-config or running-config in Flash if I wanted to have another backup of it, not really recommended. But if I want copy, run and then give it a name sample-config or whatever, well what happened is since I didn’t specify a valid location, what it does is it takes the running-config and puts this sample-config and puts it into Flash, so Flash load helper.
On this particular router, it’s actually got to reboot the router to be able to do this. More advanced or more modern routers, they don’t have to actually do that. It will actually just put it right in the Flash. So if you type copy running-config and then misspell startup-config or something like that, what will happen is – let’s say if I just do this copy running-config, startpu-config, whatever. That’s why it’s always a good idea to use the tab key instead of trying to type everything out yourself. So if I mistyped something like startpu-config, it will automatically just put it right into Flash. So you have to be careful of that because you can’t keep additional files into Flash.
Now if those additional files do go into Flash, they will not be the first thing in Flash. So if I do a show Flash, the IOS that’s there will be the first file and it will still boot appropriately. Just in case so it’s a good idea to be aware of additional files you might put into Flash. If you load a new IOS after those other files are put into Flash, you might run into some problems, and those boot system commands can be helpful. I have brought up my previous slide and we just talked about if there were multiple files in Flash, things that you can do. Now I want to talk about when the IOS in Flash is corrupted or missing, what are we going to do? We boot up. We get to ROM Monitor mode. What can we do at this point to get an IOS into the router when we can’t really access TFTP servers and things like that very easily because the operating system isn’t there to load?
What I have done is I have gone in and downloaded a couple of samples since I can’t really run these from the router I have or through the CCNA stimulator. What this is is this is the tftpdnld command, and this seems to be case sensitive when you are running it through the router. So tftpdnld. What I do is in this situation, what’s happening is we have no IOS in Flash or it’s corrupted, so we need to run and load a new one. Certain monitor routers have this tftpdnld command available. What I can do is is the first thing I would do is I would just type in HELP and see if it was there in ROM Monitor mode. If tftpdnld is available, then I am going to use that to load the new IOS. SET right here, what this is going to do is this is going to show me these variables. I have to go in and configure these variables in ROM Monitor mode on the router so I can access a tftp server to pull the IOS from and reprogram Flash.
So Set will show me these variables. What’s nice about this, tftpdnld shows me how to type these things in. It shows me variable name right here. This is what you want to key on and variable name equals value. So this is actually what I would type in if I wanted to set an IP address up top here. IP_ADDRESS equals – and I would give the router an IP address that’s able to communicate with the tftp server. So let me go in and look at that in my NetMap here. What you could do is if you have got a router you needed to load, plug directly into the Ethernet port on the router from your tftp server or if you have a laptop, put a tftp server on it and plug directly into the Ethernet port on the router. What you can do then is have an IP address on the tftp server so the tftp server I go in and check the IP I have 172.16.1.2.
So if I am looking at the NetMap, this interface on the router I have given IP address of 172.16.1.1 instead of 172.16.1.2, an IP address that can communicate directly with the tftp server. And what I would do is I would put that new IOS in the tftp route and that way, I can load it directly into the router with this tftpdnld command. Let’s go back and look at that a little bit further. So I put the IP address in. Then I go IP_SUBNET_MASK and again it’s got to be IP_SUBNET_MASK. They show you all the variables you have to fill out down here. So this is where you see all your variables. This shows you how to use those variables, variable name, value. So it’s variable name equals value, and again it will look just like this IP_SUBNET_MASK. IP_DEFAULT_GATEWAY.
If I don’t have to go through another broadcast, I mean like the picture I showed you I am directly connected to the tftp server, so I have got router connection directly to the tftp server, I just put the router’s IP address as a gateway; I just put its own IP as a gateway. I do that because again this variable has to be filled out. I specify the IP address as a TFTP server 1.2; this is 1.1, and then the filename of the new IOS that is stored in the TFTP route. And what I will do at that point, once you have all those variables configured, again go in and type the SET command. Make sure everything looks okay, and what you can do then is go in and just type in tftpdnld. Once all your variables are set at this point at the prompter, you just type in your tftpdnld command and hit enter. If everything is configured correctly, if all these variables up here are configured correctly, it will go ahead and run and start loading the IOS. If there is a problem, it won’t. So you have got to make sure to run that SET command and verify all these variables.
One other thing that you can check is if you are in there, once you set all those variables, the TFTP server should be able to ping the IP address you have set on the router. So make sure it can ping. If it can’t, check the cabling, check your IPs again. But make sure once those variables are set, you can actually ping the router. Other things to check for is make sure your TFTP server is up. So if run this tftpdnld command, if you can actually read that tftpdnld, so once you run this command and if it’s not working, check your cabling, make sure the TFTP server is up. Make sure the TFTP filename is there in the TFTP route. Make sure you can ping, things like that. If one of those things is off, it’s not going to work.
So that’s the tftpdnld. Again, if it’s available, tftpdnld is a very useful tool. It’s not available on all routers. And if it’s not, you are going to have to load the input output system through the Line Console. So this is how we are going to do that. Again, I am in ROM Monitor mode; I don’t have an IOS. And what happens in this situation, I have got my router; I have got the console port on the router that we connect up through hyper terminal and I have my computer through that Line Console connection and I have got my hyper terminal open. So what can happen is I can store the IOS on my desktop if I want to and I can use what’s called the Xmodem command to actually load the IOS through this console port. The only problem with that is it’s going to be a little bit slower. The max speed I can get if you look down here 115200, that’s a lot slower than a 10-meg connection through Ethernet.
The first thing you want to do is in ROM Monitor, the confreg command, this changes our configuration registered number. The configuration registered number, again the default 0x2102, this configuration registered number controls how the router boots. Again, this tells us to grab the first file in Flash; this tells us to use the startup configuration. Other combinations of the numbers change the baud rate, change diagnostics, things like that. By default, our baud rate is 9600 bits per second, very, very, very slow. So first thing we want to do is change the baud rate and that’s what this confreg utility is going to allow us to do. We just type in confreg, it gives us a summary and it asks us if we wish to change the configuration and we are going to say yes to that.
Now all I have to do, the only thing I am worried about is changing this baud rate down here where it says change console baud rate. I can read. Everything else I am not worried. So enable diagnostic mode. Everything that you see in here is in brackets, so the N is in brackets. That means all I have to do is hit Enter, keep hitting Enter and the default is no, meaning I am not going to change anything. Once I get to change the console baud rate, I want to say yes, and what I am going to do is I am going to select 7 here. So right now it’s at 0 which is 9600, I specify 7. That ups it to 115200. If you do not change the console baud rate, it will take you couple hours, an hour and a half to two and a half hours, to load the IOS as opposed to 20 to 30 minutes. Again, paid by the hour, maybe you don’t want to change it, I don’t know, but again it will take you a lot longer if you don’t up this baud rate. So remember to do that, otherwise it’s going to take a couple of hours.
Once you have gone in and changed it, it will ask me. Again, it gives me a summary. It says do I want to change the configuration. If I like what I see, I see the new baud rate here. I am going to say no and it’s going to tell me to reset or power cycle for new config to take effect. At this point, I am going to type in reset and hit Enter, and it will go ahead and reboot my system. Again, I haven’t done anything but changed the baud rate. So what I have to do is make a new hyper terminal connection. So if I am connected through hyper terminal, what I will do is I will disconnect and I can actually go in to the properties and I can reconfigure my connection. So what I would do is I would change 9600 to 115200. If I don’t, I am not going to see anything in hyper terminal. Settings on my hyper terminal have to match the settings for the speed on the Line Console on the back of the router.
So I just select 115200 and then I would be able to see things in here. Again, I would be coming back up into the ROM Monitor mode. So once I reset it, let it reboot, come back into ROM Monitor mode, change my baud rate on hyper terminal so I can see things. At that point, I can go in and use the Xmodem command. So let’s take a look at that xmodem command. So I have brought up another sample here of the Xmodem command. If you want, you can just close your eyes and pretend that I am on a real router. Now this is what it’s going to look like when we run Xmodem. So I have got ROM Monitor 2, rommon 2 and then all I have to do, again after changing the baud rate unless I want it to take a couple hours, I type xmodem and then the name of the file I am going to load.
What’s going to happen is it’s going to say don’t start sending the program yet, blah, blah, blah, all existing data in the Boot Flash will be lost. Not a big deal since the reason I am doing this in the first place is because all the data in Boot Flash is lost. It says invoke this application only for disaster recovery. Do I want to continue? Just missing the UE right there. And then if I say yes, then it’s going to go ahead and wait for the file. So it’s really simple. I just put the IOS on my desktop and I actually just copy and paste the name of the IOS right here. I go Xmodem paste, put the name of the file. And then what I do is when it’s saying ready to receive file, I just sit there taking away, I go to my hyper terminal and at the top here, I just pretend this says rommon and all that and when I receive file. I go transfer, send file. I choose Xmodem. I browse to my desktop where I have the file. I don’t actually have the file on my desktop. So I would go to my desktop, pretend the file is there, select the file and then I would hit. As soon as I saw the path in here to wherever the file is, it doesn’t matter, I hit Send. And what will happen is it will go through and it will start uploading the file.
Again, it takes about 20 minutes to do this, 20 to 30 minutes depending on the size of the IOS. If you do not change your baud rate, it’s going to go ahead and take close to a couple of hours. So again, once you have done this here, Xmodem, filename, blah, blah, blah, yes I want to do it, then you just use your hyper terminal and go transfer, send file, select your file, make sure you put the protocol to Xmodem on there. So when you go transfer, send file, it starts off as Zmodem by default, you are going to go Xmodem, browse your file, then hit Send. That’s it. So again, this is something you do when you try to boot your router and the IOS in Flash is corrupt or it’s just not there and we can use the Xmodem. We don’t want to use this if the tftpdnld command is available because the tftpdnld is much faster and it takes maybe 10 minutes versus a half an hour, I would say actually less than five minutes. So this is our third option. First option is boot system command if the IOS is there. Second option is tftpdnld. Third option is Xmodem if the other two are not available.
In this CCNA video on IOS recovery, we have talked about Bad File Magic Number, again the error you are going to get when the IOS is gone, IOS install through the Line Console using Xmodem, tftpdnld, Boot Flash. Again, in opposite order, you want to try this first, this second, this third. And I also went over some CCNA troubleshooting things, especially for tftpdnld such as IP connectivity you are going to test with ping, making sure your cabling is appropriate; you have the right file and things like that. So I hope you have enjoyed this CertificationKits CCNA Training video on router IOS recovery.