Z
Z
Zueuk2018-05-07 13:01:11
Cisco
Zueuk, 2018-05-07 13:01:11

How to write port forwarding rules in Cisco Asa?

Hello. I have the following config

config
:
ASA Version 9.1(5) 
!
hostname ASA
xlate per-session deny tcp any4 any4
xlate per-session deny tcp any4 any6
xlate per-session deny tcp any6 any4
xlate per-session deny tcp any6 any6
xlate per-session deny udp any4 any4 eq domain
xlate per-session deny udp any4 any6 eq domain
xlate per-session deny udp any6 any4 eq domain
xlate per-session deny udp any6 any6 eq domain
names
dns-guard
!
interface Ethernet0/0
 nameif LAN
 security-level 100
 ip address 192.168.54.40 255.255.255.0 
!
interface Management0/0
 management-only
 nameif management
 security-level 100
 ip address 192.168.1.1 255.255.255.0 
!
interface GigabitEthernet1/0
 nameif OUTSIDE
 security-level 0
 ip address OUTSIDE_IP 255.255.255.0 
!
boot system disk0:/asa915-k8.bin
same-security-traffic permit inter-interface
same-security-traffic permit intra-interface
object network LAN-SUBNET
 subnet 192.168.54.0 255.255.255.0
object network LAN_WKS
 host 192.168.54.50
object network TEST-HOST
 host XYZ.XYZ.XYZ.82
object service ssh_22
 service tcp destination eq ssh 
 description ssh service
object service ssh_2222
 service tcp destination eq 2222 
 description ssh2222 service
object-group protocol TCPIP
 protocol-object ip
 protocol-object tcp
access-list OUTSIDE_access_in extended permit tcp object TEST-HOST object LAN_WKS eq ssh log debugging 
access-list OUTSIDE_access_in extended deny icmp any interface OUTSIDE inactive 
icmp unreachable rate-limit 1 burst-size 1
asdm image disk0:/asdm-716.bin
no asdm history enable
arp timeout 14400
no arp permit-nonconnected
nat (LAN,OUTSIDE) source dynamic LAN-SUBNET interface
nat (OUTSIDE,LAN) source static any any destination static interface LAN_WKS service ssh_2222 ssh_22 no-proxy-arp
access-group OUTSIDE_access_in in interface OUTSIDE
route OUTSIDE 0.0.0.0 0.0.0.0 GATEWAY_IP 1 
timeout xlate 3:00:00
timeout pat-xlate 0:00:30
timeout conn 1:00:00 half-closed 0:10:00 udp 0:02:00 icmp 0:00:02
timeout sunrpc 0:10:00 h323 0:05:00 h225 1:00:00 mgcp 0:05:00 mgcp-pat 0:05:00
timeout sip 0:30:00 sip_media 0:02:00 sip-invite 0:03:00 sip-disconnect 0:02:00
timeout sip-provisional-media 0:02:00 uauth 0:05:00 absolute
timeout tcp-proxy-reassembly 0:01:00
timeout floating-conn 0:00:00
dynamic-access-policy-record DfltAccessPolicy
user-identity default-domain LOCAL
aaa authentication ssh console LOCAL 
aaa authentication telnet console LOCAL 
http server enable
http 192.168.1.0 255.255.255.0 management
http XX.YY.ZZ.157 255.255.255.255 OUTSIDE
sysopt noproxyarp OUTSIDE
crypto ipsec security-association pmtu-aging infinite
crypto ca trustpool policy
ssh scopy enable
ssh stricthostkeycheck
ssh 192.168.1.0 255.255.255.0 management
ssh XX.YY.ZZ.157 255.255.255.255 OUTSIDE
ssh timeout 30
ssh version 2
ssh key-exchange group dh-group1-sha1
console timeout 0
dhcpd address 192.168.1.2-192.168.1.254 management
!
threat-detection statistics access-list
no threat-detection statistics tcp-intercept
ssl encryption rc4-md5 rc4-sha1 aes128-sha1 aes256-sha1 3des-sha1
!
class-map inspection_default
 match default-inspection-traffic
!
!
policy-map type inspect dns migrated_dns_map_1
 parameters
  message-length maximum 512
policy-map global_policy
 class inspection_default
  inspect dns migrated_dns_map_1 
  inspect ftp 
  inspect h323 h225 
  inspect h323 ras 
  inspect rsh 
  inspect rtsp 
  inspect esmtp 
  inspect sqlnet 
  inspect skinny  
  inspect sunrpc 
  inspect xdmcp 
  inspect sip  
  inspect netbios 
  inspect tftp 
  inspect icmp 
  inspect ip-options 
!
service-policy global_policy global
prompt hostname context 
: end
asdm image disk0:/asdm-716.bin
no asdm history enable


It is required to forward the external port 2222 to the internal port 22.
For this, the NAT rule is written:
nat (OUTSIDE,LAN) source static any any destination static interface LAN_WKS service ssh_2222 ssh_22 no-proxy-arp

and access-list
access-list OUTSIDE_access_in extended permit tcp object TEST-HOST object LAN_WKS eq ssh log debugging

When testing a connection, packet-tracer shows the following:
packet-tracer input outside tcp TEST-HOST 11065 OUTSIDE_IP 2222

Phase: 1
Type: ROUTE-LOOKUP
Subtype: input
Result: ALLOW
Config:
Additional Information:
in   OUTSIDE_IP   255.255.255.255 identity

Phase: 2
Type: NAT
Subtype: per-session
Result: ALLOW
Config:
Additional Information:

Phase: 3
Type: ACCESS-LIST
Subtype: 
Result: DROP
Config:
Implicit Rule
Additional Information:

Result:
input-interface: OUTSIDE
input-status: up
input-line-status: up
output-interface: NP Identity Ifc
output-status: up
output-line-status: up
Action: drop
Drop-reason: (acl-drop) Flow is denied by configured rule

Tell me, where is the mistake?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Grishin, 2018-05-07
@vesper-bot

The outgoing IP in the trace is wrong, you need the IP of some node behind the OUTSIDE interface, and judging by the nat settings, TEST_HOST is inside the perimeter. Because of this, the block.

Z
Zueuk, 2018-05-07
@Zueuk

Under TEST-HOST, for convenience, the external ip of the host is indicated.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question