FortiGate
FortiGate Next Generation Firewall utilizes purpose-built security processors and threat intelligence security services from FortiGuard labs to deliver top-rated protection and high performance, including encrypted traffic.
Debbie_FTNT
Staff & Editor
Staff & Editor
Article Id 192412

Description

 

This article describes how to let a FortiGate access an internal DNS through a site-to-site IPsec VPN.

 

Scope

 

FortiGate, IPsec VPN.

Solution

 

In some circumstances, it is necessary to point the FortiGate to an internal DNS server.
If that internal DNS server is in a different location connected through an IPsec tunnel originating on the FortiGate, some configuration is required to let the FortiGate send DNS traffic through the tunnel properly.
This is necessary as by default, FortiGate uses an outgoing interface IP for traffic, and VPN interfaces do not usually have an IP.

Prerequisites:
Site-to-Site VPN fully configured with routing and policies.

There are two options to let a FortiGate access a DNS through a site-to-site VPN:

 

  1. Define a source-IP. This is the option requiring less configuration. The source IP has to be an interface on the FortiGate, and ideally the interface IP behind which is the local network that has access to the VPN in the first place.

As an example:

  • Local network: 10.0.0.0/24.
  • FortiGate port1 interface: 10.0.0.17.
  • Remote network: 172.16.0.0/24.
  • Remote DNS server: 172.16.0.250.
  • Local phase2 selector 10.0.0.0/24.\
  • Remote phase2 selector: 172.16.0.0/24.

 

In CLI, configure the following:


config sys dns
    set source-ip 10.0.0.17
    set primary 172.16.0.250
end

 

This allows the FortiGate to send traffic through the VPN utilizing source IP 10.0.0.17. No further configuration for phase2 selectors, policies, or routing is required, as FortiGate can rely on the existing setup.

If a different source-IP is selected, then:

  • The source IP needs to be added to phase2 selectors.
  • The source IP needs to be added to policies and routing on the remote side.


A downside to this setup is that should the VPN go down, the FortiGate will lose access to the DNS server entirely.
No public DNS server can be configured as a secondary server, as FortiGate is using the configured source-IP to send traffic out its WAN interface.
Only a local, internal DNS server works as a backup.

 

  1. Configure a transit network for the tunnelIn cases where FortiGate primarily uses an internal DNS, but have the option to fall back to a public DNS server, source IPs usually cannot be configured, as otherwise the FortiGate is using the (private) source IP to reach out to the public DNS server.


Under such circumstances, a transit network needs to be configured on the VPN directly, similarly to requirements for dynamic routing through a VPN tunnel.

The following needs to be configured:

DNS servers with primary internal and secondary public DNS servers, as an example:

 

config sys dns
    set primary 172.16.0.250
    set secondary 8.8.8.8
end

 

A transit network for the tunnel, not in use anywhere else (as an example, 192.168.255.0/30). Then IPs need to be configured on the tunnel interface:

 

config sys interface
    edit test2
        set ip 192.168.255.1/32
        set remote-ip 192.168.255.2/32
end

 

Add the configured subnet to the phase2 selectors on both ends and the configured IPs to any required policies on the remote side.
With the tunnel IPs configured, that means the FortiGate will use the tunnel-IP (192.168.255.1 in the example) to attempt to contact the internal DNS server.
For the public DNS server, use its WAN IP.

 

If still having the issue, check the sniffer:

 

diagnose sniffer packet any 'port 53 and host 172.16.0.250' 4 0 l

 

Ensure the traffic is going through the tunnel interface and not from the WAN interface.

 

If the FortiGate system DNS server is enabled in the SD-WAN default SLA 'Default_DNS', the traffic will be sent to the WAN interface instead of the tunnel.  

 

    config system sdwan

      config health-check

         edit "Default_DNS"
             set system-dns enable  <--------

             set members 4          <-------- Wan

         next 

      end

    end

 

Kernel route:

 

tab=254 vf=0 scope=0 type=1 proto=18 prio=0 10.0.0.17/255.255.255.255/0->172.16.0.250/32 pref=0.0.0.0 gwy=x.x.x.x dev=6 <-------- Wan

 

Ensure to disable 'set system-dns' and specify a DNS server on the Internet for the 'Default_DNS' SLA. 

 

    config system sdwan
        config health-check
            edit "Default_DNS"
                set system-dns disable
                set server "8.8.8.8" 

                set member 4
             next

        end

    end