• 全部
  • 经验案例
  • 典型配置
  • 技术公告
  • FAQ
  • 漏洞说明
  • 全部
  • 全部
  • 大数据引擎
  • 知了引擎
产品线
搜索
取消
案例类型
发布者
是否解决
是否官方
时间
搜索引擎
匹配模式
高级搜索

NGFW盒式防火墙双向NAT配置实验

2020-02-28 发表
  • 0关注
  • 4收藏 3129浏览
吴超 九段
粉丝:8人 关注:0人

组网及说明

1-1实验组网

实验组网如图1-1所示,互联方式和IP地址分配见图。

PCA位于私网,网关为FWFW同时为NAT设备,有1个私网接口和1个公网地址,公网接口与公网路由器RT互联,PCB位于公网,网关为RT

配置步骤

本实验中,私网客户端PCA需要访问公网PCB,而RT上不能保有私网路由,因此将在FW上配置NAT Outbound,动态为PCA分配公网地址。

步骤一:搭建实验环境

依照图1-1搭建实验环境,配置内网主机的IP地址为192.168.1.2/24,外网主机PCBIP地址为10.10.1.2/24,防火墙G1/0/1G1/0/2IP地址为192.168.1.1/241.1.1.1/24

步骤二:基本配置

完成FWRT的路由、安全策略等基本配置。

FW的配置如下:

GE1/0/1GE1/0/2加入到安全域,并且配上IP地址,配置方法如下:

在导航栏中选择“网络>接口>接口”,进入“接口”配置页面,分别点击GE1/0/1GE1/0/2,右边<编辑>弹出“修改接口设置”配置窗口。


FW的命令行配置如下:


[FW] interface GigabitEthernet 1/0/1


[FW-GigabitEthernet1/0/1]ip address 192.168.1.1 24


[FW-GigabitEthernet1/0/1] interface GigabitEthernet 1/0/2


[FW-GigabitEthernet1/0/2]ip address 1.1.1.1 24


[FW-GigabitEthernet1/0/2]quit


RT的命令行的配置如下:


[RT]interface GigabitEthernet 0/1


[RT-GigabitEthernet0/0]ip address 1.1.1.2 24


[RT-GigabitEthernet0/0]quit


[RT]interface GigabitEthernet 0/2


[RT-GigabitEthernet0/1]ip address 10.10.1.1 24


[RT-GigabitEthernet0/1]quit


配置FW的缺省路由,指向公网,配置方法为:


在导航栏中选择“网络>路由>静态路由”,进入“IPv4静态路由”配置页面,点击左上角<新建>弹出“新建IPv4静态路由”配置窗口。


命令行的配置如下:


 ip route-static 0.0.0.0 0 1.1.1.2


配置全通的安全策略,配置方法如下:


在导航栏中选择“策略>安全策略>安全策略”,进入“安全策略”配置页面,点击左上角<新建>弹出“新建安全策略”配置窗口。

安全策略的命令行配置如下:


[FW]security-zone name trust


[FW -security-zone-Trust] import interface GigabitEthernet 1/0/1


[FW -security-zone-Trust]quit


[FW]security-zone name untrust


[FW -security-zone-Untrust] import interface GigabitEthernet 1/0/2


[FW -security-zone-Untrust]quit


 


[FW]security-policy ip


[FW -security-policy-ip]rule name web


[FW -security-policy-ip-0-web]source-zone trust


[FW -security-policy-ip-0-web]destination-zone untrust


[FW -security-policy-ip-0-web]source-zone untrust


[FW -security-policy-ip-0-web]destination-zone trust


[FW -security-policy-ip-0-web]action pass


[FW -security-policy-ip-0-web]source-zone local


[FW -security-policy-ip-0-web]destination-zone local


 


步骤一:配置正向NAT NAT Outbound


配置允许做NATACL,配置方法如下:


在导航栏中选择“对象>ACL>IPv4”,进入“IPv4 ACL组”配置页面,点击左上角<新建>弹出“新建IPv4ACL”配置窗口。



配置NAT地址池,配置方法如下:


在导航栏中选择“策略>NAT>NAT动态转换>NAT地址组”,进入“NAT地址组”配置页面,点击左上角<新建>弹出“新建NAT地址组”配置窗口。


