CLI方式:内网用户通过NAT地址访问内网服务器典型配置

使用版本

本举例是在F1090R8660P33版本上进行配置和验证的。

组网需求

如下图所示:

需要实现如下功能:

图-1 内网用户通过NAT地址访问内网服务器配置组网图

配置思路

该需求为典型的C-S模式的NAT hairpin应用,具体配置思路如下。

配置步骤

# 配置接口IP地址、路由、安全域及域间策略保证网络可达,具体配置步骤略。

# 配置ACL 2000,允许对内部网络中192.168.1.0/24网段的报文进行地址转换。

<Device> system-view

[Device] acl basic 2000

[Device-acl-ipv4-basic-2000] rule permit source 192.168.1.0 0.0.0.255

[Device-acl-ipv4-basic-2000] quit

# 在接口GigabitEthernet1/0/2上配置NAT内部服务器,允许外网主机使用地址202.38.1.2访问内网FTP服务器,同时使得内网主机访问内网FTP服务器的报文可以进行目的地址转换。

[Device] interface gigabitethernet 1/0/2

[Device-GigabitEthernet1/0/2] nat server protocol tcp global 202.38.1.2 inside 192.168.1.4 ftp

# 在接口GigabitEthernet1/0/2上配置Easy IP方式的出方向动态地址转换,使得内网主机访问内网FTP服务器的报文可以使用接口GigabitEthernet1/0/2IP地址进行源地址转换。

[Device-GigabitEthernet1/0/2] nat outbound 2000

[Device-GigabitEthernet1/0/2] quit

# 在接口GigabitEthernet1/0/1上开启NAT hairpin功能。

[Device] interface gigabitethernet 1/0/1

[Device-GigabitEthernet1/0/1] nat hairpin enable

[Device-GigabitEthernet1/0/1] quit

验证配置

# 以上配置完成后,内网主机和外网主机均能够通过外网地址访问内网FTP Server。通过查看如下显示信息,可以验证以上配置成功。

[Device] display nat all

NAT outbound information:

  Totally 1 NAT outbound rules.

  Interface: GigabitEthernet1/0/2

    ACL: 2000

    Address group ID: ---

    Port-preserved: N    NO-PAT: N         Reversible: N

    Config status: Active

 

NAT internal server information:

  Totally 1 internal servers.

  Interface: GigabitEthernet1/0/2

    Protocol: 6(TCP)

    Global IP/port: 202.38.1.2/21

    Local IP/port : 192.168.1.4/21

    Rule name     : ServerRule_1

    NAT counting  : 0

    Config status : Active

 

NAT logging:

  Log enable          : Disabled

  Flow-begin          : Disabled

  Flow-end            : Disabled

  Flow-active         : Disabled

  Port-block-assign   : Disabled

  Port-block-withdraw : Disabled

  Alarm               : Disabled

  NO-PAT IP usage     : Disabled

 

NAT hairpinning:

  Totally 1 interfaces enabled with NAT hairpinning.

  Interface: GigabitEthernet1/0/1

    Config status: Active

 

NAT mapping behavior:

  Mapping mode : Address and Port-Dependent

  ACL          : ---

  Config status: Active

 

NAT ALG:

  DNS        : Enabled

  FTP        : Enabled

  H323       : Disabled

  ICMP-ERROR : Enabled

  ILS        : Disabled

  MGCP       : Disabled

  NBT        : Disabled

  PPTP       : Enabled

  RTSP       : Enabled

  RSH        : Disabled

  SCCP       : Disabled

  SCTP       : Disabled

  SIP        : Disabled

  SQLNET     : Disabled

  TFTP       : Disabled

  XDMCP      : Disabled

 

Static NAT load balancing:     Disabled

 

NAT link-switch recreate-session: Disabled

 

NAT configuration-for-new-connection: Disabled

# 通过以下显示命令,可以看到Host A访问FTP server时生成NAT会话信息。

[Device] display nat session verbose

Slot 1:

Initiator:

  Source      IP/port: 192.168.1.2/1694

  Destination IP/port: 202.38.1.2/21

  DS-Lite tunnel peer: -

  VPN instance/VLAN ID/Inline ID: -/-/-

  Protocol: TCP(6)

  Inbound interface: GigabitEthernet1/0/1

  Source security zone: Trust

Responder:

  Source      IP/port: 192.168.1.4/21

  Destination IP/port: 202.38.1.1/1025

  DS-Lite tunnel peer: -

  VPN instance/VLAN ID/Inline ID: -/-/-

  Protocol: TCP(6)

  Inbound interface: GigabitEthernet1/0/1

  Source security zone: Trust

State: TCP_ESTABLISHED

Application: FTP

Rule ID: -/-/-

Rule name:

Start time: 2017-06-15 14:53:29  TTL: 3597s

Initiator->Responder:            7 packets        308 bytes

Responder->Initiator:            5 packets        312 bytes

 

Total sessions found: 1

配置文件

#

interface GigabitEthernet1/0/1

 ip address 192.168.1.1 255.255.255.0

 nat hairpin enable

#

interface GigabitEthernet1/0/2

 ip address 202.38.1.1 255.255.255.0

 nat outbound 2000

 nat server protocol tcp global 202.38.1.2 21 inside 192.168.1.4 21

#

security-zone name Trust

 import interface GigabitEthernet1/0/1

#

security-zone name Untrust

 import interface GigabitEthernet1/0/2

#

acl basic 2000

 rule 0 permit source 192.168.1.0 0.0.0.255

#

security-policy ip

 rule 0 name trust-untrust

  action pass

  source-zone trust

  destination-zone untrust

 rule 1 name untrust-trust

  action pass

  source-zone untrust

  destination-zone trust

#