Cisco ASA

Cisco ASA

Cisco ASA port forwarding explained

One of the most frequent issues connected with the Cisco ASA configuration is the so-called “port forwarding”. In other words, the NAT configuration that allows users from the Internet to enter the internal company servers.

Basic NAT settings for the users’ access and internal resources on the Internet are described in the article "Basic configuration of Cisco ASA", and the principle of using the NAT technology for one or another case -  in "Using NAT on Cisco router". While this article, in particular, covers the configuration for the publication of the internal resources on the Internet.

  For successful implementation, there are two steps required:

The Static NAT configuration for needed addresses and ports;
Permitted rules in the access-lists.

 

In modern versions of Cisco ASA, there are two ways of Static NAT configuration - 1) through the objects (object NAT) and 2) manual/twice NAT. Those ways differ by the configuration logic and command syntax, but both lead to the same result. In first one - strings that describe the rules of translating the addresses are bound to a specific object. While the second one - in the separate line with the help of the same objects, the addresses both of original packet and transformed one are specified. Later there will be shown the settings for both ways, and you should decide for yourself which of them is the best for you. And if the port forwarding doesn't work by one of the ways, then try another one.

Important!
If you have old hardware and an IOS version up to 8.3, then an example of writing a string for the old syntax is given at the very end of the article.

Object NAT
The object creation for the external address
object network OBJ_NAT_SERVER_XXX_EXT
host x.x.x.x

For each port, the separate object with internal server address is being created
object network OBJ_NAT_SERVER_XXX _INT_1433
host 192.168.1.100
object network OBJ_NAT_SERVER_XXX _INT_1433
nat (inside,outside) static OBJ_NAT_SERVER_XXX_EXT service tcp 1433 1433

Here and further the parts of code responsible for internal resources will be marked in green, and the external ones - in red.
The second object for the same server 192.168.1.100, but with another name

object network OBJ_NAT_SERVER_XXX_INT_8080
host 192.168.1.100
object network OBJ_NAT_SERVER_XXX_INT_8080
nat (inside,outside) static OBJ_NAT_SERVER_XXX_EXT service tcp 8080 8080

Important!
Depending on how many external public addresses ISP provides, you should adjust the command syntax.

If the ISP provides only one(!) static address and it is the address of the external interface of the router, then in command for NAT it is necessary to specify “interface” (implying external outside interface).

If the ISP responded with several(!) static addresses and it is needed to use one of them not on the external interface, then you need to create a separate object and specify the certain address for it.

In case only one address is available, the command from the last example will look like this:
object network OBJ_NAT_SERVER_XXX _INT_1433
nat (inside, outside) static interface service tcp 1433 1433
Manual/Twice NAT
 The creation of the object for the external interface
object network OBJ_NAT_SERVER_XXX_EXT
host x.x.x.x

The creation of the object for the internal interface
object network OBJ_NAT_SERVER_XXX _INT
host 192.168.1.100

Now we should create the objects for ports and protocols, that should be visible from the outside network
object service SERVICE_TCP_1433
service tcp source eq 1433
object service SERVICE_TCP_8080
service tcp source eq 8080

The rule of broadcasting for each port/protocol is written in a separate line
nat (inside,outside) source static OBJ_NAT_SERVER_XXX_INT
OBJ_NAT_SERVER_XXX_EXT service SERVICE_TCP_1433 SERVICE_TCP_1433
nat (inside,outside) source static OBJ_NAT_SERVER_XXX_INT
OBJ_NAT_SERVER_XXX_EXT service SERVICE_TCP_8080 SERVICE_TCP_8080

As it was mentioned earlier, if only one private address is available, and it is already used in the interface, then, instead of the object with external address, the word “interface” should be used.
nat (inside,outside) source static OBJ_NAT_SERVER_XXX_INT
interface service SERVICE_TCP_1433 SERVICE_TCP_1433

Check the configuration
To check the current configuration, use the command sh nat detail. It will show all the current rules of broadcast, in which both external and internal addresses will be specified for each line.
Command syntax for old hardware (Cisco version up to 8.3)
The NAT rules are written line by line - one line for each port. Pay attention that at the beginning of the line in the brackets the sequence of the internal/external interfaces is specified, while further it is needed to define the addresses backwards - external/internal. The command will look like:

If it is necessary to use the address, not in the external interface:
static (inside,outside) tcp x.x.x.x 1433 192.168.1.100 1433 netmask
255.255.255.255
or
If it is needed to use the address of the external interface of the device, use the following command:
static (inside,outside) tcp interface 1433 192.168.1.100 1433 netmask
255.255.255.255

The access permission
Additionally to the NAT configuration for object NAT or Manual NAT, you should set up a few rules in access lists in order to allow the traffic. For that, in the access list, that is connected to the external interface, you should add the corresponding lines. Pay attention, that in the rules of modern versions of Cisco ASA  access is permitted from any address (any) to the internal server address.
access-list ACL_OUTSIDE_IN line 1 extended permit tcp any
object OBJ_NAT_SERVER_XXX_INT eq 1433
access-list ACL_OUTSIDE_IN line 2 extended permit tcp any
object OBJ_NAT_SERVER_XXX_INT eq 8080

However, if you have old hardware, and version of ASA older than 8.3, then you should specify the external address in the access list.
access-list ACL_OUTSIDE_IN line 1 extended permit tcp any
object OBJ_NAT_SERVER_XXX_EXT eq 1433
access-list ACL_OUTSIDE_IN line 2 extended permit tcp any
object OBJ_NAT_SERVER_XXX_EXT eq 8080

Important!
For more details about the principles and subtleties of the creation and filling the access lists, read the article: Basic Configuration of Cisco ASA.

