ltm rule event DNS REQUESTΒΆ

iRule(1)		      BIG-IP TMSH Manual		      iRule(1)



DNS_REQUEST
       Triggered when the system receives a DNS request.

DESCRIPTION
       Triggered when the system receives 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.

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
	    return
	}

HINTS
       Note: This event triggers in both LTM and GTM iRules

SEE ALSO
       https://devcentral.f5.com/wiki/iRules.GTM_return_LDNS_IP_to_client_.ashx
       - We do a lot of our load balancing based on topology rules.
       https://devcentral.f5.com/wiki/iRules.GTMSelectivePersistence.ashx -
       Provides a more granular persistence option for GTM

CHANGE LOG
       @BIGIP-9.2.2 --First introduced the event in GTM.  @BIGIP-11.0.0
       --First introduced the event in LTM.



BIG-IP				  2017-01-31			      iRule(1)