|
4-1. Using Security Contexts to Make Virtual FirewallsBeginning with PIX 7.0 and Firewall Services Module (FWSM) 2.2(1), you can configure one physical firewall chassis to act as multiple virtual firewalls. Each virtual firewall is called a context because it is one partition or instance of a fully functional firewall. Even though all the configured contexts are emulated by a single firewall CPU, the traffic inspection and security policies of each are kept separate, as if they were being handled by a dedicated physical firewall. Therefore, each context can be configured and managed by different administrators, or they can all be managed by one administrator who has access to them. Traditionally, one physical firewall would be added to a network every time a new firewall function was needed. The cost of adding firewalls in this way is incremental. The ability to run multiple security contexts on a single firewall provides a way to limit the cost of firewall hardware. Firewall contexts can be added according to license limits. This capability does come with a trade-off, however, because all contexts must share the resources available on the hardware platform. Security contexts can be useful in both service provider and enterprise environments. A service provider can partition one physical firewall into multiple security contexts that can be assigned to customers for a recurring cost. Each customer can configure and manage his or her respective context. In an enterprise setting, multiple contexts could be assigned to individual departments or organizations where there is no overlap in security policies. Each department would operate its own firewall context independently of others. On the "public" side of each firewall, each context could connect to a shared or common Internet feed. Security Context OrganizationA Cisco firewall that can support security contexts can operate in only one of the following modes:
In multiple-context mode, a firewall is organized into the following functions, each having its own user interface:
Figure 4-1 shows how a single physical firewall can be organized to provide multiple security contexts. Each context has its own set of virtual firewall interfaces that are mapped from the physical or VLAN firewall interfaces. Figure 4-1. Single- and Multiple-Context Security ModesIn practice, the physical firewall platform might not have enough interfaces to be able to map them one-to-one with context interfaces. In Figure 4-1, the firewall would need two unique physical interfaces for each context! Even if there were enough interfaces to go around, you might not want to use all of them in the first place when only a few could provide the necessary connectivity. Sharing Context InterfacesMultiple-context mode allows some flexibility in mapping interfaces. You can map one physical interface to one context interface when isolation from other firewalls is required. You can also map one physical interface to several context interfaces so that the contexts share a single connection. This might be practical in an enterprise setting, where each context is designated for a different department. Most likely, an enterprise would have a single path toward the public Internet. Every department would share that path, provided by one physical firewall interface. As that interface is mapped to each context, the resulting logical or mapped interface would become the context's outside interface. Figure 4-2 illustrates this concept. Figure 4-2. Mapping Common Interfaces to ContextsPhysical interfaces can be shared in any configuration. For example, if two firewall contexts need to provide access to some authentication servers that they share, one physical interface could be mapped to those two contexts and no others. Finally, consider that all contexts are really emulated by one firewall platform. As packets enter a physical firewall interface, the firewall CPU must determine which context is the true destination. If one physical interface is mapped to one context interface, the firewall CPU simply takes packets arriving on that interface and puts them in the queue for that context interface. The mapped context must be the virtual firewall that will inspect and handle the inbound traffic. Suppose one physical interface is mapped to interfaces in several contexts. Now when packets arrive on that interface, the firewall CPU must decide which of the mapped contexts is the correct destination firewall. A firewall running in multiple-context mode uses a classifier function to sort out which context should actually process each inbound packet. In effect, a classifier is positioned at each firewall interface to decide which context should receive packets as they arrive. Figure 4-3 illustrates this concept. Figure 4-3. Using a Packet Classifier to Match Inbound Traffic to a Security ContextThe classifier is simple; if it can find a unique source interface or destination address, it has enough information to hand off a packet to a context. The classifiers shown at the bottom of Figure 4-3 have an easy job because their source interfaces are mapped to a single unique context. Packets arriving on the inside interfaces are passed directly to the respective context inside interfaces to begin the normal firewall stateful inspection process. However, if firewall interfaces are shared between contexts, as in the topmost interface shown in Figure 4-3, the problem becomes a bit more difficult. The classifier at the top of the figure is faced with the task of finding a unique destination context for each inbound packet. A classifier does this by attempting to find the packet destination address defined in one of the connected contexts. The destination address must be uniquely identified in one of the following ways:
A classifier also works in only one direction. Each packet that arrives on a shared interface is examined so that it can be sent to a specific context. Because of this, you should work through scenarios with a connection originating on each side of the firewall to make sure that the classifier process will work properly. The classifier must find the destination address as a global address entry in one (and only one) of the security contexts. For example, Figure 4-4 shows a simple arrangement in which two security contexts are configured to share their outside interfaces toward the public network. The left side of the figure shows what happens when a connection is initiated from inside host 192.168.1.100 to outside host 198.133.219.25. Because the inside context interfaces are not shared, the classifier nearest to the inside host can simply send the packets to Context A, where the host is connected. At Context A, the inside address is translated to global address 207.246.96.47, because of a static NAT configuration. Figure 4-4. Example of Sharing Outside Context InterfacesFor the return traffic from the outside host, the classifier examines arriving packets on the shared outside interfaces. The destination address is 207.246.96.47, which is found as a global address in the xlate table on Context A. Therefore, traffic originating on the inside network can make the round trip successfully. On the right side of Figure 4-4, a connection originates from the outside host, located on the shared interfaces. Here, the destination address 207.246.96.47 is again found as a global address in a static NAT xlate entry on Context A. This traffic too can make the round trip. What if a dynamic NAT or PAT were used instead of a static NAT? In that case, the dynamic NAT would be configured to use one or more global addresses during translation. In Figure 4-4, the global address is 207.246.96.46, which could be found in xlate entries for connections passing through Context A. The classifiers on either side of the firewall would have no problem finding the global address on Context A. Issues with Sharing Context InterfacesIf you decide to share the inside context interfaces, you should be aware of a classifier limitation. Consider the arrangement shown in Figure 4-5, where Contexts A and B share their inside interfaces. Figure 4-5. Example of Sharing Inside Context InterfacesThe classifier must examine packets entering from the inside networks to decide which context should receive them. A search is made to find the packet destination addresses in the context xlate tables. In particular, the classifier can find only global addresses in the tables. This means that there must already be a static NAT entry in place for the outside address to appear as a global address. In practice, this is seldom successful. The outside context interface usually points toward a public network such as the Internet, where most or all of the addresses exist but are not configured into the context. Usually, a default route points the way toward the public network where a context can find every other host that isn't explicitly configured. However, the classifier must use actual global addresses, not routes, so it can't determine which context to use to reach outside hosts. To remedy this situation, you would have to configure static NAT entries for each of the outside host addresses that might be involved in connections from the inside hosts! That might result in two extremes:
In most cases, the inside context interfaces are not shared because inside networks tend to be isolated and protected from every other network. However, another scenario deserves consideration. With multiple security contexts at your disposal, you might consider nesting or cascading contexts to provide layers or shells of security in an enterprise network. Consider Figure 4-6, in which the left portion represents such a hierarchy of security contexts. The topmost context might be used at the boundary with the Internet to provide common security policies for the entire enterprise. Then other contexts might be nested below that to serve individual departments or buildings within the enterprise. Figure 4-6. Example of Nesting Security ContextsTo test this scenario, the structure has been reduced on the right portion of the figure to show a cascade of just two security contexts. This turns out to be very similar to the previous example, in which the inside context interfaces were shared. However, it might not be obvious that the middle classifier is positioned where two context interfaces are shared. The Context A inside interface is shared with the Context B outside interface to build the cascading structure. Again, when packets originating from the inside hosts reach this classifier, chances are that no static NAT or global address will be configured or found for outside Internet hosts. Therefore, that classifier can't decide whether to send the packets to Context A or back to Context B. As a result, you should plan on nesting or cascading security contexts only if you can provide static NAT entries for each outside host that inside hosts will be allowed to contact. Otherwise, you can build a nested arrangement from separate physical security appliance platforms, where classifiers aren't needed between firewalls or contexts. Configuration Files and Security ContextsThe firewall's Flash memory file system is accessible only from the system execution space. This is because Flash is considered a controlled resource, available only to the physical firewall's administrators. If an individual user context is given over to be managed by a third party, it wouldn't make sense to allow that third party to make changes to or allocate all of the firewall Flash for his or her own use. Where, then, are the firewall image and configuration files stored for a user context? None of the contexts runs its own firewall operating system image. Only one image is run in multiple-context mode, and that image is managed only by the system execution space. All other contexts appear to run the same image, as shown by the output generated by the show version command. Configuration files, however, are used and maintained by each context. They have the following characteristics:
Guidelines for Multiple-Context ConfigurationYou can configure and use several different types of contexts on a physical firewall or security appliance:
Each has a specific role within the firewall platform, making configuration somewhat confusing. The system execution space handles context definition, overall firewall modes of operation, and the physical firewall resources. Therefore, it should be configured before resources and features become available to other contexts. You can configure the following types of features in the system execution space:
You must enter firewall license activation keys from the system execution space. In addition, the system execution space provides all access to the firewall's Flash file system. However, the system execution space has no networking capability of its own. To access external network resources, such as a TFTP server containing the firewall image, the system execution space must work in conjunction with the admin context, where normal IP addressing and address translation are configured. You should consider each nonsystem context to be a fully functional standalone firewall. Therefore, you can configure the admin and user contexts with all the firewall features presented in this book. Initiating Multiple-Context ModeFollow these steps to prepare a firewall for multiple-security context support:
Navigating Multiple Security ContextsIn multiple-context mode, it is possible to open an administrative session (console, Telnet, or Secure Shell [SSH]) to the firewall and then move around between security contexts. This allows you to configure and monitor any of the contexts as necessary without opening sessions to the individual virtual firewalls. You can navigate between contexts only if you successfully connect and authenticate to the admin context or the system execution space first. At that point, you are considered an administrator of the physical firewall platform and any contexts that are configured. If you connect to a user context first, the firewall limits your administrative session to only that context. This restricts the administrators of a user context from gaining access to any other context on the firewall. Each context is then independently managed from within that context. Context PromptsMoving between contexts can get confusing. During one administrative session, you might have to keep track of which physical firewall platform and which context (virtual firewall) you are connected to. Fortunately, the firewall gives you a landmark each time you move your session. The firewall always updates its prompt to indicate which context you are currently accessing. The traditional prompt, Firewall#, represents the system context; Firewall represents the firewall's host name. Any other context is indicated by a prompt such as Firewall/context#, where context is the name of the context. TIP As you move into various contexts, keep in mind that each context has its own startup and running configuration. Therefore, the running configuration must be saved on each context independently. Think of each context as an independent firewall. The admin context represents the firewall that is used by the platform administrators. The system execution space, although not a true context, provides the functions necessary to extend the physical firewall resources (interfaces, Flash memory, context definitions, and so on) to any admin and user contexts. Changing a Session to a Different ContextYou can move your terminal session from one context to another, as long as you have the administrative rights to do so, by entering the following command: Firewall# changeto {system | context name} For example, suppose your firewall has the host name MyPix. It also has a system execution space (always created by default), an admin context, and a user context called CustomerA. You can use the following commands to navigate between contexts: MyPix# MyPix# changeto context admin MyPix/admin# MyPix/admin# changeto context CustomerA MyPix/CustomerA# MyPix/CustomerA# changeto system MyPix# Notice how the session prompt automatically changes to indicate the firewall and context name each time the session is moved. Keep in mind that the system execution space is always called system and not context system. Therefore, it doesn't really have a context name to be displayed in the prompt. Configuring a New ContextAll contexts must be defined from a firewall's system execution space. Make sure you position your session in the system space with the following command before continuing: Firewall# changeto system The firewall also needs an admin context to be able to communicate beyond itself. The admin context is usually built automatically when the firewall is configured for multiple-context mode. As well, each time the firewall boots up, you should see console messages indicating that the admin context has been rebuilt. To see a list of the contexts that have been configured, you can use the following command: Firewall# show context In the following example, only the admin context has been built: Firewall# show context Context Name Interfaces URL *admin flash:/admin.cfg Total active Security Contexts: 1 Firewall# To configure a new context, follow these steps:
Context Definition ExampleConsider a physical firewall that is configured with three separate contexts for the enterprise:
Figure 4-7 shows a network diagram of the multiple-context arrangement. Figure 4-7. Network Diagram of the Multiple-Context ExampleFor the purposes of this example, each context is defined and configured with only basic interface parameters. The idea is to become familiar with context creation and configuration and interface allocation. You perform the configuration steps by connecting to the physical firewall console to gain access to the system execution space. First, get a sampling of the physical interfaces that are available on the system execution space. These interfaces are available to be mapped into user contexts. The following command and output are used: Firewall# show running-config : Saved : ASA Version 7.0(1) <system> ! interface GigabitEthernet0/0 description Public interface ! interface GigabitEthernet0/1 description Trunk for private context interfaces ! interface GigabitEthernet0/1.2 vlan 2 ! interface GigabitEthernet0/1.3 vlan 3 ! interface GigabitEthernet0/1.4 vlan 4 [output omitted] Next, the admin context is used for firewall management, so it must be defined in the system execution space configuration. The admin startup configuration is stored in Flash as the file admin.cfg. Two firewall interfaces are allocated to the context. Because it is the admin context, the interface names cannot be mapped to other arbitrary names. Use the following commands to configure the admin context: Firewall# configure terminal Firewall(config)# context admin Firewall(config-ctx)# config-url flash:/admin.cfg Cryptochecksum(unchanged): 352c788c 39cd2793 66c6ef98 c6bc632e INFO: Context admin was created with URL flash:/admin.cfg INFO: Admin context will take some time to come up .... please wait. Firewall(config-ctx)# Firewall(config-ctx)# allocate-interface GigabitEthernet0/0 Firewall(config-ctx)# allocate-interface GigabitEthernet0/1.2 Firewall(config-ctx)# exit Firewall(config-ctx)# admin-context admin Firewall(config)# Now you can define a user context called DepartmentA. This is also done from the system execution space. Two firewall interfaces are allocated to the context, and the names are mapped to the generic values intf0 and intf1. For the present time, the context startup configuration is stored as a file named DepartmentA.cfg in Flash memory. You can manage this file from the system execution space only, but context users can read or write to it using the startup-config command keyword. Later, the context users can arrange to store the file on an external server. When that happens, the following config-url command needs to be updated: Firewall(config)# context DepartmentA Firewall(config-ctx)# config-url flash:/DepartmentA.cfg WARNING: Could not fetch the URL flash:/DepartmentA.cfg INFO: Creating context with default config Firewall(config-ctx)# description Virtual Firewall for Department A Firewall(config-ctx)# allocate-interface GigabitEthernet0/0 intf0 Firewall(config-ctx)# allocate-interface GigabitEthernet0/1.3 intf1 Firewall(config-ctx)# exit Define the user context DepartmentB with the following commands on the system execution space. This context is structured similarly to the DepartmentA context. The startup configuration also is stored on the firewall Flash until it is moved later. Firewall(config)# context DepartmentB Firewall(config-ctx)# description Virtual firewall for Department B Firewall(config-ctx)# config-url flash:/DepartmentB.cfg WARNING: Could not fetch the URL flash:/DepartmentB.cfg INFO: Creating context with default config Firewall(config-ctx)# allocate-interface GigabitEthernet0/0 intf0 Firewall(config-ctx)# allocate-interface GigabitEthernet0/1.4 intf1 Firewall(config-ctx)# exit Firewall(config)# exit Firewall# After all the contexts are defined, don't forget to save the system execution space configuration to Flash memory using the following command: Firewall# copy running-config startup-config At this point, the firewall Flash memory contains the startup configuration files for every user context. (The system execution space startup configuration file is always stored in a hidden Flash file system.) The firewall Flash memory looks something like this: Firewall# dir flash:/ Directory of flash:/ 3 -rw- 4958208 06:41:52 Nov 30 2004 image.bin 4 -rw- 8596996 10:12:38 Nov 12 2004 asdm.bin 10 -rw- 1591 16:45:18 Dec 03 2004 old_running.cfg 12 -rw- 1853 09:47:02 Dec 30 2004 admin.cfg 14 -rw- 2119 14:16:56 Dec 07 2004 CustomerA.cfg 16 -rw- 2002 14:19:44 Dec 07 2004 CustomerB.cfg 16128000 bytes total (2565231 bytes free) Firewall# NOTE Notice that the system execution space contains an Adaptive Security Device Manager (ASDM) image file (asdm.bin). Users in other contexts cannot directly access the Flash file system, so those contexts can't use the image file. However, users in each context can run ASDM sessions to manage the context. The firewall coordinates all this from the system execution space from a single ASDM image. As expected, context users can see and manage only their own context. Now, each user context can be configured as an independent firewall. Each one starts with an empty configuration, except for the mapped interface definitions, so the initial session must be opened from the system execution space. As soon as a context is configured with enough information to have network connectivity, users can connect through any other means (Telnet, SSH, ASDM, and so on). First, change the session to the admin context and have a look at the available interfaces. Notice that each one is present but has no usable configuration. Firewall# changeto context admin Firewall/admin# show running-config : PIX Version 7.0(1) <context> names ! interface GigabitEthernet0/0 no nameif no security-level no ip address ! interface GigabitEthernet0/1.2 no nameif no security-level no ip address [output omitted] At a minimum, name the inside and outside interfaces, and configure them with IP addresses and security levels. You can do this with the following configuration commands (described in more detail in Chapter 3, "Building Connectivity"): Firewall/admin# configure terminal Firewall/admin(config)# interface GigabitEthernet0/0 Firewall/admin(config-if)# nameif outside Firewall/admin(config-if)# security-level 0 Firewall/admin(config-if)# ip address 192.168.1.10 255.255.255.0 Firewall/admin(config-if)# no shutdown Firewall/admin(config)# interface GigabitEthernet0/1.2 Firewall/admin(config-if)# nameif inside Firewall/admin(config-if)# security-level 100 Firewall/admin(config-if)# ip address 192.168.2.1 255.255.255.0 Firewall/admin(config-if)# no shutdown You can configure the DepartmentA and DepartmentB user contexts in a similar manner. Use the changeto context DepartmentA and changeto context DepartmentB commands to move the session to each context. In this example, firewall interfaces are allocated to the user contexts with the mapped names intf0 and intf1. After you connect to a user context session, the only clue you have about a mapped interface is its generic or mapped name. After all, the idea behind mapping interfaces is to present context users with arbitrary interface names that don't represent physical hardware. Therefore, you might have to return to the system execution space configuration to remember which physical firewall interface is mapped to which context interface and which context interface should be configured as inside and outside. To continue the example, the DepartmentA user context is configured next. Notice the initial interface definitions: Firewall/admin# changeto context DepartmentA Firewall/DepartmentA# show running-config : Saved : PIX Version 7.0(1) <context> names ! interface intf0 no nameif no security-level no ip address ! interface intf1 no nameif no security-level no ip address [output omitted] Now you can configure the context interfaces with the following commands: Firewall/DepartmentA# configure terminal Firewall/DepartmentA(config)# interface intf0 Firewall/DepartmentA(config-if)# nameif outside Firewall/DepartmentA(config-if)# security-level 0 Firewall/DepartmentA(config-if)# ip address 192.168.1.11 255.255.255.0 Firewall/DepartmentA(config-if)# no shutdown Firewall/DepartmentA(config)# interface intf1 Firewall/DepartmentA(config-if)# nameif inside Firewall/DepartmentA(config-if)# security-level 100 Firewall/DepartmentA(config-if)# ip address 192.168.3.1 255.255.255.0 Firewall/DepartmentA(config-if)# no shutdown TIP After you move your session to a different user context, it might be tempting to use the exit command to return to the previously visited context or the system execution space. Entering exit only terminates your session with the current context, requiring you to authenticate with it again so that you can use the changeto command. Think of each context as having its own virtual console connection. By using the changeto command, you move the console connection from one context to another. Allocating Firewall Resources to ContextsWhen a firewall platform is running in single-context security mode, you can configure and use only one operational firewall. Therefore, that firewall can use any or all of the available traffic inspection and session resources on that hardware platform. In other words, if the firewall uses most of its own resources while it does its job, its own performance isn't affected. In multiple-context security mode, however, all the configured contexts must share the available resources on their physical firewall platform. If one context becomes heavily loaded or highly utilized, it can use a majority of the traffic inspection resources. This can affect the other contexts by leaving them starved for the same resources. Multiple-context mode can support resource allocation by imposing limits on how specific resources are used. You can configure resource limits in classes according to the resource type and assign memberships in the classes to contexts. Resource allocation has the following characteristics:
You can use the following steps to define and apply classes of resource limits to security contexts:
Verifying Multiple-Context OperationTo see the current admin context name and configuration URL, you can use the show admin-context command, as in the following example from a PIX 7.0 platform: Firewall# show admin-context Admin: admin flash:/admin.cfg Firewall# To see information about the configured contexts, you can use the following command: Firewall# show context [[detail] [name] | count] You can specify a context name to see information about only that context. Otherwise, all the contexts are shown. Include the detail keyword to see a breakdown of each context resource, including the configuration URL and interface mappings. The following example shows the output from a firewall running PIX 7.0 that has three configured contexts: admin, CustomerA, and CustomerB. Firewall# show context Context Name Interfaces URL *admin GigabitEthernet0 flash:/admin.cfg GigabitEthernet1.1 CustomerA GigabitEthernet0, tftp://172.30.1.10/customerA.cfg GigabitEthernet1.3 CustomerB GigabitEthernet1.2,3 tftp://172.16.0.20/customerB.cfg Total active Security Contexts: 3 Firewall# On an FWSM platform, the same command produces slightly different output: Firewall# show context Context Name Class Interfaces URL *admin silver Vlan10,100 disk:/admin.cfg CustomerA silver Vlan20,100 tftp://172.30.1.10/customerA.cfg CustomerB default Vlan30,100 tftp://172.16.0.20/customerB.cfg You can add the detail keyword to see a breakdown of the context configuration. The following example shows the detailed configuration for a context named CustomerA: Firewall# show context detail CustomerA Context "CustomerA", has been created Desc: Virtual firewall for CustomerA's headquarters location Config URL: tftp://172.30.1.10/customerA.cfg Real Interfaces: GigabitEthernet0, GigabitEthernet1.3 Mapped Interfaces: intf0, intf1 Flags: 0x00000011, ID: 2 Failover group: 1 Firewall# Finally, although the firewall can't limit CPU load as a resource that is shared across contexts, the firewall does keep CPU load statistics. You can see a breakdown of the CPU usage as it is distributed across all the configured contexts. Use the following command from the system execution space: Firewall# show cpu usage context {name | all} The following example shows CPU usage on a firewall configured with three contexts: Firewall# show cpu usage context all 5 sec 1 min 5 min Context Name 7.1% 8.0% 7.1% system 12.0% 12.0% 10.0% admin 27.7% 28.5% 27.0% CustomerA 4.0% 4.0% 4.0% CustomerB Firewall# |
|