fortios_dnsfilter_profile – Configure DNS domain filter profile in Fortinet’s FortiOS and FortiGate.

New in version 2.0.0.

Synopsis

  • This module is able to configure a FortiGate or FortiOS (FOS) device by allowing the user to set and modify dnsfilter feature and profile category. Examples include all parameters and values need to be adjusted to datasources before usage. Tested with FOS v6.0.0

Requirements

The below requirements are needed on the host that executes this module.

  • ansible>=2.15

Tips

Using member operation to add an element to an existing object.

FortiOS Version Compatibility

Supported Version Ranges: v6.0.0 -> 7.4.3

Parameters

  • access_token - Token-based authentication. Generated from GUI of Fortigate. type: str required: false
  • enable_log - Enable/Disable logging for task. type: bool required: false default: False
  • vdom - Virtual domain, among those defined previously. A vdom is a virtual instance of the FortiGate that can be configured and used as a different unit. type: str default: root
  • member_path - Member attribute path to operate on. type: str
  • member_state - Add or delete a member under specified attribute path. type: str choices: present, absent
  • state - Indicates whether to create or remove the object. type: str required: true choices: present, absent
  • dnsfilter_profile - Configure DNS domain filter profile. type: dict more...
    • block_action - Action to take for blocked domains. type: str choices: block, redirect, block-sevrfail more...
    • block_botnet - Enable/disable blocking botnet C&C DNS lookups. type: str choices: disable, enable more...
    • comment - Comment. type: str more...
    • dns_translation - DNS translation settings. type: list member_path: dns_translation:id more...
      • addr_type - DNS translation type (IPv4 or IPv6). type: str choices: ipv4, ipv6 more...
      • dst - IPv4 address or subnet on the external network to substitute for the resolved address in DNS query replies. Can be single IP address or subnet on the external network, but number of addresses must equal number of mapped IP addresses in src. type: str more...
      • dst6 - IPv6 address or subnet on the external network to substitute for the resolved address in DNS query replies. Can be single IP address or subnet on the external network, but number of addresses must equal number of mapped IP addresses in src6. type: str more...
      • id - ID. see Notes. type: int required: true more...
      • netmask - If src and dst are subnets rather than single IP addresses, enter the netmask for both src and dst. type: str more...
      • prefix - If src6 and dst6 are subnets rather than single IP addresses, enter the prefix for both src6 and dst6 (1 - 128). type: int more...
      • src - IPv4 address or subnet on the internal network to compare with the resolved address in DNS query replies. If the resolved address matches, the resolved address is substituted with dst. type: str more...
      • src6 - IPv6 address or subnet on the internal network to compare with the resolved address in DNS query replies. If the resolved address matches, the resolved address is substituted with dst6. type: str more...
      • status - Enable/disable this DNS translation entry. type: str choices: enable, disable more...
    • domain_filter - Domain filter settings. type: dict more...
      • domain_filter_table - DNS domain filter table ID. Source dnsfilter.domain-filter.id. type: int more...
    • external_ip_blocklist - One or more external IP block lists. type: list member_path: external_ip_blocklist:name more...
      • name - External domain block list name. Source system.external-resource.name. type: str required: true more...
    • ftgd_dns - FortiGuard DNS Filter settings. type: dict more...
      • filters - FortiGuard DNS domain filters. type: list member_path: ftgd_dns/filters:id more...
        • action - Action to take for DNS requests matching the category. type: str choices: block, monitor more...
        • category - Category number. type: int more...
        • id - ID number. see Notes. type: int required: true more...
        • log - Enable/disable DNS filter logging for this DNS profile. type: str choices: enable, disable more...
      • options - FortiGuard DNS filter options. type: list choices: error-allow, ftgd-disable more...
    • log_all_domain - Enable/disable logging of all domains visited (detailed DNS logging). type: str choices: enable, disable more...
    • name - Profile name. type: str required: true more...
    • redirect_portal - IPv4 address of the SDNS redirect portal. type: str more...
    • redirect_portal6 - IPv6 address of the SDNS redirect portal. type: str more...
    • safe_search - Enable/disable Google, Bing, YouTube, Qwant, DuckDuckGo safe search. type: str choices: disable, enable more...
    • sdns_domain_log - Enable/disable domain filtering and botnet domain logging. type: str choices: enable, disable more...
    • sdns_ftgd_err_log - Enable/disable FortiGuard SDNS rating error logging. type: str choices: enable, disable more...
    • transparent_dns_database - Transparent DNS database zones. type: list member_path: transparent_dns_database:name more...
      • name - DNS database zone name. Source system.dns-database.name. type: str required: true more...
    • youtube_restrict - Set safe search for YouTube restriction level. type: str choices: strict, moderate more...

Notes

Note

  • Legacy fortiosapi has been deprecated, httpapi is the preferred way to run playbooks

Examples

- name: Configure DNS domain filter profile.
  fortinet.fortios.fortios_dnsfilter_profile:
      vdom: "{{ vdom }}"
      state: "present"
      access_token: "<your_own_value>"
      dnsfilter_profile:
          block_action: "block"
          block_botnet: "disable"
          comment: "Comment."
          dns_translation:
              -
                  addr_type: "ipv4"
                  dst: "<your_own_value>"
                  dst6: "<your_own_value>"
                  id: "10"
                  netmask: "<your_own_value>"
                  prefix: "128"
                  src: "<your_own_value>"
                  src6: "<your_own_value>"
                  status: "enable"
          domain_filter:
              domain_filter_table: "0"
          external_ip_blocklist:
              -
                  name: "default_name_19 (source system.external-resource.name)"
          ftgd_dns:
              filters:
                  -
                      action: "block"
                      category: "0"
                      id: "24"
                      log: "enable"
              options: "error-allow"
          log_all_domain: "enable"
          name: "default_name_28"
          redirect_portal: "<your_own_value>"
          redirect_portal6: "<your_own_value>"
          safe_search: "disable"
          sdns_domain_log: "enable"
          sdns_ftgd_err_log: "enable"
          transparent_dns_database:
              -
                  name: "default_name_35 (source system.dns-database.name)"
          youtube_restrict: "strict"

Return Values

Common return values are documented: https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values, the following are the fields unique to this module:

  • build - Build number of the fortigate image returned: always type: str sample: 1547
  • http_method - Last method used to provision the content into FortiGate returned: always type: str sample: PUT
  • http_status - Last result given by FortiGate on last operation applied returned: always type: str sample: 200
  • mkey - Master key (id) used in the last call to FortiGate returned: success type: str sample: id
  • name - Name of the table used to fulfill the request returned: always type: str sample: urlfilter
  • path - Path of the table used to fulfill the request returned: always type: str sample: webfilter
  • revision - Internal revision number returned: always type: str sample: 17.0.2.10658
  • serial - Serial number of the unit returned: always type: str sample: FGVMEVYYQT3AB5352
  • status - Indication of the operation's result returned: always type: str sample: success
  • vdom - Virtual domain used returned: always type: str sample: root
  • version - Version of the FortiGate returned: always type: str sample: v5.6.3

Status

  • This module is not guaranteed to have a backwards compatible interface.

Authors

  • Link Zheng (@chillancezen)

  • Jie Xue (@JieX19)

  • Hongbin Lu (@fgtdev-hblu)

  • Frank Shen (@frankshen01)

  • Miguel Angel Munoz (@mamunozgonzalez)

  • Nicolas Thomas (@thomnico)

Hint

If you notice any issues in this documentation, you can create a pull request to improve it.