This article was written by Alexey Yurchenko
Back to Table of contents

Read more →
Cisco ASA

Failover on Cisco ASA

Before getting into the configuration details of Cisco ASA backup scheme (called failover), I would like to point out a few rules regarding the technology itself:

- Of the two Cisco ASA devices that have been combined into a cluster and configured to work in the failover mode, only one device will be active and forward traffic.
- In order to create a Cisco ASA failover cluster, you need to have two devices of the exact same model, for example Cisco ASA 5515X
- both devices need to have the same IOS image installed, for example 9.4(2)6
- failover WILL NOT work if your Cisco ASA is configured to connect to the ISP through PPPoE protocol

There are exceptions to these rules, but I am deliberately not mentioning them in this article, so that the possible problems with the configuration can be brought to a minimum.

When configuring failover, the order in which you enter the configuration commands, as well as the order in which you connect two Cisco ASA devices together, is more important than the configuration itself.

Step 0. Verification
Before you begin to connect and configure your Cisco ASA devices, make sure that the IOS versions on both ASA are identical and supports the failover mode. Use the "" command for that

If you have different versions of IOS installed, upgrade it on one of the devices.
Step 1. Choose the synchronization interface
Connect to your first Cisco ASA device, that we will call Cisco ASA #1. Choose one of its free interfaces so that it can be used for synchronizing with the Cisco ASA  #2 device. For clarity, add a description to the interface (STATE Failover Interface). You should remove all other configuration from the interface, if any has been entered. Activate the interface with the "no shutdown" command.

Step 2.
Activate the failover mode on Cisco ASA #1

STATE - the name of the interface
primary - indicates that this is the primary device. Should not be confused with the device's current role - active or standby. A device may be currently in standby mode for passing traffic, but will be the primary device in the cluster.
10.0.0.1 and 10.0.0.2 - these are the IP addresses for the synchronization interfaces on both Cisco ASA. You can enter any address pair that you want, but make sure that they are from the same network and are unique to your LAN.

At this point of configuration, both Cisco ASA devices should NOT be connected to each other in any way. ONLY the device Cisco ASA #1 should be powered on. The second device should be set aside, waiting for its turn to be configured.
Step 3. Preparing Cisco ASA #2
Before configuring the second Cisco ASA, erase all configuration on it and disconnect all patch cords.

Step 4. Configuring Cisco ASA #2
Activate the failover mode on Cisco ASA #2. The synchronization interface and failover configuration commands will be identical to the ones entered on Cisco ASA #1, with the exception of the device sequence. Here you should specify "secondary".

Save the configuration and turn off the device completely.

Step 5. Connecting devices
At this moment, you should have the following:
Cisco ASA #1 is turned on and configured for failover
Cisco ASA #2 is turned off and configured for failover

Connect the synchronization interfaces (Gi0/3 or the ones you have chosen in Step 1) on both devices to each other and turn on Cisco ASA #2. When it boots, you should see an informational message on the console stating that it has found a mate for synchronizing configuration:

Cisco ASA #2 will the copy the entire configuration of Cisco ASA #1 into its memory.
From this moment on you need to make all any any configuration changes only(!) on Cisco ASA #1.
Step 6. Checking the failover operation
Besides initial synchronization interface configuration and connection you need to connect all other interfaces on both devices in an identical fashion. In the most general case this will be a LAN interface (inside) and WAN interface that connects to your ISP or dedicated line (outside). You need to connect the internal and external interfaces on Cisco ASA #2 in the same exact way that you did on the first device.
In order to check the current failover state, use the "sh failover" command. It will output the device role for the device that you are currently consoled into, the IOS version on both Cisco ASA devices and the operational state of all interfaces.

Note the state of the Secondary device. In our example it is Standby Ready. This means that everything works as it should.
If the state is shown as "Other host: Secondary - Failed", then your failover is not working. Check that the Cisco ASA #2 device is powered on, that all its interfaces are connected in the same manner as Cisco ASA #1 and whether you have identical IOS versions on your devices.

The failover algorithm
1) When powered on, a Cisco ASA device checks if there are cluster neighbors available, and if it finds one, it enters the Standby role and copies the entire running configuration from the Active device. After this it becomes the standby devices and waits.

2) If the just powered Cisco ASA device does not find a cluster neighbor, it will enter the Active state and work as a standalone device.

3) If everything is configured correctly and the devices states are Active/Standby, then the roles will switch upon following events:

- you manually switch the role from the console of the active device through issuing the command "no failover active". This forces the devices to switch their Active and Standby roles and the traffic starts flowing through the neighbor device.
- automatic failover occurs if the Active device experiences a failure of at least one interface. If the same interface on the Standby device was already inactive, the failover will not happen.

If one of the interfaces on the Active unit (Cisco ASA ) has experienced a failure and the devices have switched their roles, with #1 becoming the Standby unit, and then the failed interface is restored, there will be to the original state. The Secondary device will remain in the Active state up until it experiences a failure itself or you manually switch the roles (see "no failover active" above). You do not have to do anything about this.

Primary and Secondary - are the index numbers of the devices. They have no specific impact on your network.
Active and Standby - are the device's roles. They define which device is currently being used to pass traffic.

A common question that comes up with failover usage is: how do you connect the external ISP link into both firewalls at the same time? How do you make two cables from one?
The answer is rather simple - use a switch. Take a LAN switch that you are already using and connect Cisco ASA #2 to ports that have the same VLAN configuration as those, to which Cisco ASA #1 is connected. Or use a separate device.
A simple 8-port switch for $10-$20 is sufficient. Connect the ISP cable into port 1 and use ports 2 and 3 to connect to both Cisco ASA devices. This option is the simplest, cheapest and easiest to implement. If your switch goes out of order, you can easily replace it with a similar one within 5 minutes. You need to have one such switch or a Vlan for every common interface on the ASA devices.
If your budget allows it, I would recommend getting a Cisco 2960 switch for reliability and configuring the needed number of VLANs for each pair Cisco ASA interfaces.

