DNS_REQUEST

Description

Triggered when the system processes a DNS request.
When using this event in a GTM iRule, a GTM license must be enabled for it to work.
This event is only available for LTM in versions 11.0+ and requires either a GTM license or DNS Services addon license. When using this event in an LTM iRule a DNS profile must be enabled on the listener.
Note: This event triggers in both LTM and GTM iRules

Examples

when DNS_REQUEST {
  if { [IP::addr [IP::remote_addr] equals 10.10.1.0/24] } {
    cname cname.siterequest.com
  } else {
    host 10.20.20.20
  }
}

when DNS_REQUEST {
  # Changed = = 0 to < 1 for CR100063 / SOL10137
  if { [active_members pool_test] < 1 } {
    cname "something.domain.com"
  }
}

# Send one or more IP addresses for a response to an A query
# Use on an LTM virtual server with a DNS profile enabled
when DNS_REQUEST {
    # Log query details
    log local0. "\[DNS::question name\]: [DNS::question name],\
        \[DNS::question class\]: [DNS::question class],
        \[DNS::question type\]: [DNS::question type]"

    # Generate an answer with two A records
    DNS::answer insert "[DNS::question name]. 111 [DNS::question class] [DNS::question type] 1.1.1.1"
    DNS::answer insert "[DNS::question name]. 111 [DNS::question class] [DNS::question type] 1.1.1.2"

    # Stop further processing of the query after this iRule and send the answer to the client
    DNS::return
}