1. 需求

用户有内网服务器和内网DNS,如下图所示



内网DNS服务器IP 192.168.11.123

内网域名为 test.com

内网OA服务器IP www.test.com    192.168.11.4

用户希望在FortiGate的内网接口上启用DNS转发功能,将Internet的域名解析转发到Internet的DNS服务器处理,将内网域名(test)的解析发送到内网DNS服务器处理。


2. 解决方案

这个需求有两种解决方法,一种是通过FortiGate的的NS记录方式,将test.com请求转发给内网DNS服务器。另外一种方法是通过FortiGate的forworder方式,将特定域转发给内网DNS服务器处理。



3. NS方案的配置方法

默认情况下DNS Database的功能是关闭的,我们需要先将其开启起来。找到System---Feature Select,然后找到DNS Database启用后,点击Apply的选项。



新建DNS区域“test.com”,设置域名也是“test.com”。将权威设置为“禁用”,这一点很重要。

然后新建一个A记录,主机名可以任意设置,本案例中设置为“ns1”,对应的IP地址为内网OA服务器“192.168.11.123”。

然后新建一个NS记录,设置主机名为A记录的主机名,本案例中为ns1。

配置方法如图:



命令行设置如下:

config system dns-database

edit "test.com"

set domain "test.com"

set authoritative disable

config dns-entry

edit 1

set hostname "ns1"

set ip 192.168.11.123

next

edit 2

set type NS

set hostname "ns1"

next

end

next

end

完成以上配置后,可以在FortiGate的内网接口上启用DNS转发,设置类型为“递归”。配置如图:



命令行设置如下:

config system dns-server

edit "internal"

set mode recursive

next

end

完成以上设置后,我们就可以实现访问Internet域名,则转发到Internet的DNS,访问test.com转发到内网DNS服务器。


4. forwarder配置方法

Forworder配置相对简单,主要在命令行下配置:

config system dns-database

edit "test.com"

set forwarder 192.168.11.123

set authoritative disable

next

end

然后在FortiGate的内网接口上启用DNS转发,设置类型为“递归”。配置如图:



命令行设置如下:

config system dns-server

edit "internal"

set mode recursive

next

end

完成以上设置后,我们就可以实现访问Internet域名,则转发到Internet的DNS,访问hytest.com转发到内网DNS服务器。


5. 常用的诊断工具

有两个命令比较常用:

“diagnose test application dnsproxy”,参数说明如下

FG90DP3Z13000115 # diag test app dnsproxy 

1 Clear DNS cache

2 Show stats

3 Dump DNS setting

4 Reload FQDN

5 Requery FQDN

6 Dump FQDN

7 Dump DNS cache

8 Dump DNS DB

9 Reload DNS DB

10 Dump secure DNS policy/profile

11 Reload Secure DNS setting

12 Show Hostname cache

13 Clear Hostname cache

14 DNS debug bit mask


如:FG90DP3Z13000115 # diag test app dnsproxy  2

config: alloc=1

DNS_CACHE: alloc=11, hit=1

DNS UDP: req=118 res=107 fwd=145 alloc=0 cmp=0 cur=44 

         switched=57100 v6_cur=0 v6_switched=0 to=7 

         ftg_res=0 ftg_fwd=0

DNS TCP: req=0, res=0, fwd=0, alloc=0, to=0

FQDN: alloc=6


另外一个命令可以跟踪诊断dnsproxy过程

diagnose debug enable

diagnose debug app dnsproxy -1