Do not forget to save your configuration on the devices with the "write" or "copy run start" command. Otherwise all your changes will be lost upon reload.

This article was written by Alexey Yurchenko
Back to Table of contents

Read more →
Cisco ASA

Cisco ASA recovery using ROMMON mode

Sadly enough, sometimes network equipment goes out of order. This, of course, happens when you're least expecting it. In most cases that I've come across throughout my work, this is what happens: Cisco ASA is unexpectedly powered down or reloaded (due to planned or unplanned power outage, thunderstorm or work with electric equipment), and after reload, the interfaces, VPN tunnels and other services don't come back up. We're not going to examine the situation in which the device cannot turn on entirely and all the LED indicators are dead - in that case, a replacement for the device is the only viable option. Let's focus on the situation when the Cisco ASA device is still operable, but does not perform a full load - i.e. the Cisco IOS operating system image can't load properly. In this case, there is still a chance to reanimate the device, at least until you get a new one for replacement.

The first thing we need to do is connect to the firewall through a console cable. If the firewall does not respond to any commands and produces no output on the console screen, then you've reached the worst-case scenario - you can thank the device for its long and fruitful service and put it on a shelf. However, if you are seeing some activity on the console screen, it's not that bad and you can try to understand what's going on. The firewall may have entered into the special ROMMON mode (under normal circumstances, this mode is activated by pressing the ESC key during boot-up) or is in a cyclic reload that happens as it tries to load the operating system image.

The special ROMMON mode looks something like this:
Use ? for help.
ROMMON #0>

Once you're in this mode, you should try to force the device to start by entering the system command "boot":
ROMMON #0> boot

Cisco ASA will try to load the operating system image that is located on the internal Flash memory. I can tell you right now that, in my years of practice, this has worked only once, when I got lucky and the device booted normally. Most of the times if the firewall does not load on its own, then it will not be able to load from the boot command under ROMMON mode.

In this case, let's remember how Cisco devices work:

The operating system is located on some kind of nonvolatile memory and is loaded into RAM once, upon device boot-up. After that, the operating system works until the next reload. Flash memory is the most commonly used nonvolatile memory for storing the Cisco IOS (most likely you're reading this article because it's what went out of order), but you always have the option to specify some external resource that stores the IOS you need to load - for example, a TFTP server.
The task of recovering your firewall will come down to:

installing a TFTP server on some workstation. Using a simple laptop will suffice.
placing the relevant Cisco IOS on the TFTP server
connecting one of the Cisco ASA interfaces directly to the workstation that has the TFTP server
specifying that workstation as the IOS source and booting up the firewall with that image

 

In order to install TFTP server software, you simply need to download the install package, start the software, and copy the IOS image into the folder indicated in the software's dialog box.
I suggest using the simple and free TFTPD. You can download it here.
The interface of the program is extremely straightforward and should not cause any difficulties.

Place the IOS file for your firewall into the C:\Program Files\Tftpd64 folder that is specified in the "Current Directory" field. It is strongly advised to use the same IOS that was on the device when it went out of order. Don't use a newer version until you are sure that your firewall works fine.

Important!
Note how the TFTP server software interface works: if the IP address of the laptop's NIC gets changed, the "Server interfaces" field will still hold the old information. Check this and reload the TFTP server program if the value in that field is incorrect. For our example, we will use the address 192.168.1.2
Next, we need to connect the laptop's LAN interface to the Ethernet 0/0 interface of the firewall with a straight-through patch cord.
Inside the firewall's console (ROMMON mode) enter the IP address (ADDRESS), port number (PORT), TFTP server address (SERVER) and the operating system image file (IMAGE) information.

Important!
When entering the commands in ROMMON mode, you have to enter them in full - no abbreviations or short versions are available.
rommon #1> ADDRESS=192.168.1.1
rommon #2> PORT=Ethernet0/0
rommon #3> SERVER=192.168.1.2
rommon #4> IMAGE=asa803-k8.bin
Important!
In this example the Cisco ASA firewall and the laptop with TFTP server software are directly connected to each other, so there is no need to specify the default gateway. However, if the corporate network is available, you can install the TFTP server on any network workstation and specify the default gateway (GATEWAY) and/or VLAN tag (VLAN) parameters in Cisco ASA's ROMMON:
rommon #5> GATEWAY=Х.Х.Х.Х
rommon #6> VLAN=Y

Enter the IP address for the default gateway of your network instead of X.X.X.X. Enter the VLAN tag for your VLAN instead of Y.
You can check the values that you entered using the "set" command:
rommon #7> set

The availability of the TFTP server is checked with the "ping server" command:
rommon #8> ping server

Once you've ensured that the workstation with TFTP server software and Cisco ASA firewall are connected and configured correctly, enter the command "tftp" to start the process of loading the IOS:
rommon #8> tftp

Even if your device loads successfully, I still suggest that you work on finding a , since its reliability is now questionable.
To emphasize one more time:  this article describes an emergency recovery of a Cisco ASA device and the success of the procedure depends on how badly the device's components are damaged. Everything laid out in this article will 100% work if the hardware is intact.

This article was written by Alexey Yurchenko
Back to Table of contents

Read more →
Cisco ASA

Configuring VPN on Cisco ASA

This material follows up on the topic covered in the Configuring VPN between two Cisco routers, but is being dedicated an entirely separate article, since it deals explicitly with configuring Cisco ASA devices.

