CLI方式:外网用户通过域名访问内网服务器典型配置(地址不重叠)

使用版本

本举例是在M9000-AI-E8R9071版本上进行配置和验证的。

组网需求

如下图所示:

需要实现,外网主机可以通过域名访问内网的Web服务器。

图-1 外网用户通过域名访问内网服务器配置组网图(地址不重叠)

配置思路

配置步骤

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

# 开启DNS协议的ALG功能。

<Device> system-view

[Device] nat alg dns

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

[Device] acl basic 2000

[Device-acl-ipv4-basic-2000] rule permit source 10.110.10.2 0

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

# 创建地址组1

[Device] nat address-group 1

# 添加地址组成员202.38.1.3

[Device-address-group-1] address 202.38.1.3 202.38.1.3

[Device-address-group-1] quit

# 在接口GigabitEthernet1/0/2上配置NAT内部服务器,允许外网主机使用地址202.38.1.2访问内网DNS服务器。

[Device] interface gigabitethernet 1/0/2

[Device-GigabitEthernet1/0/2] nat server protocol udp global 202.38.1.2 inside 10.110.10.3 dns

# 在接口GigabitEthernet1/0/2上配置出方向动态地址转换,允许使用地址组1中的地址对DNS应答报文载荷中的内网地址进行转换,并在转换过程中不使用端口信息,以及允许反向地址转换。

[Device-GigabitEthernet1/0/2] nat outbound 2000 address-group 1 no-pat reversible

[Device-GigabitEthernet1/0/2] quit

验证配置

# 以上配置完成后,外网Host能够通过域名访问内网Web server。通过查看如下显示信息,可以验证以上配置成功。

[Device] display nat all

NAT address group information:

  Totally 1 NAT address groups.

  Address group ID: 1

    Port range: 1-65535

    Address information:

      Start address         End address

      202.38.1.3            202.38.1.3

    Exclude address information:

      Start address         End address

      ---                   ---

 

NAT outbound information:

  Totally 1 NAT outbound rules.

  Interface: GigabitEthernet1/0/2

    ACL: 2000

    Address group ID: 1

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

    Config status: Active

 

NAT internal server information:

  Totally 1 internal servers.

  Interface: GigabitEthernet1/0/2

    Protocol: 17(UDP)

    Global IP/port: 202.38.1.2/53

    Local IP/port : 10.110.10.3/53

    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 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访问Web server时生成NAT会话信息。

[Device] display nat session verbose

Slot 1:

Initiator:

  Source      IP/port: 200.1.1.2/1694

  Destination IP/port: 202.38.1.3/8080

  DS-Lite tunnel peer: -

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

  Protocol: TCP(6)

  Inbound interface: GigabitEthernet1/0/2

  Source security zone: Untrust

Responder:

  Source      IP/port: 10.110.10.2/8080

  Destination IP/port: 200.1.1.2/1694

  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: HTTP

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

配置文件

#

nat address-group 1

 address 202.38.1.3 202.38.1.3

#

interface GigabitEthernet1/0/1

 ip address 10.110.10.1 255.255.255.0

#

interface GigabitEthernet1/0/2

 ip address 20.2.2.1 255.255.255.0

 nat outbound 2000 address-group 1 no-pat reversible

 nat server protocol udp global 202.38.1.2 53 inside 10.110.10.3 53

#

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 10.110.10.2 0

#

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

#