配置出方向NAT,配置方法如下:


在导航栏中选择“策略>NAT>NAT动态转换>策略配置”,进入“NAT出方向动态转换(基于ACL)”配置页面,点击左上角<新建>弹出“新建NAT出方向动态转换”配置窗口。


由配置可见,在FW上配置了公网地址池1,地址范围是20.20.10.1~20.20.10.1。此时FW会对公网口上出方向匹配acl 2000的流量做地址转换。


命令行的相关配置如下:


[FW]acl basic 2000


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


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


 


[FW]nat address-group 1


[FW-address-group-1] address 20.20.10.1 20.20.10.1


[FW-address-group-1]quit


[FW]interface GigabitEthernet 1/0/2


[FW-GigabitEthernet1/0/2]nat outbound 2000 address-group 1


[FW-GigabitEthernet1/0/2]quit


步骤一:配置反向NAT(NAT Server)


本实验中,PCB可以通过访问公网地址1.1.1.1PCA通信。


在导航栏中选择“策略>NAT>NAT内部服务器>策略应用”,进入“NAT内部服务器”配置页面,点击左上角<新建>


FW上命令行的配置如下:


[FW]interface GigabitEthernet 1/0/2


[FW-GigabitEthernet1/0/2] nat server protocol icmp global current-interface inside 192.168.1.2


[FW-GigabitEthernet1/0/2]quit


 


步骤五:检查连通性


PCAping公网PCB,显示如下:


C:\Users\H3C>ping  10.10.1.2


正在 Ping 10.10.1.2 具有 32 字节的数据:


来自 10.10.1.2 的回复: 字节=32 时间<1ms TTL=128


来自 10.10.1.2 的回复: 字节=32 时间<1ms TTL=128


来自 10.10.1.2 的回复: 字节=32 时间<1ms TTL=128


来自 10.10.1.2 的回复: 字节=32 时间<1ms TTL=128


10.10.1.2 Ping 统计信息:


    数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失)


往返行程的估计时间(以毫秒为单位):


最短 = 0ms,最长 = 0ms,平均 = 0ms


结果显示PCAPCB之间可以通信。


步骤一:检查NAT表项


完成上一步后,立即在FW上检查NAT表项:


 [FW]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


          20.20.10.1            20.20.10.1


 


NAT outbound information:


  Totally 1 NAT outbound rules.


  Interface: GigabitEthernet1/0/2


    ACL: 2000


    Address group ID: 1


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


    NAT counting: 0


    Config status: Active


 


NAT internal server information:


  Totally 1 internal servers.


  Interface: GigabitEthernet1/0/2


    Protocol: 1(ICMP)


    Global IP/port: 1.1.1.1/---


    Local IP/port : 192.168.1.2/---


    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


 


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


  SIP        : Disabled


  SQLNET     : Disabled


  TFTP       : Disabled


  XDMCP      : Disabled


 


Static NAT load balancing:     Disabled


步骤二:查看会话信息


[FW]display nat session verbose


Slot 1:


Initiator:


  Source      IP/port: 192.168.1.2/260


  Destination IP/port: 10.10.1.2/2048


  DS-Lite tunnel peer: -


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


  Protocol: ICMP(1)


  Inbound interface: GigabitEthernet1/0/1


  Source security zone: Trust


Responder:


  Source      IP/port: 10.10.1.2/3


  Destination IP/port: 20.20.10.1/0


  DS-Lite tunnel peer: -


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


  Protocol: ICMP(1)


  Inbound interface: GigabitEthernet1/0/2


  Source security zone: Untrust


State: ICMP_REPLY


Application: ICMP


Rule ID: 0


Rule name: web


Start time: 2018-09-08 05:53:03  TTL: 29s


Initiator->Responder:            5 packets        420 bytes


Responder->Initiator:            5 packets        420 bytes


 


Initiator:


  Source      IP/port: 10.10.1.2/246


  Destination IP/port: 1.1.1.1/2048


  DS-Lite tunnel peer: -


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


  Protocol: ICMP(1)


  Inbound interface: GigabitEthernet1/0/2


  Source security zone: Untrust


Responder:


  Source      IP/port: 192.168.1.2/246


  Destination IP/port: 10.10.1.2/0


  DS-Lite tunnel peer: -


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


  Protocol: ICMP(1)


  Inbound interface: GigabitEthernet1/0/1


  Source security zone: Trust