The task will again consist of connecting a main and a branch office through VPN, but this time the main office works on a Cisco ASA 5510 firewall instead of a Cisco 2800 router.

At our disposal we have:
Cisco ASA 5510 firewall in the main office

Users are inside LAN 192.168.10.0 /24
External static IP address is 1.1.1.2 /30
ISP gateway is 1.1.1.1 /30

Router Cisco 881 at the branch office

Users are inside LAN 192.168.20.0 /24
External static IP address is 2.2.2.2 /30
ISP gateway 2.2.2.1 /30

The process of configuring the Cisco 881 router has been described in the "second universal method" section for configuring VPN tunnels in the article  Configuring VPN between two Cisco routers, so here we will focus only on configuring the Cisco ASA firewall. The firewall is already configured with the basic settings outlined in Cisco ASA. The Basics. Internet access article:  it is accessible for remote administration and the office LAN can reach the Internet.
Step 0
If your ASA IOS version is older than 8.3 (you can check the current version with the "sh ver" command), then turn off nat-control option for the ease of configuration:

FW-DELTACONFIG-1(config)#
no nat-control
Step 1. Interface configuration check
First, let's check that our firewall has correctly configured outside and inside interfaces. Since we are working on Cisco ASA 5510 model (as opposed to 5505), this configuration is slightly different than the one mentioned in the initial article. The IP addresses and other parameters are assigned directly to the physical interfaces Ethernet0 and Ethenet1 instead of the virtual VLAN interface.

The outside interface:
FW-DELTACONFIG (config)#
interface Ethernet 0
nameif outside
security-level 0
ip address 1.1.1.2 255.255.255.252
no shut

The inside interface for the internal LAN:
FW-DELTACONFIG (config)#
interface Ethernet 1
nameif inside
security-level 100
ip address 192.168.10.1 255.255.255.0
no shut

Step 2. Define the encryption parameters
Here we configure the encryption parameters for the VPN tunnel between the main office and the branch location and turn on the VPN on the outside interface. These parameters are identical to the ones used on the Cisco 881 router at the remote site:
For IOS version less than 9.0

For IOS version greater than 9.0

Step 3. Define the "interesting traffic" that should be encrypted and sent into the tunnel
Create an access list named ACL_CRYPTO_DO, in which we define the traffic that needs to be encrypted into the VPN tunnel, this is called "interesting traffic" in Cisco. All other packets will not be routed into the VPN.

FW-DELTACONFIG-1(config)#
access-list ACL_CRYPTO_DO extended permit ip 192.168.10.0 255.255.255.0 192.168.20.0 255.255.255.0
Step 4. Create the encryption policy
Create the encryption policy, also known as a "crypto map", in which we will reference all the rules and encryption parameters that were created in steps 2 and 3:
For IOS version less than 9.0
FW-DELTACONFIG-1(config)#
crypto map SECMAP 1 match address ACL_CRYPTO_DO
crypto map SECMAP 1 set peer 2.2.2.2
crypto map SECMAP 1 set transform-set ESP-3DES-SHA
Apply the created policy to the outside interface:
FW-DELTACONFIG-1(config)#
crypto map SECMAP interface outside
Create the encryption key that is exchanged between peers:
FW-DELTACONFIG-1(config)#
tunnel-group 2.2.2.2 type ipsec-l2l
tunnel-group 2.2.2.2 ipsec-attributes
pre-shared-key XXXXX

Instead of XXXXX enter the key you wish to use for the VPN with the remote peer. It needs to be identical on both the Cisco ASA in the main office and the Cisco 881 at the branch office. I recommend making it complex, no less than 50 symbols, using digits, letters and special characters.

All the same but for IOS version greater than 9.0

Step 5. Routing
Directly define the route to the branch LAN network through the outside interface and the gateway, provided by the ISP (1.1.1.1) :
FW-DELTACONFIG-1(config)#
route outside 192.168.20.0 255.255.255.0 1.1.1.1
Step 6. Avoiding unneccessary translation (NO-NAT)
If the Cisco ASA is used for user access to the Internet (Dynamic NAT is configured to translate internal addresses to the outside), you need to prevent unneccessary translation of packets which should be routed to the private ip networks through the tunnel. In order to avoid this add these strings

For IOS version after 8.3
object-group network NET_PRIVATE_IP
network-object 10.0.0.0 255.0.0.0
network-object 172.16.0.0 255.240.0.0
network-object 192.168.0.0 255.255.0.0
nat (any,any) source static any any destination static NET_PRIVATE_IP NET_PRIVATE_IP no-proxy-arp description NO-NAT

For IOS version before 8.3
access-list NO-NAT extended permit ip any 10.0.0.0 255.0.0.0
access-list NO-NAT extended permit ip any 192.168.0.0 255.255.0.0
access-list NO-NAT extended permit ip any 172.16.0.0 255.240.0.0
nat (inside) 0 access-list NO-NAT

If this won't be done, the tunnel will be established, but packets will not be transmitted.
Step 7. Check the VPN tunnel
After we create the mirror configuration on the branch office's Cisco 881, next step is to check whether the VPN tunnel works by sending a ping from a workstation in the main office to a workstation at the branch office.

You can check the tunnel with the following commands:

Check the active VPN connections with the "show crypto isakmp sa" command

FW-DELTACONFIG-1# sh cry isa sa
Active SA: 1
Rekey SA: 0 (A tunnel will report 1 Active and 1 Rekey SA during rekey)
Total IKE SA: 1
1   IKE Peer: 2.2.2.2
Type    : L2L             Role    : responder
Rekey   : no              State   : MM_ACTIVE

