Forum Discussion

PhillyPDXMike's avatar
PhillyPDXMike
Icon for Altocumulus rankAltocumulus
Nov 03, 2020

What is the syntax equivalentof RESOLV::lookup with the RESOLVER::name_lookup command?

With RESOLV::lookup being deprecated as of version 15.1 in favor of the RESOLVER and DNSMSG namespaces, I am not finding detailed enough documentation and examples to convert my 14.1 iRule to the new 15.1 syntax. My end goal is to do a reverse lookup (PTR) of the IP::client_addr against two internal DNS servers, then log it.

14.1 Syntax

when CLIENT_ACCEPTED {
 log local0. "The client source IP address is: [IP::client_addr]"
 log local0. "[IP::client_addr] resolves in DNS (server1) to [RESOLV::lookup @192.168.1.1 -ptr "[IP::client_addr]"]"
 log local0. "[IP::client_addr] resolves in DNS (server2) to [RESOLV::lookup @192.168.1.2 -ptr "[IP::client_addr]"]"
}
  • So this is a more object-orientated and scalable way of doing lookups - you can think of the response ($result) being a data object which you can then interrogate as you want to. Below is an example,

     

    when CLIENT_ACCEPTED {
      set result [RESOLVER::name_lookup "/Common/resolver1" [IP::client_addr PTR]
      log local0.debug "Response code: [ DNSMSG::header $result rcode ]"
      foreach rr { [RESOLVER::summarize $result] } {
        log local0.debug "Response from resolver1 for [IP::client_addr]: $rr"
      }
    }