ltm rule command DNS returnΒΆ

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

DNS::return
       Skips all further processing after TCL execution and sends the DNS packet in the opposite direction.

SYNOPSIS
       DNS::return

DESCRIPTION
       This iRules command skips all further processing after TCL execution and sends the DNS packet in the opposite direction.
       In the DNS_REQUEST context, DNS::return signals that no further DNS resolution should occur for this request upon
       completion of the event.  To provide a useful response, resource record and header changes must be made in the iRule. The
       next event triggered is the DNS_RESPONSE event.	In the DNS_RESPONSE context, DNS::return sends a request back for
       additional processing. This is typically done after the answer, authority and additional sections have been cleared and the
       query changed to obtain a different response. Great care must be taken to avoid an infinite loop, which can easily occur if
       the query is not changed before being returned to the resolver.	In both contexts, the use of DNS::return signals what to
       do after the event has completed, but does not stop processing the current event.

       Note: This command should not be confused with the global command return which immediately exits the current event.

       Note: This command functions only in the context of LTM iRules and requires the DNS Profile, which is only enabled as part
       of GTM or the DNS Services add-on.

       Syntax

       DNS::return

	    * Skips all further processing after TCL execution and sends the dns
	      packet in the opposite direction.

RETURN VALUE
VALID DURING
       DNS_REQUEST, DNS_RESPONSE

EXAMPLES
	# 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
SEE ALSO
CHANGE LOG
       @BIGIP-11.1.0 --First introduced the command.

BIG-IP							    2022-04-12							  iRule(1)