State: ICMP_REPLY


Application: ICMP


Rule ID: 0


Rule name: web


Start time: 2018-09-08 05:53:01  TTL: 27s


Initiator->Responder:            5 packets        420 bytes


Responder->Initiator:            5 packets        420 bytes


Total sessions found: 2


  


通过查看NAT会话信息可以看出,对于内网用户PCA的地址192.168.1.2访问公网地址10.10.1.2时,源地址在公网出接口由NAT outbound转换成公网地址20.10.10.1,外网访问内网地址时,目的地址由NAT server配置映射成内网地址192.168.1.2


 


[FW]display session table ipv4 verbose


Slot 1:


Initiator:


  Source      IP/port: 10.10.1.2/247


  Destination IP/port: 1.1.1.1/2048


  DS-Lite tunnel peer: -


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


  Protocol: ICMP(1)


  Inbound interface: GigabitEthernet1/0/2


  Source security zone: Untrust


Responder:


  Source      IP/port: 192.168.1.2/247


  Destination IP/port: 10.10.1.2/0


  DS-Lite tunnel peer: -


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


  Protocol: ICMP(1)


  Inbound interface: GigabitEthernet1/0/1


  Source security zone: Trust


State: ICMP_REPLY


Application: ICMP


Rule ID: 0


Rule name: web


Start time: 2018-09-08 05:55:57  TTL: 29s


Initiator->Responder:            5 packets        420 bytes


Responder->Initiator:            5 packets        420 bytes


 


Initiator:


  Source      IP/port: 192.168.1.2/261


  Destination IP/port: 10.10.1.2/2048


  DS-Lite tunnel peer: -


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


  Protocol: ICMP(1)


  Inbound interface: GigabitEthernet1/0/1


  Source security zone: Trust


Responder:


  Source      IP/port: 10.10.1.2/4


  Destination IP/port: 20.20.10.1/0


  DS-Lite tunnel peer: -


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


  Protocol: ICMP(1)


  Inbound interface: GigabitEthernet1/0/2


  Source security zone: Untrust


State: ICMP_REPLY


Application: ICMP


Rule ID: 0


Rule name: web


Start time: 2018-09-08 05:55:56  TTL: 27s


Initiator->Responder:            5 packets        420 bytes


Responder->Initiator:            5 packets        420 bytes


Total sessions found: 2


查看防火墙会话也可以看到,PCA主动访问的ICMP报文中192.168.1.2被转换成了20.20.10.1的公网地址。PCB主动访问的报文中,目的地址1.1.1.1转换为了192.168.1.2


步骤三:查看debug信息。


两个PC进行互访做ping测试,开启debugging nat packet命令查看打印信息,可以看出ICMP报文首先达到配置的G1/0/2口,出方向源地址转换成公网地址,然后回程的报文匹配NAT会话进行目的地址转换,实现内网用户访问外部网络或者公网用户访问内部网络时隐藏了内部主机的源IP和公网用户的目的IP的功能。


debugging nat packet


terminal monitor


The current terminal is enabled to display logs.


terminal debugging


The current terminal is enabled to display debugging logs.


*Sep  8 06:09:49:049 2018 FW NAT/7/COMMON: -COntext=1;


 PACKET: (GigabitEthernet1/0/2-out-config) Protocol: ICMP


     192.168.1.2:  262 -       10.10.1.2: 2048(VPN:    0) ------>


      20.20.10.1:    5 -       10.10.1.2: 2048(VPN:    0)


*Sep  8 06:09:49:065 2018 FW NAT/7/COMMON: -COntext=1;


 PACKET: (GigabitEthernet1/0/2-in-session) Protocol: ICMP


       10.10.1.2:    5 -      20.20.10.1:    0(VPN:    0) ------>


       10.10.1.2:  262 -     192.168.1.2:    0(VPN:    0)


*Sep  8 06:09:55:440 2018 FW NAT/7/COMMON: -COntext=1;


 PACKET: (GigabitEthernet1/0/2-in-config) Protocol: ICMP


       10.10.1.2:  255 -         1.1.1.1: 2048(VPN:    0) ------>


       10.10.1.2:  255 -     192.168.1.2: 2048(VPN:    0)