Any state except (!) MM_ACTIVE means that the VPN is not working. If it is taking more than one minute in order to establish the tunnel, you need to check all the configured encryption parameters and ensure that they are identical on both VPN peers.
If this command does not produce any output, then you are probably missing some part of configuration - for example, you did not aplpy the crypto map to the outside interface.

Important!
Please note that the VPN tunnel does not come up when there is no traffic to be encrypted between two devices.

The "show crypto ipsec sa" command give you the number of transmitted and received packets inside the VPN tunnel. This is the ultimate command for troubleshooting a connection. The information is available only (!) when the tunnel has been established - otherwise the output is empty.

FW-DELTACONFIG-1# sh cry ips sa
interface: outside
/... output cut .../
local ident (addr/mask/prot/port): (192.168.10.0/255.255.255.255/0/0)
remote ident (addr/mask/prot/port): (192.168.20.0/255.255.255.255/0/0)
current_peer: 2.2.2.2
    #pkts encaps: 4748, #pkts encrypt: 4748, #pkts digest: 4748
      #pkts decaps: 4432, #pkts decrypt: 4432, #pkts verify: 4432
#pkts compressed: 0, #pkts decompressed: 0
#pkts not compressed: 4748, #pkts comp failed: 0, #pkts decomp failed: 0
#pre-frag successes: 0, #pre-frag failures: 0, #fragments created: 0
#PMTUs sent: 0, #PMTUs rcvd: 0, #decapsulated frgs needing reassembly: 0
#send errors: 0, #recv errors: 0
/... output cut .../
The line containing "pkts encaps" shows how many packets were encrypted and sent in the direction of the remote office
The line containing "pkts decaps" shows how many packets were received and decrypted

The "clear crypto isakmp sa" command allows to reset all the current VPN tunnels and force them to re-initialize. The command "clear crypto ipsec sa peer 2.2.2.2" will reset the counters of all transmitted and received packets.

Important!
Don’t forget to save the changes you made to the configuration with the write or copy run start/ commands. Otherwise you will lose all changes after the next reload.
FW-DELTACONFIG-1#write
Building configuration...
[OK]

This article was written by Alexey Yurchenko
Back to Table of contents

Read more →
Cisco ASA

Basic configuration of Cisco ASA

Let’s look over an example of how to connect an office LAN to the Internet with using a Cisco ASA firewall. For this example, we will use the junior model of the lineup – Cisco ASA 5505. Its main distinction from the higher-end models is the 8-port integrated switch, that allows to have 8 switch ports on board(Layer 2 of OSI model) . These ports cannot have an IP address assigned to them, but if you want to create Layer 3 interfaces, you can configure a virtual interface (VLAN) and assign IP addresses there. Assigning a port to a VLAN will allow you to use an IP address for that port, just like assigning one to an interface of a router.

In this example we will use:

An Internet uplink with static IP address
Several hosts inside the office’s Local Area Network (LAN)
Cisco ASA 5505 firewall
Layer 2 switch (used only to connect the LAN hosts, without any additional configuration)

Our task: allow the internal LAN hosts to access the Internet through the firewall.

Step 0. Clear configuration
(Should be done only on new or test lab equipment, since it completely erases all existing configuration)

