目的NAT简介
目的NAT是指对报文中的目的地址和端口进行转换。
通过目的NAT技术将公网IP地址转换成私网IP地址,使公网用户可以利用私网地址访问内部Server。转换过程如图1所示。
当外网用户访问内部Server时,FW的处理过程如下:
- 当外网用户访问内网Server的报文到达FW时,FW将报文的目的IP地址由公网地址转换为私网地址。
- 当回程报文返回至FW时,FW再将报文的源地址由私网地址转换为公网地址。
根据转换后的目的地址是否固定,目的NAT分为静态目的NAT和动态目的NAT。
组网需求
某公司在网络边界处部署了FW作为安全网关。为了使服务器能够对外提供不同的服务,需要在FW上配置目的NAT。除了公网接口的IP地址外,公司还向ISP申请了一个IP地址(1.1.10.10)作为内网服务器对外提供服务的地址。网络环境如图1所示,其中Router是ISP提供的接入网关。
拓扑图
防火墙基本配置
<USG6000V1>system-view
[USG6000V1]sysname FW1
[FW1]interface GigabitEthernet 1/0/1
[FW1-GigabitEthernet1/0/1]ip address 10.2.0.1 24
[FW1-GigabitEthernet1/0/1]q
[FW1]interface GigabitEthernet 1/0/2
[FW1-GigabitEthernet1/0/2]ip address 1.1.1.1 24
[FW1-GigabitEthernet1/0/2]q
将接口加入DMZ区域。
[FW1]firewall zone dmz
[FW1-zone-dmz]add interface GigabitEthernet 1/0/1
[FW1-zone-dmz]q
将接口加入untrust区域。
[FW1]firewall zone untrust
[FW1-zone-untrust]add interface GigabitEthernet 1/0/2
[FW1-zone-untrust]q
配置安全策略,允许外部网络用户访问内部服务器。
[FW1-policy-security]rule name untrust-2-DMZ
[FW1-policy-security-rule-untrust-2-DMZ]destination-zone dmz
[FW1-policy-security-rule-untrust-2-DMZ]destination-address 10.2.0.0 24
[FW1-policy-security-rule-untrust-2-DMZ]action permit
[FW1-policy-security-rule-untrust-2-DMZ]q
[FW1-policy-security]q
地址池
[FW1]destination-nat address-group bdqn1
[FW1-dnat-address-group-bdqn1]section 10.2.0.9 10.2.0.9
配置NAT策略
[FW1-policy-nat]rule name dnat2
[FW1-policy-nat-rule-dnat2]source-zone untrust
[FW1-policy-nat-rule-dnat2]destination-address 1.1.10.12 32
[FW1-policy-nat-rule-dnat2]service protocol tcp destination-port 2000 to 2001
[FW1-policy-nat-rule-dnat2]action destination-nat static port-to-port address-gr
oup bdqn1 80 to 81
R1基本配置
<Huawei>system-view
[Huawei]sysname R1
[R1]interface GigabitEthernet 0/0/0
[R1-GigabitEthernet0/0/0]ip address 1.1.1.254 24
[R1-GigabitEthernet0/0/0]q
[R1]interface GigabitEthernet 0/0/1
[R1-GigabitEthernet0/0/1]ip address 172.16.1.254 24
[R1-GigabitEthernet0/0/1]q
写两条通往服务器的路由
[R1]ip route-static 1.1.10.12 32 1.1.1.1
FTP 配置2001端口
http的端口2000
防火墙查询会话表
可以看到http 和 tcp 的结果