*Sep  8 06:09:55:441 2018 FW NAT/7/COMMON: -COntext=1;


 PACKET: (GigabitEthernet1/0/2-out-session) Protocol: ICMP


     192.168.1.2:  255 -       10.10.1.2:    0(VPN:    0) ------>


         1.1.1.1:  255 -       10.10.1.2:    0(VPN:    0)


 


综上所述,双向NAT技术有效界定了用户所在网络的范围,保证了用户访问内网服务器的最佳快速访问路由走向,同时可以隐藏报文的源地址,使得内网服务器回应数据包也能按照最快速的路由达到客户端。双向NAT为内网主机访问外网服务器以及外网主机访问内网服务器提供了有效的技术支持。




配置关键点

如果要写详细的安全策略,应该如何放通?

 

答:NAT Outbound:放通内部私网地址访问外部公网地址;NAT Server:放通外部公网地址访问内部私网地址。



该案例对您是否有帮助:

您的评价:1

若您有关于案例的建议,请反馈:

1 个评论
粉丝:0人 关注:0人

想问一下,如果我不配置nat outbound,我配置nat inbound为什么不行?按理说

nat inbound已经转了源,也有转目的了,那就应该正常以防火墙接口地址为源,去访问server,再以server为源,防火墙接口地址为目的回包。nat outbound是出口接口时转源,nat inbound是进接口时转源,只是先后不同而已,最终还是转了源呀

编辑评论

举报

×

侵犯我的权益 >
对根叔知了社区有害的内容 >
辱骂、歧视、挑衅等(不友善)

侵犯我的权益

×

泄露了我的隐私 >
侵犯了我企业的权益 >
抄袭了我的内容 >
诽谤我 >
辱骂、歧视、挑衅等(不友善)
骚扰我

泄露了我的隐私

×

您好,当您发现根叔知了上有泄漏您隐私的内容时,您可以向根叔知了进行举报。 请您把以下内容通过邮件发送到zhiliao@h3c.com 邮箱,我们会尽快处理。
  • 1. 您认为哪些内容泄露了您的隐私?(请在邮件中列出您举报的内容、链接地址,并给出简短的说明)
  • 2. 您是谁?(身份证明材料,可以是身份证或护照等证件)

侵犯了我企业的权益

×

您好,当您发现根叔知了上有关于您企业的造谣与诽谤、商业侵权等内容时,您可以向根叔知了进行举报。 请您把以下内容通过邮件发送到 zhiliao@h3c.com 邮箱,我们会在审核后尽快给您答复。
  • 1. 您举报的内容是什么?(请在邮件中列出您举报的内容和链接地址)
  • 2. 您是谁?(身份证明材料,可以是身份证或护照等证件)
  • 3. 是哪家企业?(营业执照,单位登记证明等证件)
  • 4. 您与该企业的关系是?(您是企业法人或被授权人,需提供企业委托授权书)
我们认为知名企业应该坦然接受公众讨论,对于答案中不准确的部分,我们欢迎您以正式或非正式身份在根叔知了上进行澄清。

抄袭了我的内容

×

原文链接或出处

诽谤我

×

您好,当您发现根叔知了上有诽谤您的内容时,您可以向根叔知了进行举报。 请您把以下内容通过邮件发送到zhiliao@h3c.com 邮箱,我们会尽快处理。
  • 1. 您举报的内容以及侵犯了您什么权益?(请在邮件中列出您举报的内容、链接地址,并给出简短的说明)
  • 2. 您是谁?(身份证明材料,可以是身份证或护照等证件)
我们认为知名企业应该坦然接受公众讨论,对于答案中不准确的部分,我们欢迎您以正式或非正式身份在根叔知了上进行澄清。

对根叔知了社区有害的内容

×

垃圾广告信息
色情、暴力、血腥等违反法律法规的内容
政治敏感
不规范转载 >
辱骂、歧视、挑衅等(不友善)
骚扰我
诱导投票

不规范转载

×

举报说明

提出建议

    +

亲~登录后才可以操作哦!

确定

亲~检测到您登陆的账号未在http://hclhub.h3c.com进行注册

注册后可访问此模块

跳转hclhub

你的邮箱还未认证,请认证邮箱或绑定手机后进行当前操作