As A Command Line Technical Guide
As A Command Line Technical Guide
As A Command Line Technical Guide
discussions, stats, and author profiles for this publication at: https://www.researchgate.net/publication/303518237
CITATIONS READS
0 1,473
1 author:
Motasem Hamdan
American University of Science and Technology
14 PUBLICATIONS 0 CITATIONS
SEE PROFILE
Some of the authors of this publication are also working on these related projects:
Blocking peer to peer traffic on Cisco ASA Firewall and other Intrusion prevention systems View project
All content following this page was uploaded by Motasem Hamdan on 25 May 2016.
1
Abstract
This guide is intended to streamline the most used commands by network security engineers when
managing Cisco ASA firewall. It covers the very basic common commands to manage, administer,
secure, and providing connectivity operations to devices connected to Cisco ASA firewall. This guide is
neither comprehensive nor reference document for commands in Cisco ASA and the main reference for
command line syntaxes is refered at the end of this document. This paper is handy for network security
engineers to manage command line for most common aspects in cisco ASA while other operations such
as Virtual firewalls and VPN remote access could be done seamlessly using ASDM. This guide assumes
you have the required knowledge of CCNA, CCNA Security, CCNP and could be handy if you’re already
enrolled in CCNP Security pathway.
2
Basic IP Connectivity and routing protocols
Configuring trunk link and sub-interfaces between ASA and Switch
On the outside physical interface of switch1:
Interface f0/10
Switchport mode trunk
No shutdown
On the inside interface of ASA firewall:
Interface f0/3
Switchport mode trunk
Switchport trunk allowed vlan 20,10
No shutdown
Interface f0/3.1
Vlan 20 [ or use encapsulation command]
No shutdown
Interface f0/3.2
Vlan 10 [ or use encapsulation command]
No shutdown
Note: the command used to create trunk link between two networking devices should be used once
between router and switch and must be used twice between firewall and switch on each opposite
interface
3
Security-level [level:0-100]
When configuring interfaces with same security level, a command must be explicitly configured to
allow traffic between them
Same-security-traffic permit inter-interface
Configuring and changing MTU size for each interface to carry larger packets
Mtu if_name bytes
The ASA does not forward DHCP requests by default so it needs to be configured to use
dhcp relay agent
Dhcprelay server ip-address interface
Dhcprelay enable interface
Note that in the first command, the refered interface is the one connected to the DHCP Server or
gateway while the second interface in the second command is the one facing the clients
4
Access-list [Access-list name ] standard [ permi tor deny ] [ network ip ] [ subnet mask ]
Router rip
Version 2
No auto-summary
Default-information orginiate [ to advertise static routes ]
Network [ the IP of the intended network to be advertised ]
Distribute-list [Access-list name used above ] [ in or out ]] interface [ inside or outside]
Exit
İnterface eth0/2
Rip authentication mode md5
Rip authentication key [ your key ] key_id [id]
Redistribute routes that are learned through RIPv2, Static routes or Directly connected
routes
Redistribute [ rip | static | connected ] [metric : bandwidth | delay | reliability | load | mtu ] [
route-map map_name]
5
Configure OSPF on ASA
Router ospf pid
Router-id ip_addr
Network ip_addr netmask area area_id
Area area_id authentication md5
İnterface interface
Ospf message-digest-key key_id md5 key
Ospf authentication –message-digest
Prefix-list list_name [permit | deny ] network_ip ge min_bit le max_bit
Area area_id filter-list prefix list_name [in | out ]
Configuring host name and domain name to create FQDN for the ASA:
Hostname hostname
Domain-name domain_name
Note 1: configuring the above parameters is optional but it’s compulsory to create and generate CA for
SSH, HTTPS and VPN connections
6
Ssh ip_addr subnet_mask
Ssh disconnect
Note 3: the ip address in the second command is the network address for allowed hosts to perform ssh
sessions or could be single ip used to manage ASA through SSH
Note 3.1: the last command used to terminate a designated SSH session
7
Note 6: The second and third command used to send syslog messages and debugging messages from
internal buffer memory into an ftp server
8
NAT and PAT procedures
Configuring Dynamic NAT
Nat inside 1 network_ip subnet_mask
Global outside 1 pool_translated_ip netmask netmask
Timeout xlate 1:00:00
A must – read note: Dynamic Nat is a type of nat where a pool of public ip addresses are
assigned to local host every time they initiate an outbound connection to the outside world but
for hosts in DMZ the connection back from the client will not happen because of the dynamic
ip address assignment.
Note 1: The first commands specify the inside interface and every local host connected to it
which will be subjected to Dynamic NAT
Note 1.1: The second command specifies the outside interface in which the translation will take
place along with the pool of the selected ip addresses and their netmask
Note 1.2: the third command specifies the lease time for each local host before a new assignment
of public ip addresses occur
Note 2: the first command specifies the DMZ interface to be subject to PAT along with the ip
addresses that exist in this space
Note 2.1: the second command specifies the inside interface with its local hosts ip addresses to
be subject to PAT along with the ports
9
Note 2.2: the third command specifies the outside interface in which PAT occurs
Note 2.3: the fourth command specifies the global ip address that will be used for the DMZ hosts
in order to initiate connections to the internet and receive back.
Note 2.4: in the fourth command, a pool of ip addresses can be specified and so the subnet mask
must be accordingly changed.
10
Configure No-Translation or NAT exempt
Nat inside network_ip subnet_mask 0 0 tcp 0 0 udp 0
A must-read note: NAT exempt states that no translation takes place for local hosts and this type is
used for connections in the internal space only.
Note 7: the command above specifies that a network of local hosts ip addresses will not be subject to
translation kind
A must-read note: this type of NAT is the most preferred for connections between DMZ and
client’s hosts and vice versa. It uses the same ip as the translated ip address
Note 8: the commands above could be specified for inside of DMZ interface on the ASA with the host ip
address remains the same after translation
11
Access-list INSIDE line 2 extended permit tcp src_ip subnet_mask any eq smtp
Access-list INSIDE line 3 extended permit tcp src_ip subnet_mask any eq ftp
Access-list INSIDE line 4 extended permit tcp src_ip subnet_mask any eq sftp
Allow incoming connections to the smtp, ftp and sftp server for “in” and “out”
direction
Access-list OUTSIDE line 2 extended permit tcp any host smtp_srv_ip eq smtp
Access-list OUTSIDE line 3 extended permit tcp any host ftp_srv_ip eq ftp
Access-list OUTSIDE line 4 extended permit tcp any host sftp_srv_ip eq sftp
Access-list DMZ line 1 extended permit tcp host smtp_srv_ip any eq smtp
Access-list DMZ line 2 extended permit tcp host ftp_srv_ip any eq ftp
Access-list DMZ line 3 extended permit tcp host tftp_srv_ip any eq tftp
Access-list DMZ line 4 extended permit tcp host http_srv_ip any eq http
Note 2: The last section or last two commands are specified to log the denied packets with 106100 log
message to be appeared in syslog server
Note 2.1: We could disable any access list above by appending the word “inactive” to the end of the
access list
Configuring time range access lists or attach time range to access lists
12
Time-range temporary-FTP-access-workhours ( for employees )
Periodic weekdays 09:00 to 06:00
Time-range ftp-hosting
Absolute start 00:00:01 May 2015 end 00:00:01 May 2016
Note 3: Every access list needs a time range to be appended to it so a time range must be named
and settled to related range
Time-range temporary-FTP-access-workhours
Access-list INSIDE line 5 extended permit tcp src_ip subnet_mask host ftp_srv eq ftp
Time-range temporary-FTP-access-workhours
Note 4: the time range for limiting access to ftp server beyond the working hours was applied to the
access lists the permit connection from outside and from the internal clients to the ftp server so that they
are only given access remotely or locally during working hours
Configuring network- object groups and service-object groups for enterprise access list
implementation
Name 10.0.10.0 Internal-clients
Name 10.0.30.0 DMZ-servers
Name 10.0.40.0 LA-Internal-clients
Name 10.0.50.0 LA-DMZ servers
Object-group network US-Offices
Network-object 10.0.10.0 255.0.255.0
13
Network-object 10.0.30.0 255.0.255.0
Network-object 10.0.40.0 255.0.255.0
Network-object 10.0.50.0 255.0.255.0
Object-group network internal-clients-offices
Network-object 10.0.10.0 255.0.255.0
Network-object 10.0.40.0 255.0.255.0
Object-group network DMZ-offices
Network-object 10.0.30.0 255.0.255.0
Network-object 10.0.50.0 255.0.255.0
Object-group service Allowed-services-ext-clients-DMZ
Description external services allowed for inside clients an DMZ servers
Port-object eq ftp
Port-object eq stp
Port-object eq http
Port-object eq smtp
Port-object eq pop3
Access-list INSIDE line 1 extended permit tcp object-group US-Offices any object-group
Allowed-services-ext-clients-DMZ
Access-list DMZ line 1 extended permit tcp object-group US-Offices any object-group
Allowed-services-ext-clients-DMZ
Access-list INSIDE line 2 extended permit tcp object-group internal-clients-offices object-
group DMZ-offices eq ftp
Time-range temporary-FTP-access-workhours
Access-list DMZ line 2 extended permit tcp object-group DMZ-offices object-group
internal-clients-offices eq any
Access-list OUTSIDE line 1 extended permit tcp any object-group DMZ-offices object-
group Allowed-services-ext-clients-DMZ
Note 6: the specified ACLs are to provide full connectivity to the DMZ server and internal client
server using object groups for network and services
14
Configure protection against spoofed ip packets towards the ASA
Ip verify reverse-path interface outside
Note 7: the specified command enables the unicast reverse path forwarding feature that if it’s enabled on
specific interface, it will examine every incoming connection whether exists in the connection table or not
and if not it will extract the source ip address to determine whether it’s reachable or not based on the
ASA’s routing table.
Note 7.1: Do not enable this feature on the outside interface in case a default route exists on your network
architecture to avoid the process overhead
15
Note 1.2: the class map matches the traffic whether all traffic, defined set of traffic, traffic
destined for specific destination, destined for specific port, matches against specific access list,
matches against VPN traffic or Qos values.
Note 1.3: in table 92 above, a list of all available commands that can be typed and specified in
class map to match against specific 3-4 OSI layer traffic. Most of these match commands will be
used on the outside interface to inspect traffic incoming to our network.
16
Table 2 - policy map action commands
Note 1.4: table 2 lists all actions that could be taken when a specified criterion matched in the class map.
Note 1.5: the last command above binds the policy map inside a service policy and applies it to the
outside interface
Note 1.6: table 3 lists the directions in which the actions of policy map could be applied. For
example, setting connection’s volume and limits, adjusting tcp parameters and sending the
traffic to an inspection engine and IPS could be applied and implemented on an interface in
both direction for traffic destined to the internet and for inbound traffic.
17
Note1.7: applying Quality of service, limiting bandwidth and shaping the traffic could be only on
an egress direction meaning that for outbound traffic only.
Essential and Important: the service policy which contains policy map and class map could be
applied for 3-4 OSI traffic or 5-7 OSI traffic while the former is used to examine, analyze and
inspect TCP and UDP traffic for connection parameters, connection volumes, connection
timeouts , protocol inspection , traffic analyzation using IPS module and for Qos of service
purposes and the latter which is 5-7 OSI traffic is used to examine and inspect application
layer traffic destined for DMZ servers.
Table 4 lists parameters for use in the “set connection timeouts” command when defining an action to be
taken by the policy map.
set connection timeout [embryonic {hh:mm:ss | 0}] [half-closed {hh:mm:ss | 0}] [tcp
{hh:mm:ss | 0} [dcd [retry_interval [max_retries]]
18
Table 5 tcp connection volume
Table 5 lists the parameters to be used in “set connection “command to control tcp connection volume.
set connection [conn-max n] [embryonic-conn-max n] [per-client-embryonic-max n] [per-client-max n]
To prevent TCP SYN attack the ASA must set a maximum number of simultaneous embryonic
connections which are half open or half closed. If the maximum number is reached the ASA triggers the
TCP Intercept feature and begins to act as proxy and send TCP handshake on target host behalf to
determine if the source address which communicates with the target host is legitimate or not so it drops
the connection is not.
Assuming that internal clients are under object-group (see previous sheet about object-groups) “Internal-
clients” and DMZ servers are under object-group “DMZ-Servers”. Let’s apply a connection limit for
embryonic connections initiated by these object groups.
Access-list INSIDE line 1 extended permit tcp Internal-clients any eq any
Access-list INSIDE line 2 extended permit udp Internal-clients any eq any
Service-policy SYN-Attack-protect
Class-map cmap1
Match access-list INSIDE
Policy-map pmap1
Class-map cmap1
Set connection embryonic-conn-max 65000
Access-list DMZ line 1 extended permit tcp any DMZ-Servers eq http
Access-list DMZ line 2 extended permit tcp DMZ-Servers any eq http
Service-policy SYN-Attack-protect
19
Class-map cmap2
Match access-list DMZ
Policy-map pmap2
Class-map cmap2
Set connection embryonic-conn-max 65000
Configuring and enabling the protection from TCP sequence number brute force
set connection random-sequence-number {enable | disable}
20
Table 6 tcp normalizer actions
Tcp-map TCP-Protect
invalid-ack drop
synack-data drop
ttl-evasion-protection
seq-past-window drop
exit
class-map cmap1
match access-list Internal-clients
exit
class-map cmap2
match access-list DMZ-Servers
exit
21
policy-map pmap3
class cmap1
set connection advanced-options TCP-Protect
exit
class cmap2
match access-list DMZ-Servers
set connection advanced-options TCP-Protect
exit
service-policy pmap3 interface outside
Note 4: The commands above matches against traffic inbound to internal clients and internal DMZ
servers and check for certain TCP parameters to protect internal hosts from TCP SYN attack,
reconnaissance packets and SYN flood attack by limiting the number or embryonic connections, dropping
invalid handshake packets or that contains invalid payload, dropping packets with invalid sequence
number and dropping values above maximum segment size in TCP window packet
Policy-map global_policy
Class inspection_default
Inspect icmp
Inspect icmp error
Exit
Note 5: the ICMP inspection feature is enabled when an access list that permits incoming ping request is
enabled. ICMP inspection used to allow only one response per ICMP request and inspect ICMP packet
for invalid sequence number.
Inspecting HTTP
Http inspection policy is implemented to examine and analyze traffic destined to protected servers or
clients. It’s main core to minimize http content to the minimal set of requirements and to look deeply in
the application signature for known bad cues mainly using regular expressions.
A class map that matches specific conditions in the http traffic should be defined along with a policy map
used to apply the appropriate action.
22
Table 7 - http match commands
Let’s say we want to configure a http policy map to allow only GET and POLL request to be passed
to the protected server.
class-map type inspect http match-all MY_HTTP_CLASS
match [not] request method get
23
match [not] request method poll
policy-map type inspect http http_map_name
parameters
protocol-violation drop-connection log
class MY_HTTP_CLASS
drop-connection log
exit
Now to match against regular expression we should use the following table
24
Table 8 regular expression match commands
For example, let’s suppose we want to filter incoming http traffic and take away any embedded link
within the http content
regex Embedded-link https?://
policy-map type inspect http HTTP_MAP_1
match request args regex Embedded-link
drop-connection
exit
in case of a multiple regular expressions we could use class map with match-any to apply OR
operation on the match commands or use match-all to apply AND operation on the match
commands
regex Embedded-link-1 https?://
regex Embedded-link-2 http?://
class-map type regex match-any embedded-link
match regex Embedded-link-1
match regex Embedded-link-2
now applying the http inspection map using the following command
25
inspect http http-map-name
the activation command must be applied inside a policy map
Inspecting FTP
Inspecting FTP traffic includes masking FTP banner, masking reply message, prevent uploading “exe”
files to the server unless it’s stated in the security policy and restricting request methods to GET and PUT
26
The commands above create a policy map to inspect FTP. Banner information and system reply
information are masked to prevent malicious users from conducting vulnerability assessment using the
FTP server information. Also, the commands filters request to the server to only accept GET and PULL
request as well as prevent EXE file names to be uploaded.
27
exit
The ASA has a default dns inspection policy map called “preset_dns_map” which limits the size of dns
packets to 512 bytes
28
Configuring traffic policing and traffic shaping
Controlling bandwidth limits is essential when it comes to Qos and prioritizing packets over other ones.
Controlling packets is performed either by dropping the packet which surpasses the bandwidth threshold
or by re-shaping it so it conforms to the bandwidth limits.
Traffic policing
Suppose we want to configure a policy map to match all traffic and drop every packet that consumes more
than 2Mbps. To achieve so we need a policy map with a class map to match all traffic therefore we need
the following commands
Class-map Policing
Match any
Exit
Policy-map mine
Class-map policing
Police output 200000000 conform-action transmit exceed-action drop
Exit
Exit
Service-policy mine interface outside
Traffic shaping
Traffic shaping is the act of placing the packets inside a buffer and then pulling out the traffic with a
bandwidth limits beneath the threshold. This type of bandwidth control is applicable and permissible only
to all traffic or bulk.
Policy-map outside-policy
Class class-default
Shape average 200000000
Exit
Exit
Service-policy outside-policy interface outside
29
Deploying transparent mode has some challenges and restrictions so this mode should not be applied until
you specify your network requirements and recognize the limitations imposed by this mode
30
match the incoming packet with the information in the ARP table so to drop the packet or allow it to pass
based on the match conditions.
Arp interface ip_address mac_address
Arp-inspection interface enable
Show arp-inspection
Now coming to prevent MAC address denial of service by disabling mac address learning feature in
transparent mode and here the administrator must create MAC address table just like above and maintain
it regularly.
Mac-learn interface disable
Mac-address-table static interface mac_address
Integrating Security service module, Intrusion prevention system and content security
control
After inserting the card module in the specified slot, create a vlan and upload the IPS software to the
modules through the commands
Interface vlan 10
Allow-ssc-mgmt
Ip address ip_address subnet_mask
Nameif inside
Interface eth0/10
Switchport mode access vlan 10
No shutdown
Hw-module 1 recover configure
Hw-module 1 recover boot
Hw-module 1 password-rest : resets to “cisco”
Hw-module 1 reload
Hw-module 1 reset
Hw-module 1 shutdown : used to shutdown the module
Now coming to initialization knowing that the IPS could work in an inline mode [ drop the packets as it
violates or determined a malicious] or in a promiscuous mode [ allow the packet to pass to the intended
destination while sending the packet for analysis].
Session 1
31
Setup
Policy-map IPS
Class class-default
Ips inline fail-open
Service-policy IPS interface outside
Conclusion
Virtual firewalls and many other aspects and configurations related to Cisco ASA were not mentioned
here because it’s easier to manage it using ASDM and this guide documented the most common tasks
related to command line in Cisco ASA firewall.
References
Cisco CCNP Security Firewall Certification Guide
CCNP Certification Guide
32
33
34