NAME::lookup

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.

Warning

This command has been deprecated with the release of version 15.1 in favor of the RESOLVER and DNSMSG namespaces.

Syntax

NAME::lookup <IP address>
NAME::lookup <hostname>
# In v10.1
NAME::lookup [@{IP|virtual name}] [{inet|inet6}] [-a|-aaaa|-txt|-mx|-ptr] <name>

NAME::lookup <IPaddress>

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

NAME::lookup <hostname>

  • 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 question, you will receive no response.

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
}