穿越接口的 DNS 服务
穿越接口的 DNS 服务
网络需求

FortiGate 内网口(lan)开启 DNS 服务器,作为内部网络和 SSL VPN/IPSec VPN 客户端的 DNS 服务器。SSL VPN 客户端连接后,使用 FortiGate 内网口上提供的 DNS 服务进行域名解析。
在 FortiGate 上的“主 DNS 服务器”和“备用 DNS 服务器”均为公网的 DNS 服务器,如下所示。
config system dns set primary 223.5.5.5 set secondary 114.114.114.114 endFortiGate 仅在内网口上启用 DNS 服务器(递归方式)。
config system interface edit "lan" set ip 192.168.100.99 255.255.255.0 next end config system dns-server edit "lan" set mode recursive next endSSL VPN 配置分配的 DNS 服务器为 FortiGate 内网接口 IP 192.168.100.99。
config vpn ssl settings set servercert "Fortinet_Factory" set tunnel-ip-pools "sslvpn_pool" set dns-server1 192.168.100.99 <----设置分配的DNS服务器为FortiGate内网口地址 set source-interface "wan1" set default-portal "web-access" config authentication-rule edit 2 set groups "VPN" set portal "full-access" next end end防火墙策略、SSL VPN 门户、用户等配置略。
问题现象
FortiClient 客户端连接 FortiGate 的 SSL VPN 后,使用 FortiGate 内网口上提供的 DNS 服务器(192.168.100.99)无法进行域名解析。
::: important nslookup www.baidu.com ::: Server: 192.168.100.99 Address: 192.168.100.99#53 ;; connection timed out; no servers could be reached在 FortiGate 上抓包查看 FortiClient(3.3.3.9)发送的 DNS 请求,只有从
ssl.root接口进的流量,没有返回的流量。FortiGate # diagnose sniffer packet any 'host 3.3.3.9 and port 53' 4 interfaces=[any] filters=[host 3.3.3.9 and port 53] 0.614261 ssl.root in 3.3.3.9.65295 -> 192.168.100.99.53: udp 47 0.614514 ssl.root in 3.3.3.9.53355 -> 192.168.100.99.53: udp 47 1.660982 ssl.root in 3.3.3.9.65295 -> 192.168.100.99.53: udp 47 1.661521 ssl.root in 3.3.3.9.53355 -> 192.168.100.99.53: udp 47 1.793631 ssl.root in 3.3.3.9.56286 -> 192.168.100.99.53: udp 31在 FortiGate 上查看对应的 dnsproxy debug 信息,提示解析结果为
non-active。diagnose debug application dnsproxy -1 diagnose debug enable [worker 0] udp_receive_request()-3194: vd=0, vrf=0, intf=39, len=31, alen=16, 3.3.3.9:59503=>192.168.100.99 [worker 0] handle_dns_request()-2489: vfid=0 real_vfid=0 id=0x1aec pktlen=31 qr=0 req_type=3 [worker 0] dns_parse_message()-603 [worker 0] dns_nat64_ptr_lookup()-272 [worker 0] dns_nat64_ptr_lookup()-285: vdname:root request:256 [worker 0] dns_nat64_update_request()-305 [worker 0] dns_nat64_update_request()-319: vdname:root request:1 [worker 0] get_intf_policy()-1469: ifindex=39 [worker 0] dns_query_delete()-585: orig id:0x1aec local id:0x0000 domain=www.baidu.com use=5 non-active <----提示解析结果为non-active
解决方法
对于这种穿越接口之间提供 DNS 服务的场景,DNS 服务器接口的配置除了要添加提供 DNS 服务的接口(此例中为内网口
lan),还要添加 DNS 请求流量的入接口(此例中为内网口ssl.root)。config system dns-server edit "lan" set mode recursive next edit "ssl.root" set mode recursive next endFortiClient 客户端再次使用 FortiGate 内网口上提供的 DNS 服务器(192.168.100.99)进行域名解析,可以正常获取解析结果。
::: important nslookup www.baidu.com ::: Server: 192.168.100.99 Address: 192.168.100.99#53 Non-authoritative answer: Name: www.baidu.com Address: 110.242.70.57 Name: www.baidu.com Address: 110.242.69.21在 FortiGate 上查看对应的 dnsproxy debug 信息,显示 FortiGate 的内网口
lan收到 FortiClient(3.3.3.9)的 DNS 请求后,递归到公网 DNS 服务器 114.114.114.114 进行查询,并将 DNS 解析结果返回给 FortiClient(3.3.3.9)。diagnose debug application dnsproxy -1 diagnose debug enable [worker 0] udp_receive_request()-3194: vd=0, vrf=0, intf=39, len=31, alen=16, 3.3.3.9:59143=>192.168.100.99 [worker 0] get_intf_policy()-1469: ifindex=39 [worker 0] dns_local_lookup_common()-2553: vfid=0, real_vfid=0, view=2, qname=www.baidu.com, qtype=1, qclass=1, offset=31, map#=3 max_sz=512 [worker 0] dns_lookup_aa_zone()-608: vfid=0, fqdn=www.baidu.com [worker 0] dns_send_request()-1490 [worker 0] dns_send_resol_request()-1344: orig id: 0x95f3 local id: 0x95f3 domain=www.baidu.com [worker 0] dns_find_best_server()-652: found server: 114.114.114.114 (vfid=0 vrf=0) [worker 0] dns_udp_forward_request()-1089: vdom=root req_type=3 domain=www.baidu.com oif=0 [worker 0] dns_udp_forward_request()-1210: Send 31B to [114.114.114.114]:53 via fd=20 request:1 [worker 0] udp_receive_request()-3144 [worker 0] batch_on_read()-3555 [worker 0] _udp_receive_response()-3406: vd-0: len=63, addr=114.114.114.114:53, rating=0 [worker 0] dns_query_handle_response()-2743: vfid=0 real_vfid=0 vrf=0 id=0x95f3 domain=www.baidu.com pktlen=63 [worker 0] dns_query_save_response()-2724: domain=www.baidu.com pktlen=63 [worker 0] dns_set_min_ttl()-190: QR: www.baidu.com [worker 0] dns_set_min_ttl()-197: Offset of 1st RR: 31 Number of RR's: 2 [worker 0] dns_set_min_ttl()-218: RR TTL: 78, RR type: 1 [worker 0] dns_set_min_ttl()-218: RR TTL: 78, RR type: 1 [worker 0] dns_cache_response()-329: Min ttl = 78 [worker 0] dns_forward_response()-1720 [worker 0] dns_secure_forward_response()-1676: category=255 profile=none [worker 0] dns_visibility_log_hostname()-241: vd=0 pktlen=63 [worker 0] wildcard_fqdn_response_cb()-965: vd=0 pktlen=63 [worker 0] hostname_entry_insert()-143: af=2 domain=www.baidu.com [worker 0] hostname_entry_insert()-143: af=2 domain=www.baidu.com [worker 0] dns_send_response()-1645: domain=www.baidu.com reslen=63 [worker 0] __dns_udp_forward_response()-1522 [worker 0] __dns_udp_forward_response()-1533: vd-0 Send 63B via fd=7, family=2 [worker 0] __dns_udp_forward_response()-1537: set svf of fd to 0 [worker 0] __dns_udp_forward_response()-1587: vd=0 send 63B response 192.168.100.99:53=>3.3.3.9:59143 [worker 0] dns_query_delete()-585: orig id:0x95f3 local id:0x95f3 domain=www.baidu.com use=7 active [worker 0] dns_query_cleanup()-564: use=2
总结
- 对于这种穿越接口之间提供 DNS 服务的场景,如 FortiGate 不同 VLAN 之间、不同物理口之间、VPN 接口到内网口的 DNS 访问,均需要在 DNS 服务器接口配置中增加 DNS 请求流量的入接口。
- 从 FortiOS 7.6.1 开始,这种场景不再需要在 DNS 服务器上配置 DNS 请求的入接口。