Configuration of Security Contexts
The configuration of a security context is broken down into seven steps:
- Enable multiple security contexts globally.
- Set up the system execution space.
- Specify a configuration URL.
- Allocate the interfaces.
- Configure an admin context.
- Configure a customer context.
- Manage the security contexts (optional).
Refer to Figure 9-3 throughout this section to visualize how to configure a virtual firewall.
Step 1: Enabling Multiple Security Contexts Globally
The security context can be enabled by using the mode multiple command, as shown in Example 9-2. When this command is executed, the security appliance prompts the system administrator to verify mode conversion before proceeding further. This initiates the reboot process to complete mode conversion.
Example 9-2. Enabling Security Context
Chicago# configure terminal Chicago(config)# mode ? multiple Multiple mode; mode with security contexts single Single mode; mode without security contexts Chicago(config)# mode multiple WARNING: This command will change the behavior of the device WARNING: This command will initiate a Reboot Proceed with change mode? [confirm] Convert the system configuration? [confirm] The old running configuration file will be written to disk0 The admin context configuration will be written to disk0 The new running configuration file was written to disk0 Security context mode: multiple *** *** --- SHUTDOWN NOW --- *** *** Message to all terminals: *** *** change mode Rebooting.... Booting system, please wait... ! Output omitted for brevity. INFO: Context admin was created with URL disk0:/admin.cfg INFO: Admin context will take some time to come up .... please wait. Chicago>
When multiple-mode conversion is initiated, the security appliance prompts the administrator to convert the current running configuration into the system execution space and admin context. The appliance stores the system execution space in NVRAM and saves the admin context in the local Flash memory as admin.cfg. During conversion, it copies all the network-related information to the admin.cfg file, while all the device-related system information is stored in the NVRAM space.
Once the appliance comes online, you can use show mode to verify whether it is running in multiple mode. Example 9-3 shows the output of show mode.
Example 9-3. Verifying Virtual Firewall Mode
Chicago# show mode Security context mode: multiple
To convert the device back to single mode, you have to copy the saved old_running.cfg as the startup configuration. After that, you need to switch the security appliance to single mode. Both of these steps are shown in Example 9-4.
Example 9-4. Reverting to Single-Mode Firewall
Chicago# copy disk0:/old_running.cfg startup-config Source filename [old_running.cfg]? Copy in progress...C 1465 bytes copied in 0.250 secs Chicago# configure terminal Chicago(config)# mode single WARNING: This command will change the behavior of the device WARNING: This command will initiate a Reboot Proceed with change mode? [confirm] Security context mode: single *** *** --- SHUTDOWN NOW --- *** *** Message to all terminals: *** *** change mode Rebooting....
Step 2: Setting Up the System Execution Space
As mentioned earlier, the system execution space is created as soon as multiple mode is enabled. To access the system execution space, you can do either of the following:
- Access the security appliance via the console or the auxiliary port.
-
Log into the admin context using SSH or Telnet, and then switch to the system execution space. (The admin context is discussed earlier under the "Architectural Overview" section.
If you are logged into the admin context, you need to use the changeto system command to get access to the system execution space. Example 9-5 demonstrates how to log into the system from the admin context.
If you are in a security context, the host name contains a /. The text before the / is the host name of the security appliance, while the text after is the name of the security context. If the host name does not contain a /, you are in the system execution space.
Example 9-5. Switching to System Execution Space
Chicago/admin# changeto system Chicago#
The purpose of system execution space is to define the admin and customer contexts on the appliance. A context can be added by using the context command followed by the name of the context. Example 9-6 shows how to add CustA and CustB security contexts in the Chicago ASA. The security context name is case sensitive, so double-check it when adding the contexts. The appliance takes you into the context subconfiguration mode (config-ctx) to configure the necessary parameters.
Example 9-6. Adding Customer Contexts in System Execution Space
Chicago# configure terminal Chicago(config)# context CustA Creating context 'CustA'... Done. (2) Chicago(config-ctx)# exit Chicago(config)# context CustB Creating context 'CustB'... Done. (3) Chicago(config-ctx)# end Chicago#
The Cisco appliance allows you to add a description to the configured contexts. It is recommended that you add a description under each context for references purposes, as illustrated in Example 9-7.
Example 9-7. Configuring a Description on the Security Context
Chicago(config)# context CustA Chicago(config-ctx)# description Customer A's Security Context Chicago(config-ctx)# context CustB Chicago(config-ctx)# description Customer B's Security Context
Step 3: Specifying a Configuration URL
The configuration URL specifies the location of the startup configuration for each context. The configured contexts (either admin or customer) are not active unless there is a configuration URL. The supported storage locations include the local disk and a network drive using the HTTP, HTTPS, FTP, or TFTP protocol. Once a configuration URL is specified, the Cisco ASA tries to retrieve the configuration from that location. If it does not find the configuration file, the Cisco security appliance creates a configuration file with the default settings.
An administrator can choose to specify different external servers as the configuration URL location for the security contexts. As shown in Figure 9-3, the Chicago ASA has an admin and two customer contexts. The system administrator prefers to use the following:
- A TFTP server, 192.168.10.50, to store the CustA configuration
- An FTP server, 192.168.20.50, to save the CustB configuration
- The local disk for the admin context configuration
By default, these configuration files are saved in the root directory of the network protocol used by the context. For example, if the root directory of an FTP server is C:\FTP\files, the configuration URL using the FTP protocol will save the configuration file at that location. The security appliance saves the configuration of these security contexts when either write memory or copy running-config startup-config is issued from within the security context. Example 9-8 shows the relevant configuration to define configuration URL.
Example 9-8. Setting config-url for Security Contexts
Chicago(config)# context admin Chicago(config-ctx)# config-url disk0:/admin.cfg Chicago(config-ctx)# context CustA Chicago(config-ctx)# config-url tftp://192.168.10.50/CustA.cfg Chicago(config-ctx)# context CustB Chicago(config-ctx)# config-url ftp://cisco:cisco123@192.168.20.50/CustB.cfg
For the FTP protocol, you have to specify a username and a password to save and retrieve the configuration file. In the previous example, the CustB context is set up to use cisco as the username and cisco123 as the password.
When the configuration URL is changed, the appliance merges the running configuration of a context with the new configuration specified in the URL. This may add unnecessary commands and may cause system instability. If you do not want to merge the two configurations, you can follow these guidelines:
- Log into the security context whose URL is to be changed, and clear the running configuration.
- Log into the system execution space and enter into the context configuration mode.
- Specify the new configuration URL that you want to use.
As soon as the new URL is entered, the appliance loads the new configuration immediately in the running configuration. Example 9-9 shows how the security appliance in Chicago can be configured to use a new configuration URL. The CustA context is currently using a TFTP server to retrieve the startup configuration; however, the administrator wants to use an FTP server instead.
Example 9-9. Changing the Configuration URL
Chicago# change context CustA Chicago/CustA# configure terminal Chicago/CustA(config)# clear configure all Chicago/CustA(config)# changeto system Chicago(config)# context CustA Chicago(config-ctx)# config-url ftp://cisco:cisco123@192.168.10.50/CustA.cfg
Step 4: Allocating the Interfaces
After defining the configuration URL, the next step is to allocate interfaces to each of the security contexts. You can assign either a physical interface or a subinterface to a security context. Do this by entering into the context subconfiguration mode and using the allocate-interface command:
allocate-interface physical_interface [map_name][visible | invisible] allocate-interface physical_interface.subinterface[ -physical_interface. subinterface] [map_name[ -map_name]][visible | invisible]
The allocate-interface command can hide the physical interface name from the security context if a mapped name is used. This provides additional security by displaying only the mapped name to the context administrator.
Table 9-3 lists and defines the arguments used in the allocate-interface command.
Table 9-3. allocate-interface Command Definition
Syntax |
Description |
physical_interface |
Physical interface that is being allocated to a context, such as GigabitEthernet0/0. |
subinterface |
Subinterface that is being allocated to a context, such as GigabitEthernet0/0.1. A range of subinterfaces can also be specified. |
map_name |
By default, the allocated interface is displayed as the interface ID in the context. If you want to display the name for an interface instead of the interface ID, you can specify an alphanumeric mapped name. This is extremely useful when you do not want the context administrator to find out which physical interface is being used as the inside or the outside interface. You can also specify a range of mapped names for the corresponding range of subinterfaces. |
invisible |
If the invisible keyword is configured, the appliance does not display the interface ID in the configuration or the show interface command. This default option only shows the mapped name. |
visible |
If the visible keyword is configured, the appliance displays the interface ID in the configuration and the show interface command. |
In Example 9-10, the ASA in Chicago is configured to allocate GigabitEthernet0/0 and GigabitEthernet0/1 to CustA and are mapped as A_inside and A_outside, respectively. The invisible option is used at the end to hide the physical interface name when the context administrator looks at the interface configuration or statistics. The appliance is also set up to allocate GigabitEthernet0/2 and GigabitEthernet0/3 to CustB. The context administrators will see these interfaces as B_inside and B_outside.
Example 9-10. Allocating Interfaces to Security Contexts
Chicago(config)# context CustA Chicago(config-ctx)# allocate-interface GigabitEthernet0/0 A_inside invisible Chicago(config-ctx)# allocate-interface GigabitEthernet0/1 A_outside invisible Chicago(config-ctx)# exit Chicago(config)# context CustB Chicago(config-ctx)# allocate-interface GigabitEthernet0/2 B_inside invisible Chicago(config-ctx)# allocate-interface GigabitEthernet0/3 B_outside invisible
Step 5: Configuring an Admin Context
Cisco ASA creates an admin context automatically, if you convert it from single to multiple mode and you answer "yes" to "Convert the system configuration?" The admin context is treated as any other customer context in the security appliance. To log into the admin context, use the changeto context command, as shown in Example 9-11, where an administrator logs into admin context called admin.
Example 9-11. Logging into a Security Context
Chicago# changeto context admin Chicago/admin#
If you would rather designate a different context as the admin context, use the following command in the system execution space:
admin-context context_name
where context_name is the name of the context you want to designate as the admin context. Before a context is declared to be an admin context, it must meet two requirements:
- The context must be predefined and have a config-url.
- The config-url must point to a file in the local disk.
Example 9-12 shows how to designate CustA as the admin context in a security appliance. Because CustA used a TFTP server to store the startup configuration, the administrator is modifying it to use the local disk0 before setting up the admin-context command.
Example 9-12. Setting Up an Admin Context
Chicago(config)# context CustA Chicago(config-ctx)# config-url disk0:/CustA.cfg Chicago(config-ctx)# exit Chicago(config)# admin-context CustA
Not sure which context is set up as the admin context? Use one of the following three methods to find out:
- show running-config | include admin-context
- show admin-context
- show context, and look for the context name with an asterisk (*)
In Example 9-13, the highlighted entries indicate that CustA is currently set as the admin context.
Example 9-13. Verifying the Admin Context
Chicago# show running-config | include admin-context admin-context CustA Chicago# show admin-context Admin: CustA disk0/:CustA.cfg Chicago# show context Context Name Interfaces URL admin Management0/0 disk0:/admin.cfg *CustA GigabitEthernet0/0, disk0:/CustA.cfg GigabitEthernet0/1 CustB GigabitEthernet0/2, ftp://cisco:cisco123@192.168.20.50/CustB.cfg GigabitEthernet0/3
Step 6: Configuring a Customer Context
Any context that is not set up as the admin context is referred to as the customer context. As mentioned earlier in this chapter, a customer context is configured similarly to a standalone firewall, with a few exceptions that are listed in Table 9-1. When an administrator logs into a customer context, the command prompt displays the name of that context, as shown in Example 9-14.
Example 9-14. Logging Into a Security Context
Chicago# change to context CustA Chicago/CustA#
After logging into the customer context, you can configure all the supported firewall-related options.
Step 7: Managing the Security Contexts (Optional)
Cisco ASA provides many ways to manage and optimize system resources. For example, if a context name is mistyped or if it needs to be deleted, you can remove it by typing no context followed by the name of that context. In Example 9-15, the administrator of the Chicago ASA does not want to use CustB as a customer context anymore; instead, the administrator wants to remove it from system configuration. By deleting any unused security context, you do not waste security contexts, which are restricted by the system license. Additionally, the system does not have to allocate CPU and memory resources to maintain the unused contexts.
Example 9-15. Removing a Security Context
Chicago(config)# no context CustB WARNING: Removing context 'CustB' Proceed with removing the context? [confirm] Removing context 'CustB' (4)... Done
In a situation where all contexts need to be removed, you can use the clear configure context command, as shown in Example 9-16.
Example 9-16. Removing All Security Contexts
Chicago(config)# clear configure context