思科接口和模块 : Cisco ACE 设备控制引擎模块

使用源 NAT 和客户端 IP 报头插入配置 ACE

2016 年 10 月 24 日 - 机器翻译
其他版本: PDFpdf | 英语 (2015 年 8 月 22 日) | 反馈


目录


简介

本文档提供了应用控制模块 (ACE) 的一个配置范例,其中配置了源网络地址转换 (NAT) 并在 HTTP 报头中插入了原始客户端 IP 地址。使用源 NAT 时,客户端 IP 地址不会传递至负载均衡服务器。在报头中插入客户端 IP 地址将使服务器能够看到进行该连接的 IP。服务器默认网关指向服务器 VLAN 中的 MSFC。只有需要进行负载均衡的通信才会通过 ACE。

此范例使用两上下文:

  • 管理上下文用于远程管理和容错 (FT) 配置

  • 第二个上下文 C1 用于负载均衡

先决条件

要求

本文档没有任何特定的要求。

使用的组件

本文档不限于特定的软件和硬件版本。

本文档中的信息都是基于特定实验室环境中的设备编写的。本文档中使用的所有设备最初均采用原始(默认)配置。如果您使用的是真实网络,请确保您已经了解所有命令的潜在影响。

规则

有关文档规则的详细信息,请参阅 Cisco 技术提示规则

配置

本部分提供有关如何配置本文档所述功能的信息。

注意: 使用命令查找工具仅限注册用户)可获取有关本部分所使用命令的详细信息。

网络图

本文档使用以下网络设置:

/image/gif/paws/107399/ace-sourcenat-config1.gif

配置

本文档使用以下配置:

ACE C1 上下文
switch/C1#show run
Generating configuration....

access-list any line 8 extended permit icmp any any 
access-list any line 16 extended permit ip any any 

!--- Access-list used to permit or deny traffic from entering the ACE.

probe tcp SERVERS
  interval 5
  passdetect interval 10

!--- TCP probe used to test the availability of the servers.

parameter-map type http HTTP_PARAMETER_MAP
  persistence-rebalance

!--- Parameter-map used to configure advanced http behavior.
!--- Persistence-rebalance inspects every get and matches to specific content.
!--- Without this command only the first get in a tcp session will be inspected.

rserver host S1
  ip address 192.168.0.200
  inservice
rserver host S2
  ip address 192.168.0.201
  inservice
rserver host S3
  ip address 192.168.0.202
  inservice
rserver host S4
  ip address 192.168.0.203
  inservice

serverfarm host SF-1
  probe SERVERS
  rserver S1
    inservice
  rserver S2
    inservice
  rserver S3
    inservice
  rserver S4
    inservice

!--- Serverfarm used for load balanced traffic.

class-map match-all L4VIPCLASS
  2 match virtual-address 172.16.0.15 tcp eq www

!--- Layer 4 class-map defining IP address and port.

class-map type management match-any REMOTE_ACCESS
  2 match protocol ssh any
  3 match protocol telnet any
  4 match protocol icmp any
  5 match protocol snmp any
  6 match protocol http any

!--- Remote management class-map defining protocols allowed to manage the ACE.

policy-map type management first-match REMOTE_MGMT_ALLOW_POLICY
  class REMOTE_ACCESS
    permit

policy-map type loadbalance http first-match WEB_L7_POLICY
  class class-default
    serverfarm SF-1
    insert-http x-forward header-value "%is"

!--- Policy-map will insert the IP address of the client when sending traffic to the serverfarm.

policy-map multi-match VIPs
  class L4VIPCLASS
    loadbalance vip inservice
    loadbalance policy WEB_L7_POLICY
    loadbalance vip icmp-reply active
    loadbalance vip advertise active
    nat dynamic 1 vlan 511
    appl-parameter http advanced-options HTTP_PARAMETER_MAP

!--- Multi-match policy ties the class-map and policy-maps together.
!--- Clients matching class L4VIPCLASS will use source NAT.

interface vlan 240
  ip address 172.16.0.130 255.255.255.0
  alias 172.16.0.128 255.255.255.0
  peer ip address 172.16.0.131 255.255.255.0
  access-group input any
  service-policy input REMOTE_MGMT_ALLOW_POLICY
  service-policy input VIPs
  no shutdown

!--- Client side VLAN; This is the VLAN clients will enter the ACE.
!--- Apply access-lists and service-policies that are needed.

interface vlan 511
  ip address 192.168.0.130 255.255.255.0
  alias 192.168.0.128 255.255.255.0
  peer ip address 192.168.0.131 255.255.255.0
  access-group input any
  nat-pool 1 192.168.0.254 192.168.0.254 netmask 255.255.255.0 pat
  no shutdown

!--- Server side VLAN.

