转换 DNS 解析结果
2025/10/29大约 2 分钟
转换 DNS 解析结果
DNS Translation 功能用于将穿越 FortiGate 的 DNS 解析结果替换为指定的结果。
具体适用场景请见如下网络拓扑与说明。
网络拓扑

- DNS 服务器位于 Internet,内网 PC 填写的 DNS 服务器均为公网 DNS 服务器的 IP 223.5.5.5。
- FortiGate 通过 VIP 将 Server 的端口映射到 WAN1(port1)的 202.103.12.2。
- Server 的域名为
www.fortitest.com,通过公网 DNS 服务器解析的结果为 202.103.12.2。 - 需要实现的效果:
- 外网客户端访问 Server 时,直接通过
www.fortitest.com解析到公网 IP 202.103.12.2,通过 FortiGate 的 VIP 映射访问即可。 - 内网客户端访问 Server 时,首先通过公网的 DNS 服务器 223.5.5.5 解析
www.fortitest.com的 IP 地址,DNS Server 会回复解析结果为 202.103.12.2,FortiGate 需要将解析结果修改为 Server 的内网 IP 10.10.2.100,然后转发给内网客户端,内网客户端直接通过解析到的 Server 内网 IP 访问服务器。
- 外网客户端访问 Server 时,直接通过
配置步骤
基础网络配置、上网策略、与 Server 的 VIP 配置(略)。
在 FortiGate 上配置 DNS Translation,将 DNS 请求结果为 202.103.12.2 的 DNS 响应报文中的 IP 地址修改为 Server 的内网 IP 10.10.2.100。
config firewall dnstranslation edit 1 set src 202.103.12.2 set dst 10.10.2.100 next end
结果验证
公网客户端 PC 使用 DNS 服务器 223.5.5.5 解析 Server 的域名(流量不经过 FortiGate),得到结果为 Server 对应的 VIP 地址 202.103.12.2。
C:\Users\Administrator.SUMMERICE2019>nslookup www.fortitest.com 服务器: public1.alidns.com Address: 223.5.5.5 非权威应答: 名称: www.fortitest.com Address: 202.103.12.2内网客户端 PC 使用 DNS 服务器 223.5.5.5 解析 Server 的域名(流量经过 FortiGate),得到结果为 Server 内网 IP 10.10.2.100。
C:\Users\Administrator.SUMMERICE2019>nslookup www.fortitest.com 服务器: public1.alidns.com Address: 223.5.5.5 非权威应答: 名称: www.fortitest.com Address: 10.10.2.100