ltm rule command NAME lookupΒΆ

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

NAME::lookup
       Deprecated: Performs DNS query for A or PTR record corresponding to a hostname or IP address.

SYNOPSIS
DESCRIPTION
       Performs a DNS query, typically returning the A record for the indicated hostname, or the PTR record for the indicated IP
       address.

       Starting in v10.1, the RESOLV::lookup command has been introduced, which is the inline version of this command. With
       RESOLV::lookup, the iRule execution will suspend and the result will be simply returned, whereas NAME::lookup continues and
       eventually causes NAME_RESOLVED to fire, where the NAME::response command can be used to retrieve the lookup result.

       NAME::lookup  Performs DNS query, returning the PTR record (hostname) for the indicated IP address. Only a
       single address should be returned.

       NAME::lookup  Performs DNS query, returning the A record (address) for the indicated hostname. If no record is
       found, a blank string is returned. Multiple addresses may be returned in a tcl list format.

       If you do not include the @{IP/Virtual Name} argument, local bind will be the target of the query. If your local bind is
       not set up to query recursively, and is not authoritative for the domain in question, you will receive no response.

RETURN VALUE
       Typically returning the A record for the indicated hostname, or the PTR record for the indicated IP address.

VALID DURING
       ANY_EVENT

EXAMPLES
	# Reverse resolution - get PTR (hostname) for an IP address (Note: Not all names have corresponding PTR records. Reverse resolutions are easily spoofed not guaranteed to be correct) Logs a line reading "client name = >10.10.10.1<" if resolved or "client name = ><" if not:
	when HTTP_REQUEST {
	   # Hold HTTP data until hostname is resolved
	   HTTP::collect

	   # Start a name resolution on the hostname
	   NAME::lookup [IP::client_addr]
	}
	when NAME_RESOLVED {
	   log local0. "client name = >[NAME::response]<"

	   # Release HTTP data once hostname is resolved
	   HTTP::release
	}

	# Forward resolution - get IP address for hostname. Logs the following for resolution returning 3 addresses: "IP address list for remotehost.domain.com = >{10.10.10.1 10.10.10.2 10.10.10.3}<" "First listed address is >10.10.10.1<" "Second listed address is >10.10.10.2<"
	when HTTP_RESPONSE {

	   # Hold HTTP data until IP address is resolved
	   HTTP::collect

	   # Start a name resolution on the hostname
	   NAME::lookup remotehost.domain.com
	}
	when NAME_RESOLVED {

	   log local0. "IP address list for remotehost.domain.com = >[NAME::response]<"
	   log local0. "First listed address is >[lindex [NAME::response] 0]<"
	   log local0. "Second listed address is >[lindex [NAME::response] 1]<"

	   # Release HTTP data once hostname is resolved
	   HTTP::release
	}

HINTS
SEE ALSO
       Block requests by reverse DNS record  - Performs a reverse DNS lookup to
       validate client IP Destination Snat Using DNS  - This
       iRule selects a snatpool based on which virtual called the iRule. and will select the member servers to use based on DNS
       resolution.

CHANGE LOG
       @BIGIP-9.0.0 --First introduced the command.  @BIGIP-10.1.0 --Introduce AT_SERVER, inet, inet6 and -a/-aaaa/-txt/-mx/-ptr
       options.  @BIGIP-15.1.0 --Deprecated in favor of RESOLVER and DNSMSG namespaces

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