ip route 0.0.0.0 0.0.0.0 172.16.0.1

!--- Default gateway points to the MSFC.

switch/C1#

ACE 管理上下文
switch/Admin#show running-config
Generating configuration....

boot system image:c6ace-t1k9-mz.A2_1_0a.bin

resource-class RC1
  limit-resource all minimum 50.00 maximum equal-to-min

!--- Resource-class used to limit the amount of resources a specific context can use.

access-list any line 8 extended permit icmp any any 
access-list any line 16 extended permit ip any any 

rserver host test

class-map type management match-any REMOTE_ACCESS
  2 match protocol ssh any
  3 match protocol telnet any
  4 match protocol icmp any
  5 match protocol snmp any
  6 match protocol http any

policy-map type management first-match REMOTE_MGMT_ALLOW_POLICY
  class REMOTE_ACCESS
    permit

interface vlan 240
  ip address 172.16.0.4 255.255.255.0
  alias 172.16.0.10 255.255.255.0
  peer ip address 172.16.0.5 255.255.255.0
  access-group input any
  service-policy input REMOTE_MGMT_ALLOW_POLICY
  no shutdown
interface vlan 511
  ip address 192.168.0.4 255.255.255.0
  alias 192.168.0.10 255.255.255.0
  peer ip address 192.168.0.5 255.255.255.0
  access-group input any
  no shutdown

ft interface vlan 550
  ip address 192.168.1.4 255.255.255.0
  peer ip address 192.168.1.5 255.255.255.0
  no shutdown

!--- VLAN used for fault tolerant traffic.
 
ft peer 1
  heartbeat interval 300
  heartbeat count 10
  ft-interface vlan 550

!--- FT peer definition defining heartbeat parameters and to associate the ft VLAN.

ft group 1
  peer 1
  peer priority 90
  associate-context Admin
  inservice

!--- FT group used for Admin context.

ip route 0.0.0.0 0.0.0.0 172.16.0.1

context C1
  allocate-interface vlan 240
  allocate-interface vlan 511
  member RC1

!--- Allocate vlans the context C1 will use.

  ft group 2
  peer 1
  no preempt
  associate-context C1
  inservice

!--- FT group used for the load balancing context C1.

username admin password 5 $1$faXJEFBj$TJR1Nx7sLPTi5BZ97v08c/  role Admin domai
n default-domain 
username www password 5 $1$UZIiwUk7$QMVYN1JASaycabrHkhGcS/  role Admin domain 
default-domain 

switch/Admin#

路由器配置

!--- Only portions of the config relevant to the ACE are displayed.

sf-cat1-7606#show run
Building configuration...

!--- Output Omitted.


svclc multiple-vlan-interfaces
svclc module 2 vlan-group 2
svclc vlan-group 2  220,240,250,510,511,520,540,550

!--- Before the ACE can receive traffic from the supervisor engine in the Catalyst 6500
!--- or Cisco 6600 series router, you must create VLAN groups on the supervisor engine,
!--- and then assign the groups to the ACE.
!--- Add vlans to the vlan-group that are needed for ALL contexts on the ACE.

interface Vlan240
 description public-vip-172.16.0.x 
 ip address 172.16.0.2 255.255.255.0
 standby ip 172.16.0.1
 standby priority 20
 standby name ACE_slot2

!--- SVI (Switch Virtual Interface). The standby address is the default gateway for the ACE.


!--- Output Ommited.

sf-cat1-7606#

验证

使用本部分可确认配置能否正常运行。

