A.2. Procedure – Configuring advanced routing on Cisco routers

Purpose: 

To configure a Cisco router to redirect selected traffic to PSM instead of its original destination, complete the following steps. This procedure should work on most modern Cisco IOS releases but was specifically tested on IOS version 12.3.

Steps: 

  1. Create an ACL (Access Control List) entry that matches the client and server subnets and the to-be-audited port. Keep in mind that whatever is permitted by this ACL is what will be matched, so make sure that the scope of the ACL entry is narrowed down as much as possible.

    #(config) ip access-list extended ssh-inbound
    #(config-ext-nacl) permit tcp <src net> <src mask> <dst net> <dst mask> eq <dst port>
    Example A.2. Configuring an ACL entry for Cisco policy routing

    For example, if the clients are in the 192.168.0.0/24 subnet, the servers are located in the 10.0.0.0/24 subnet, and the clients access the servers using port 22 (the default port of the SSH protocol), then the permit clause should be:

    #(config-ext-nacl) permit tcp 192.168.0.0 0.0.0.255 10.0.0.0 0.0.0.255 eq 22
    Tip

    Cisco ACLs use inverse netmasks for defining network addresses. To calculate an inverse mask given a subnet mask, simply subtract each octet value from 255.

  2. Create an ACL entry that matches the reply packets coming from the server zone and targeted at the client zone to make sure that replies are reaching the PSM.

    #(config) ip access-list extended ssh-outbound
    #(config-ext-nacl) permit tcp <dst net> <dst mask> eq <dst port> <src net> <src mask>
    Note

    This step is only required if you want to use Source NAT (IP Spoofing) instead of PSM’s address towards the monitored servers.

    Figure A.2. Control > Connections — Using SNAT

    Control > Connections — Using SNAT
    Example A.3. Configuring an ACL entry for reply packets with Cisco policy routing

    In case of the example in step 1, the permit clause should be:

    #(config-ext-nacl) permit tcp 10.0.0.0 0.0.0.255 eq 22 192.168.0.0 0.0.0.255
  3. Create a route-map entry. It controls which packets are affected by policy routing and where they should be forwarded to. The match commands specify the conditions under which policy routing occurs. The set commands specify the routing actions to perform if the criteria enforced by the match commands are met. A new route-map can be defined as follows:

    #(config) route-map scb-inbound
    1. Set your route-map to match the traffic in ACL ssh-inbound:

      #(config-route-map) match ip address ssh-inbound
    2. Set an action on the matching traffic. Define a next-hop entry to redirect the traffic to the PSM.

      #(config-route-map) set ip next-hop <PSM IP address>
  4. Create another route-map that controls the reply packet flow.

    #(config) route-map scb-outbound
    #(config-route-map) match ip address ssh-outbound
    #(config-route-map) set ip next-hop <PSM IP address>
    Note

    This step is only required if you want to use Source NAT (IP Spoofing) instead of PSM’s address towards the monitored servers.

    Figure A.3. Control > Connections — Using SNAT

    Control > Connections — Using SNAT
  5. Apply the route-map to the appropriate interfaces.

    1. First, add the ssh-inbound route-map entry to the interface facing the clients:

      #(config) interface <interface-facing-the-clients>
      #(config-if) ip policy route-map scb-inbound
    2. Then add the ssh-outbound route-map entry to the interface facing the servers:

      #(config) interface <interface-facing-the-servers>
      #(config-if) ip policy route-map scb-outbound

    Expected result: 

    The traffic from the clients targeting the specified port of the servers is redirected to PSM. Therefore, PSM can be configured to control and audit this traffic.

    The full configuration for the above topology:

    ! interface facing the clients
    interface FastEthernet0/0
     ip address 192.168.0.254 255.255.255.0
     ip policy route-map scb-inbound
     duplex full
     speed auto
     no mop enabled
    
    ! interface facing the SCB
    interface FastEthernet0/1
     ip address 172.16.0.254 255.255.255.0
     duplex full
     speed auto
     no mop enabled
    
    ! interface facing the servers
    interface FastEthernet1/0
     ip address 10.0.0.254 255.255.255.0
     ip policy route-map scb-outbound
     duplex full
     speed auto
     no mop enabled
    
    ! access lists matching the server and client subnets and the SSH port - incoming packets
    ip access-list extended ssh-inbound
     permit tcp 192.168.0.0 0.0.0.255 10.0.0.0 0.0.0.255 eq 22
    ! access lists matching the server and client subnets and the SSH port - reply packets
    ip access-list extended ssh-outbound
     permit tcp 10.0.0.0 0.0.0.255 eq 22 192.168.0.0 0.0.0.255
    
    ! policy routing entry matching on the incoming SSH connections and
    ! redirecting them to the SCB external interface
    route-map scb-inbound permit 10
     match ip address ssh-inbound
     set ip next-hop 172.16.0.1
    
    ! the following part is only required for SNAT-based SCB configuration
    ! policy routing entry matching on the SSH reply packets and
    ! redirecting them to the SCB external interface
    route-map scb-outbound permit 10
     match ip address ssh-outbound
     set ip next-hop 172.16.0.1