If your new device with factory settings is asking for a password to enter the privileged mode (#) enable, just hit "Enter".

Lets completely erase the startup configuration of the device. To do this, connect using a console cable to the console port of the device, enter the CLI and type:

After this confirm the deletion of all configuration files.

Unlike with Cisco routers, you don’t have to reload the device in order to erase its configuration. The command “clear configure all” executed on the firewall leaves only the service lines from factory configuration and you can immediately begin to configure your device afresh.
Step 1. Hostname
In order to give your device a hostname and make it easier and more convenient to administer later, use the command “hostname ”

Step 2. Interface configuration
At the very minimum, you need to configure two interfaces on your firewall: the outside and the inside.

The outside interface will communicate with the Internet. Configure it with the IP address and subnet mask provided by your ISP:

The internal interface, inside, should be configured for the LAN:

At this point you have to attach your virtual VLAN interfaces to real Ethernet ports.
Here is how you tie together the outside interface and port Ethernet0/0:

Important!
Notice that the line with “switchport access vlan 1” command will not be displayed in the running configuration output (the one shown with the “show run” command). The reason for this is that VLAN 1 is configured for each physical interface by default. When you configure any other VLAN tag, except the default one, you will see the line in the running configuration.

Configure your internal inside interface to use physical port Ethernet 0/1:

Step 3. Configure Remote Access
In order to configure remote access for administration of your device through SSH protocol, you need to do the following:
Create a password for privileged mode (#). Enter your desired password instead of “XXXXX”:

Create an administrator account. Enter your desired password instead of “YYYYY” for the user admin:

Specify the authentication method and generate the RSA keys:

Specify the IP address of the administrator workstation, from which to allow remote access via SSH and the interface for accepting remote access requests (inside). You can specify multiple IP addresses or entire networks to be designated as management.

After performing these steps you should be able to access the firewall through the SSH protocol from the workstation with IP 192.168.10.100.
Step 4. Configure the default gateway
In order to route packets to the Internet, your firewall needs to have the default gateway (the closest IP address on the ISP side) and the interface, through which it can be accessed (outside) configured.

After configuring the default route, you can check both the availability of your ISP and your access to the Internet. You can do this by pinging any address available in the Internet. For this example, we’ll take the IP address of the most-pinged resource – google DNS (8.8.8.8)

Important!
Please note that, at this stage, you can only send ICMP requests from the CLI of your Cisco ASA device. The workstations in your LAN will not have access to the Internet until after performing the next steps.
Step 5. Configure Network Address Translation (NAT)
NAT configuration commands differ depending on the device’s firmware version. Check what version you have by entering the “sh ver” command:

Step 5.1 NAT for access to the Internet (from inside to outside, PAT)
In order for the LAN hosts to have access to the Internet, their private (grey) IP addresses need to be translated into a public (white) IP address.
Configuration commands for version 8.2.x and older

Configuration commands for version 8.3.x and newer

Result:
After configuring PAT in this way, your LAN workstation IP addresses will be dynamically translated into the IP address of the outside interface.

Important!
You can also translate traffic into a specific IP address, not assigned to one of your interfaces (this works when your ISP allocated you a subnet larger than /30).

One option is translating into the outside interface IP address, like in the example above
Second option is translating into an IP address on the same subnet as the outside interface, but not the address of the interface itself

In all other cases the NAT translation will not work correctly, if it manages to work at all.
Step 5.2 NAT for access from the Internet to a resource in the internal network (static NAT)
If you need to organize access from the Internet to an address in your LAN, for example for a web server, then you have to configure static NAT translation.
Configuration commands for version 8.2.x and older

Important!
Pay attention to the order of the interfaces and addresses. Inside the parenthesis you have internal interface first, then the external. After that you list the external address first, then the internal. Vice versa!
Configuration commands for version 8.3.x and newer

Result:
This configuration will force all traffic sent to the outside IP address of the firewall to be redirected to the internal LAN address 192.168.10.200.

OR
Configuration commands for version 8.2.x and older

Configuration commands for version 8.3.x and newer

Result:
In this case only the traffic sent to the outside interface of your firewall for port TCP 80 (HTTP protocol) will be redirected to the internal LAN address 192.168.10.200.

Important!
Instead of using the keyword "interface", you can specify an actual IP address that is different from the IP address that is configured for the “outside” interface, but in this example this is not possible: the ISP has assigned us a subnet of only 4 addresses – 200.150.100.0 /30 – out of which we can use only two. 200.150.100.1 is configured on the ISP side as our default gateway, 200.150.100.2 is assigned to our outside interface. Therefore, this subnet does not allow for any other IP addresses.
Yet if we were provided a slightly larger address space, for example 200.150.100.0 with a subnet mask of /29, then we could have used 6 out of 8 IPs in the subnet, 200.150.100.1 – 200.150.100.6. Two addresses would be still taken up by the gateway and the interface, but 4 more are available for use. In this case, we could configure the NAT translation for the server on a different address in this subnet, for example 200.150.100.3..
Configuration commands for version 8.2.x and older

Configuration commands for version 8.3.x and newer

Important!
Please note that simply creating NAT rules does not provide access to the resources being configured. In order to have access to those resources, you need to also configure access lists and attach them to the relevant interfaces. By default, the firewall does not allow any traffic to pass between its interfaces, unless specifically allowed to do so by an access list – this is called implicit deny.

Read more about static NAT or Port forwarding in the article "Cisco ASA port forwarding explained"
Step 6. Configure access lists
So that this article does not get cluttered with a lot of theory on how access lists work, I will provide an example of configuration that is sufficient for most small offices. If there is a need to allow access to any other resources, you will have to add access list rules in a similar fashion.

Important!
It is possible to write all access list rules using only the numerical IP addresses, but for the ease of future administration it is considered best practice to first create named objects that describe the group of IP addresses that they contain. After that, all rules in access lists reference these named objects. This is the more practical and convenient way of configuration. Let’s start with an access list that allows access from the local LAN to the Internet. Here are the rules that we need to configure:
- Each user or device on the local LAN needs to have access to the Internet in order to browse the web sites
- Workstations that belong to the company’s director and IT administrator need to have unlimited Internet access
- Workstation of a certain manager needs to have special access to a certain resource using the port TCP 9443
First, we configure object groups:

NET_LAN – all local LAN users
USER_CEO – director’s workstation
USER_ADMIN – IT administrator’s workstation
USER_PRIVELEDGED – IP address of the manager that needs to have privileged access to resources
HOST_X - specific resource on the Internet that needs to be accessible by the manager’s workstation
USERS_FULL_ACCESS – named group, for which we will grant unlimited access to the Internet
SERVICE_HTTP_HTTPS –  group that lists the standard ports for web browsing
HOST_DNS – external DNS server address
SERVICE_DNS – group that lists the DNS service ports

Create an access list named ACL_INSIDE_IN that will describe all the rules:

Unlimited access for the group USERS_FULL_ACCESS to the Internet:

Special access for users in USER_PRIVELEDGED group to the resource listed in group HOST_X using the port TCP 9443:

Access to the Internet using ports TCP 80 (HTTP) and TCP 443 (HTTPS) for all LAN hosts:

Access to Google's DNS server for all hosts on the local LAN:

ICMP access from any host on the local LAN to any outside resource, allowing to send ping commands:

Explicit ban for all other connections. Using the keyword “log” at the end will allow us to view all attempts that were blocked by this access list in our system log.

The order of rules in an access list is extremely important! First, the firewall processes the topmost rule, then the one that is below it, and continues so until it gets a match on the addresses and ports in the packet or until it hits the end of the access list. If you put your deny rule in the middle, everything else below it will get ignored and the required access will not be granted.

After you have listed all the desired access rules, you need to assign the access list ACL_INSIDE_IN to the “inside” interface. Until you do so, the access list does not affect the traffic going through the firewall in any way. In order to assign it to an interface, use the following command:

On top of that, lets allow to automatically accept ICMP replies:

The access list controlling the outside interface will be smaller, since we only need to allow access to the web server inside our office. This rule will supplement the NAT rules, specifically the one that translates the internal private IP address of the web server into the public IP address assigned to the firewall’s “outside” interface.

Configure the access list names ACL_OUTSIDE_IN and assign it to the external “outside” interface in a similar way that we did for the internal interface above:

Don’t forget about static NAT:
Configuration commands for version 8.2.x and older

Configuration commands for version 8.3.x and newer

Now our configuration has both the static NAT rules and the access list rules that allow the traffic. Consequently, any host out in the Internet trying to connect to the IP address configured on the “outside” interface of our firewall (200.150.100.2) and TCP port 80 (HTTP protocol) will be allowed access and translated into a request to connect to the internal IP address of the web server (192.168.10.200).

All the functions and configs above are typically present in every Cisco ASA firewall setup in every office. I hope this simple article will help you with your tasks. Don’t hesitate to write me if you have any questions.
Important!
Don’t forget to save the changes you made to the configuration with the write or copy run start/ commands. Otherwise you will lose all changes after the next reload.
FW-DELTACONFIG-1#write
Building configuration...
[OK]

This video could help you better understand basic configuration of Cisco ASA.
https://youtu.be/NyyeI8Mh_fA

This article was written by Alexey Yurchenko
Back to Table of contents

Read more →
Cisco ASA

Dual WAN on Cisco ASA

This article describes how to configure Dual WAN connection on Cisco ASA. If you need to configure the same on any Cisco router like Cisco 881 then read the article "IP SLA on Cisco router"

Sooner or later, every network administrator encounters a channel going down, whether it is an ISP uplink to the Internet or a WAN circuit to some other resources. Most of the time this serves as that “a-ha” moment that forces us to think about creating some kind of a backup mechanism (too bad that we didn’t think about such things in advance!). Yet, if there are two ISPs available, you have the opportunity to configure a redundant connection scheme that will help you avoid downtime.

Ideally, you would place a router, connect two ISPs to it, reserve an autonomous system with public IP addresses and configure a fully redundant connection scheme with BGP protocol (Cisco ASA series support BGP only on 5500X models and with the latest versions of IOS). However, this approach suits only large companies with enough resources, capacity, and trained personnel.

In most cases configuring a backup ISP to be used in case of main channel failure is the most adequate solution. Cisco ASA devices have the capability to monitor the availability of the primary ISP channel and switching over to the configured backup in case of its failure (when the gateway fails to respond to ICMP requests over several seconds).

Let’s see how we can configure this.

Let us look at the following example:  we have a Cisco ASA 5505, which connects our office to the Internet through ISP 1 via the Ethernet 0/1 interface. You can read the detailed setup in the “Cisco ASA Basics. Connecting to the Internet” article. We have connected an additional service provider, ISP 2, to the interface Ethernet 0/2 (see the diagram).

Our task:  configure a fault-tolerant Internet connection scheme (dual WAN)
Step 1. Check the routes
First, let us check the current configured routes on the device. The easiest way to do so will be the “sh run | inc route” command, which will output the running configuration lines that contain the word “route”:

If we translate this into normal language, we will get the following:
“Redirect all packets, which I don’t know, into the “outside” interface through the gateway 1.1.1.1”
Cisco ASA “knows” only those networks that are directly connected to its interfaces or that are entered as routes in its running configuration.

Step 2. Configure interfaces for the use of secondary ISP
Our firewall already has an interface name “outside” (Ethernet 0/1, VLAN 2) that connects to the primary ISP. The running configuration (available through the “sh run” command) has the following lines:

Let’s add the configuration for the backup ISP that is connected to interface Ethernet 0/2, VLAN 3:

If all cables are properly connected and the configuration is correct, then you shall be able to reach the gateway of the backup ISP:

Step 3. Configure monitoring of the ISP’s availability
In order for the firewall Cisco ASA to monitor the availability of the primary channel, we need to configure the “ip sla monitor” function. It allows to send a ping request (an ICMP echo request) to the ISP 1’s gateway address at configured time intervals. Receiving a response (ICMP echo reply) will mean that the channel is available.

Additional information:
timeout 3000 – is the timeframe within which Cisco ASA will await for an ICMP response. 3000 => 3 seconds
frequency 5 – how often to send the requests. Here is every 5 seconds
threshold 10000 – a delay for the operation of 10 seconds, during which no actions are taken
Step 4.  Configure the default gateway for the backup ISP
Just like with the primary ISP, the backup ISP needs to have its default gateway configured on the Cisco ASA, so that the firewall will send all the unknown packets in its direction. The only difference is that this gateway should only be used in case the primary ISP is unavailable and not clog the routing table in all other cases. To achieve this, we need to change the administrative distance of the route – make it bigger, thus lowering the priority of this route. By default, all static routes have an administrative distance of 1. We will configure an administrative distance of 250 for our backup channel, bringing it closer to the highest possible value.

After we add this configuration, our default routes should look like this:

Step 5.  Activate the backup mechanism
The final step for configuring a backup channel on a Cisco ASA is to turn on the monitoring function (ip sla) for the primary ISP.
To achieve this, we add a new line of configuration for the default route, using the track 1 remark and remove the old configuration:

Now we have the following configuration for the default routes:

Important!
You should take into consideration any other configured static routes on your device.

Important!
You also have to configure the access lists and NAT rules to use the backup ISP. Add identical rules and apply them to the outside_backup interface.
Checking the IP SLA monitoring function state
In order to see the state of the IP SLA working on your device, use the show sla monitor operational-state command:

The output of this command gives all information and statistics of the IP SLA function. This will be very useful if you need to troubleshoot the setup and operation.
Important!
Don’t forget to save the changes you made to the configuration with the write or copy run start commands. Otherwise you will lose all changes after the next reload.

This article was written by Alexey Yurchenko
Back to Table of contents

Read more →
Cisco ASA

Few words about capturing packets on Cisco ASA

Cisco ASA firewalls have a useful tool for capturing and analyzing the traffic that crosses the firewall, called capture. Sometimes this is also referred to as 'traffic dump' or 'traffic sniffer'.
You only need to set two parameters to start capturing:

indicate the traffic to capture
indicate an interface on which you want to apply the capture

Step 1. Setting up target traffic
Target packets should be defined with a simple access list. For example, we are interested in capturing traffic from host 192.168.10.100. Create an access list with the following two lines, where the host address serves both as a source and a destination.

You may change 'any' in the lines above to a more specific host address or even a network, or change 'ip' to a specific protocol. For instance, to capture TCP traffic between hosts 192.168.10.100 and 1.1.1.1, use commands like these

Attention!
There are no limitations to that access list: it does not filter any traffic, and you may add as many lines as you need. However, the more diverse packets you capture, the harder it is to analyze the results. In the field, you often capture IP traffic (which includes all connections) between two specific hosts.

Step 2. Setting up interface and other parameters
After you identify the traffic to be captured, enable capturing on the interface that is (important!) the closest one to the source. If any traffic specified in the access list passes through this interface, it will be captured and written into a buffer, even if a deny rule is active and traffic will not pass beyond the firewall.
Capture syntax is:

Suppose a Cisco ASA firewall has 2 interfaces:

dmz is located in network 10.0.0.0 /24, its address is 10.0.0.1
inside is located in network 192.168.10.0/24, its address is 192.168.10.1

For example, we investigate the case when host 192.168.10.100 cannot reach a web server with ip address 10.0.0.20. To understand the reason behind this, create a relevant access list and enable capture on the inside interface.

Here, capmy is an arbitrary name identifier for a capture, ACL_CAP is an access list specifying the target traffic, inside is an interface on which capture is applied.
After we enabled capture, send an ICMP query (ping) from host 192.168.10.100 to web server 10.0.0.20 and wait until the query is completed. The capture file should now have new lines describing the target traffic.
Step 3. Examining the result
You can look through all enabled captures with sh capture.

You can examine the captured packets with show capture name-of-capture

This output indicates that both ICMP requests from 192.168.10.100 to 10.0.0.20 and ICMP replies from 10.0.0.20 to 192.168.10.100 are able to cross the firewall interface.
Next, from the command prompt at 192.168.10.100 run telnet 10.0.0.20 80 to check if port 80 is reachable by TCP (it's a web server, after all).

Examining the captured traffic

Three new lines (numbered 9, 10 and 11) are added to the output. Note that traffic is only crossing from 192.168.10.100.62990 to 10.0.0.20.80; no reply packets appear.
Step 4. Analyzing the data
So, ping is working in both directions, but a TCP connection using port 80 (www) cannot be established, since no reply packets are sent. However, the hosts are interconnected (all devices are functional and routing is working fine). We have yet only captured the traffic from one Cisco ASA interface (inside), and we don't know why the connection cannot be established.
Let's set up a second capture on dmz interface, which is closer to the destination, to give a complete picture.
Using the same access list, provide another capture name and another interface.

Again, send some traffic from host 192.168.10.100 to port 80 and compare the capture results

The same packets appear on the dmz interface, which is the closest one to the destination address 10.0.0.20. This means that traffic is successfully crossing the firewall, and the issue is at the server which is not responding. It might be that the www service is disabled or a server firewall is active.
Step 5. Clearing the results
You might have noticed that the first capture (the one at the inside interface) lists information on 14 packets, while the second one, which has been enabled later, only lists 3 last packets. To reset the counters and clear the capture results, use clear capture name-of-capture.

Step 6. Saving a capture file
Apart from looking at the capture logs, you might need to analyze them in greater detail by a third-party software like Wireshark or other packet analyzers.
There are many different options to get the file (through ftp, usb, etc.), but the one that is tried and true is a TFTP server. For this:

set up and launch a TFTP server at any workstation. I recommend using tftpd64, which is simple and user-friendly. For the sake of clarity, we install it at the very same host 192.168.10.100 we used in our examples.
send some traffic from host 192.168.10.100 to host 10.0.0.20 in order to get some output in both captures: capmy and capmy_dmz. Recall that we've cleared their output at step 5.
check that the packets are captured and written into buffer with sh cap name-of-capture
upload the file to a TFTP server with copy /pcap capture: tftp:

You'll have to enter the source capture name, the address of the TFTP server, and the destination filename to save the capture file.

You may now open the file in Wireshark traffic analyzer or send it to a third party for analysis.
Step 7. Setting up advanced options
A capture file by default takes up 512 KBytes in Cisco ASA RAM. If you are capturing more than a couple packets (say, your company daily traffic), the buffer overflows quite soon. You have two options to solve this problem:

you may set up a non-default buffer size. Add option buffer size to the capture command. A value of 1 000 000 will allocate 1 MByte of memory.

Attention!
Be very wary of your actions, as the device RAM is being allocated. It is strongly recommended not to allocate more than 10 MBytes. After you analyze the traffic, delete the old captures with no cap name-of-capture.

If you only need a glimpse on the traffic and not going to analyze it in Wireshark and its likes, you can only capture the packet headers. They contain the information on IP addresses, protocols and ports -- exactly what sh cap name-of-capture displays. In this case, a standard 512 KBytes buffer will have space for much more traffic. Enable this mode by adding headers-only to the capture command.

You may also make use of circular-buffer parameter, which allows to overwrite the buffer continuously.
You may combine all these parameters in one call.

This article is only giving an overview of capture feature and does not include the subtleties of analysis.

This article was written by Alexey Yurchenko
Back to Table of contents

Read more →