命令输出解释程序仅限注册用户)(OIT) 支持某些 show 命令。使用 OIT 可查看对 show 命令输出的分析。

  • show serverfarm name — 显示有关服务器群和 rserver 的状态的信息。

    以下示例提供了一个输出范例:

    switch/C1#show serverfarm SF-1 
     serverfarm     : SF-1, type: HOST
     total rservers : 4
    
     ---------------------------------
                                                    ----------connections---------
    --
           real                  weight state        current    total      failure
    s 
       ---+---------------------+------+------------+----------+----------+-------
    --
       rserver: S1
           192.168.0.200:0       8      OPERATIONAL  0          114        0
       rserver: S2
           192.168.0.201:0       8      OPERATIONAL  0          113        0
       rserver: S3
           192.168.0.202:0       8      OPERATIONAL  0          109        0
       rserver: S4
           192.168.0.203:0       8      OPERATIONAL  0          106        0
  • show service-policy name — 显示 http 统计信息。

    以下示例提供了一个输出范例:

    switch/C1#show service-policy VIPs 
    
    Status     : ACTIVE
    -----------------------------------------
    Interface: vlan 240 
      service-policy: VIPs
        class: L4VIPCLASS
          nat:
            nat dynamic 1 vlan 511
            curr conns       : 0         , hit count        : 300       
            dropped conns    : 0         
            client pkt count : 1503      , client byte count: 195846              
            server pkt count : 1731      , server byte count: 1760884             
            conn-rate-limit      : 0         , drop-count : 0         
            bandwidth-rate-limit : 0         , drop-count : 0         
          loadbalance:
            L7 loadbalance policy: WEB_L7_POLICY
            VIP Route Metric     : 77
            VIP Route Advertise  : ENABLED-WHEN-ACTIVE
            VIP ICMP Reply       : ENABLED-WHEN-ACTIVE
            VIP State: INSERVICE
            curr conns       : 0         , hit count        : 300       
            dropped conns    : 0         
            client pkt count : 1503      , client byte count: 195846              
            server pkt count : 1731      , server byte count: 1760884             
            conn-rate-limit      : 0         , drop-count : 0         
            bandwidth-rate-limit : 0         , drop-count : 0         
            Parameter-map(s):
              HTTP_PARAMETER_MAP
  • show stats http — 显示 http 统计信息。

    以下示例提供了一个输出范例:

    switch/C1#show stats http
    
    +------------------------------------------+
    +-------------- HTTP statistics -----------+
    +------------------------------------------+
     LB parse result msgs sent : 109        , TCP data msgs sent       : 294      
     
     Inspect parse result msgs : 0          , SSL data msgs sent       : 0        
     
                          sent
     TCP fin/rst msgs sent     : 0          , Bounced fin/rst msgs sent: 0        
     
     SSL fin/rst msgs sent     : 0          , Unproxy msgs sent        : 109      
     
     Drain msgs sent           : 79         , Particles read           : 520      
     
     Reuse msgs sent           : 0          , HTTP requests            : 109      
     
     Reproxied requests        : 38         , Headers removed          : 0        
     
     Headers inserted          : 109        , HTTP redirects           : 0        
     
     HTTP chunks               : 0          , Pipelined requests       : 0        
     
     HTTP unproxy conns        : 109        , Pipeline flushes         : 0        
     
     Whitespace appends        : 0          , Second pass parsing      : 0        
     
     Response entries recycled : 0          , Analysis errors          : 0        
     
     Header insert errors      : 0          , Max parselen errors      : 0        
     
     Static parse errors       : 0          , Resource errors          : 0        
     
     Invalid path errors       : 0          , Bad HTTP version errors  : 0        
     
     Headers rewritten         : 0          , Header rewrite errors    : 0
  • show conn — 显示当前连接及其状态。

    以下示例提供了一个输出范例:

    switch/C1#show conn
    
    total current connections : 2
    
    conn-id    np dir proto vlan source                destination           state
    ----------+--+---+-----+----+---------------------+---------------------+-----
    -+
    11         1  in  TCP   240  172.16.10.221:1712    172.16.0.15:80        ESTAB
    19         1  out TCP   511  192.168.0.201:80      192.168.0.254:1369    ESTAB
  • sniffer trace — 嗅探器踪迹,用于确认插入了报头。

    以下示例提供了一个输出范例:

    GET / HTTP/1.1
    x-forward: 172.16.10.221
    Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, */*
    Accept-Language: en-us
    Accept-Encoding: gzip, deflate
    If-Modified-Since: Fri, 30 Nov 2007 16:59:08 GMT
    If-None-Match: "0164b527233c81:767"
    User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)
    Host: www.cisco.com
    Connection: Keep-Alive
    
    HTTP/1.1 304 Not Modified
    Content-Location: http://www.cisco.com/index.htm
    Last-Modified: Fri, 30 Nov 2007 16:59:08 GMT
    Accept-Ranges: bytes
    ETag: "0164b527233c81:767"
    Server: Microsoft-IIS/6.0
    X-Powered-By: ASP.NET
    Date: Tue, 20 May 2008 19:10:04 GMT
    
    GET /header.html HTTP/1.1
    x-forward: 172.16.10.221
    Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, */*
    Referer: http://www.cisco.com/
    Accept-Language: en-us
    Accept-Encoding: gzip, deflate
    If-Modified-Since: Fri, 30 Nov 2007 16:59:08 GMT
    If-None-Match: "0164b527233c81:767"
    User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)
    Host: www.cisco.com
    Connection: Keep-Alive
    
    HTTP/1.1 304 Not Modified
    Last-Modified: Fri, 30 Nov 2007 16:59:08 GMT
    Accept-Ranges: bytes
    ETag: "0164b527233c81:767"
    Server: Microsoft-IIS/6.0
    X-Powered-By: ASP.NET
    Date: Tue, 20 May 2008 19:10:04 GMT

故障排除

目前没有针对此配置的故障排除信息。


相关信息


Document ID: 107399