Cisco ASA 5505 — installazione da zero

The Cisco ASA 5505 is a firewall with a built-in 8-port switch (Ethernet0/0–0/7, ports 0/6 and 0/7 with PoE). IP addresses are assigned not to ports but to Vlan interfaces, and the ports are placed in those VLANs. The last software release for the 5505 is 9.2, while policy based routing appeared in ASA only in 9.4, so the link choice for 192.168.3.x is made with “NAT divert” — standard twice NAT behaviour where the NAT rule determines the egress interface.

Porte di dispositivo

RolePorto di Porto
ISP principale (ISP1)Ethernet0/0 (Vlan100, outside)
ISP extra (ISP2)Ethernet0/1 (Vlan200, isp2)
VLAN 1 (accesso)Ethernet0/2 (Vlan1, inside)
CONTROEthernet0/3 — VLAN 1 untagged, VLANs 2 and 3 tagged

The ISP and resource addresses in the examples are documentation addresses (RFC 5737): 203.0.113.0/24, 198.51.100.0/24, 192.0.2.0/24. Replace them with your own. Replace passwords shown as <PASSWORD> with your own. Dati iniziali →

Impostazione passo-passo

  1. Connect, reset and check the license

    Console: 9600 8N1. write erase and reload give a clean configuration; answer no to the setup wizard prompt. The scheme needs the Security Plus license: five VLAN interfaces (outside, isp2, inside, vlan2, vlan3) and a trunk port, while the Base license gives 3 VLANs and no trunking. For /22 networks you also need the unlimited-hosts license (Inside Hosts: Unlimited), otherwise the ASA serves only 10 or 50 inside addresses.

    enable
    write erase
    reload
    ! "Pre-configure Firewall now through interactive prompts [yes]?" -> no
    enable
    show version | include VLANs|Inside Hosts|Trunk
    configure terminal
    hostname ASA5505
    enable password <PASSWORD>
  2. Main ISP on Ethernet0/0 and DNS

    Vlan100 with nameif outside and security-level 0, port 0/0 in VLAN 100. Default route and the ISP's DNS servers.

    interface Vlan100
     nameif outside
     security-level 0
     ip address 203.0.113.10 255.255.255.248
     no shutdown
    interface Ethernet0/0
     switchport access vlan 100
     no shutdown
    route outside 0.0.0.0 0.0.0.0 203.0.113.9 1
    dns domain-lookup outside
    dns server-group DefaultDNS
     name-server 203.0.113.2
     name-server 203.0.113.3
  3. Extra ISP on Ethernet0/1

    Vlan200 with nameif isp2. Routes via ISP2 go to the resources only; without step 9 they would apply to all hosts.

    interface Vlan200
     nameif isp2
     security-level 0
     ip address 198.51.100.10 255.255.255.248
     no shutdown
    interface Ethernet0/1
     switchport access vlan 200
     no shutdown
    route isp2 192.0.2.10 255.255.255.255 198.51.100.9 1
    route isp2 192.0.2.128 255.255.255.128 198.51.100.9 1
  4. VLAN 1 on Ethernet0/2

    Vlan1 is the inside interface with the highest trust level 100 and gateway 192.168.1.254/22.

    interface Vlan1
     nameif inside
     security-level 100
     ip address 192.168.1.254 255.255.252.0
     no shutdown
    interface Ethernet0/2
     switchport access vlan 1
     no shutdown
  5. VLAN 2 and VLAN 3

    By default the ASA passes traffic from a higher security-level interface to a lower one: inside (100) → vlan2 (90) → vlan3 (80) → internet (0). The reverse directions are closed until you allow them with an ACL.

    interface Vlan2
     nameif vlan2
     security-level 90
     ip address 192.168.5.254 255.255.252.0
     no shutdown
    interface Vlan3
     nameif vlan3
     security-level 80
     ip address 192.168.9.254 255.255.252.0
     no shutdown
  6. Trunk on Ethernet0/3

    VLAN 1 is native (untagged), VLANs 2 and 3 are tagged.

    interface Ethernet0/3
     switchport mode trunk
     switchport trunk allowed vlan 1-3
     switchport trunk native vlan 1
     no shutdown
  7. DHCP server

    The ASA automatically gives clients its interface address as the gateway. Pools use the first /24 of each network; 192.168.1.1–192.168.3.254 are assigned manually.

    dhcpd address 192.168.0.1-192.168.0.254 inside
    dhcpd address 192.168.4.1-192.168.4.254 vlan2
    dhcpd address 192.168.8.1-192.168.8.254 vlan3
    dhcpd dns 203.0.113.2 203.0.113.3
    dhcpd lease 86400
    dhcpd enable inside
    dhcpd enable vlan2
    dhcpd enable vlan3
  8. NAT for internet access via ISP1

    Auto NAT (PAT to the outside interface address) for each of the three networks.

    object network NET-VLAN1
     subnet 192.168.0.0 255.255.252.0
     nat (inside,outside) dynamic interface
    object network NET-VLAN2
     subnet 192.168.4.0 255.255.252.0
     nat (vlan2,outside) dynamic interface
    object network NET-VLAN3
     subnet 192.168.8.0 255.255.252.0
     nat (vlan3,outside) dynamic interface
  9. Resources via ISP2 for 192.168.3.1–192.168.3.254 only (instead of PBR)

    Twice NAT with destination static RES-ISP2 RES-ISP2 (the destination does not change) selects the egress interface before the routing table — this is NAT divert. Rule 1 sends 192.168.3.1–254 to the resources via isp2, translated to the isp2 address. Rules 2–4 send all other hosts to the same resources via outside, otherwise the route from step 3 would take them. Order matters: the 3.x addresses must match rule 1 before rule 2.

    object network PBR-SRC
     range 192.168.3.1 192.168.3.254
    object network RES-1
     host 192.0.2.10
    object network RES-2
     subnet 192.0.2.128 255.255.255.128
    object-group network RES-ISP2
     network-object object RES-1
     network-object object RES-2
    nat (inside,isp2) 1 source dynamic PBR-SRC interface destination static RES-ISP2 RES-ISP2
    nat (inside,outside) 2 source dynamic NET-VLAN1 interface destination static RES-ISP2 RES-ISP2
    nat (vlan2,outside) 3 source dynamic NET-VLAN2 interface destination static RES-ISP2 RES-ISP2
    nat (vlan3,outside) 4 source dynamic NET-VLAN3 interface destination static RES-ISP2 RES-ISP2
  10. Management and ICMP

    SSH only from VLAN 1 with a local account. ICMP inspection lets ping and traceroute work from inside.

    username admin password <PASSWORD> privilege 15
    aaa authentication ssh console LOCAL
    crypto key generate rsa modulus 2048
    ssh 192.168.0.0 255.255.252.0 inside
    ssh version 2
    policy-map global_policy
     class inspection_default
      inspect icmp
  11. Save and verify

    packet-tracer simulates a packet without real traffic: for 192.168.3.10 the output should show the phase “NAT divert to egress interface isp2”, for 192.168.1.10 — outside.

    write memory
    show interface ip brief
    show switch vlan
    show route
    show nat detail
    show dhcpd binding
    packet-tracer input inside tcp 192.168.3.10 50000 192.0.2.10 443
    packet-tracer input inside tcp 192.168.1.10 50000 192.0.2.10 443

Importante

  • The ASA 5505 is end-of-sale and end-of-life; it no longer receives security updates. For a new project, choose a device on a current platform.
  • If ISP2 is down, 192.168.3.x traffic to the resources will not fail over to ISP1 by itself: rule 1 forces isp2. For redundancy, temporarily disable the rule (no nat … 1) or use a device with full PBR.
  • When more resources are added, put them into the RES-ISP2 group and add a route isp2 — the NAT rules stay unchanged.

Fonti

  1. Cisco. ASA 5505 licensing (Base / Security Plus), switch ports and VLAN interfaces — Cisco ASA Series General Operations CLI Configuration Guide
  2. Cisco. ASA Series Firewall CLI Configuration Guide 9.x: Network Address Translation — NAT and the egress interface
  3. Cisco. Release Notes for the Cisco ASA Series 9.4: Policy Based Routing
  4. Cisco. End-of-Sale and End-of-Life Announcement for the Cisco ASA 5505