Using IOS Menus to Load Labs
Since I am using my home lab for the bulk of my training, I have been trying to find a way to easily load different lab configurations so I can rework different things or just practice a lab over and over. One easy and pretty slick way to accomplish this is to use the menu command built into the IOS.
In the example below, I have created a menu that prompts me to choose which lab I would like to load. All of the configuration files exist in a LabConfigs directory within the root of my TFTP server. Once I choose an option, the router/switch reaches out to the TFTP server for the configuration file and copies it to the startup-config. After this is complete, I have to issue a reload command to bring up the device with the selected configuration.
HQ-RTR(config)# menu LoadConfig title ^C
*************************************************************************
* Choose the lab you would like to load...
*
* When you select the option, the configuration will be downloaded
* from the TFTP server. You will need to issue a reload command after
* the file transfer is complete.
*************************************************************************
^C
HQ-RTR(config)# menu LoadConfig prompt ^CEnter your option and press Return:^C
HQ-RTR(config)# menu LoadConfig text 1 "Load Lab 1"
HQ-RTR(config)# menu LoadConfig command 1 copy tftp://10.10.100.15/LabConfigs/Lab1 startup-config
HQ-RTR(config)# menu LoadConfig text 2 "Load Lab 2"
HQ-RTR(config)# menu LoadConfig command 2 copy tftp://10.10.100.15/LabConfigs/Lab2 startup-config
HQ-RTR(config)# menu LoadConfig text 3 "Load Lab 3"
HQ-RTR(config)# menu LoadConfig command 3 copy tftp://10.10.100.15/LabConfigs/Lab3 startup-config
HQ-RTR(config)# menu LoadConfig text 4 "Load Lab 4"
HQ-RTR(config)# menu LoadConfig command 4 copy tftp://10.10.100.15/LabConfigs/Lab4 startup-config
HQ-RTR(config)# menu LoadConfig text 5 "Exit"
HQ-RTR(config)# menu LoadConfig command 5 exit
HQ-RTR(config)# menu LoadConfig clear-screen
HQ-RTR(config)# menu LoadConfig default 5
See Cisco’s official documentation for definition on each command does and its syntax.
- menu name title: very similar to the banner command. Allows for a title for the menu.
- menu name prompt: Text that displays to tell the user to make a selection.
- menu name text menu-option: Displays the text of the menu option
- menu name command menu-item: This is the command that will run when the corresponding menu option is selected.
- menu name clear-screen: This clears the terminal window before displaying the menu
- menu name default menu-option: This is the default action that will be taken if you press enter and do not select an option
Now that you have entered all of that into the router, you can call up the menu by typing menu LoadConfig. This will present you with the menu that you have just so painstaking configured.
HQ-RTR# menu LoadConfig
*************************************************************************
* Choose the lab you would like to load...
*
* When you select the option, the configuration will be downloaded
* from the TFTP server. You will need to issue a reload command after
* the file transfer is complete.
*************************************************************************
1 "Load Lab 1"
2 "Load Lab 2"
3 "Load Lab 3"
4 "Load Lab 4"
5 "Exit"
CEnter your option and press Return:
One thing that I have done is to create an alias for the menu LoadConfig command that I have to run every time I want to bring up this menu. This can be done by entering the following:
HQ-RTR(config)# alias exec Lconfig menu LoadConfig
This will allow you to only type Lconfig to display the menu you have created.
I hope this helps you as it has helped me switch back and forth between different home lab configurations.
