Forum Discussion

Arnor_Arnason's avatar
Icon for Altostratus rankAltostratus
May 23, 2011

How to answer a DNS SRV request in a irule on GTM


I know how I could answer an A request directly with an host ip in an irule:

  if { [IP::addr [IP::client_addr]/24 equals "] } {
    use pool GTM_pool1
  } elseif { ([DNS::rrtype] eq "A") and ([DNS::rrname] eq "") }

But what if I want to answer to a SRV request - what do I use instead of the 'host' keyword in the above ?

  if { [IP::addr [IP::client_addr]/24 equals "] } {
    use pool GTM_pool1
  } elseif { ([DNS::rrtype] eq "SRV") and ([DNS::rrname] eq "") }
      ?????? "1 0 5061"

I have searched through the wikis and references here - but I haven't found what to use ?

I'm pretty sure that this is something very simple, but everything I have tried in the irule editor has created an error when checking the syntax ?



6 Replies

  • Hello Arnor,


    Were you able to find a solution? If yes please share.


    Regards, Aref


  • Hi Aref,

    you may try the syntax below to intercept and respond to a specific SRV DNS query. It will also set authority information and additional records for the resolved SRV records to speed up DNS resolution (if supported by the DNS client).

    when DNS_REQUEST { 
        log local0. "\[DNS::question name\]: [DNS::question name], \[DNS::question class\]: [DNS::question class], \[DNS::question type\]: [DNS::question type]"
        set ttl 300
        if { [string tolower [DNS::question name]] starts_with "" } then { 
            if { [DNS::question type] equals "SRV" } then {
                 SOA information
                DNS::authority insert " $ttl IN SOA 1337 900 600 86400 3600"
                 SRV response
                DNS::answer insert "[DNS::question name]. $ttl IN [DNS::question type] 1 0 389"
                DNS::answer insert "[DNS::question name]. $ttl IN [DNS::question type] 1 0 389"
                 Additional records
                DNS::additional insert  " $ttl IN A"
                DNS::additional insert  " $ttl IN A"

    Note: The syntax can be used for v11.1+ LTM deployments.

    Cheers, Kai

  • Ahh brilliant Kai, thanks :-)


    I hadn't checked this again recently, and obviously not after version 11.1. At least I did not find this DNS::answer command back then.




  • Nice one +1 for Kai.

    In case you like to return a SOA record with an up-to-date serial number (reflecting current day, i.e. "2016051201" for 01 of 05/12/2016 [mm/dd/yyyy]) you can use the following:

    DNS::authority insert [DNS::rr "" SOA IN 60 " [clock format [clock seconds] -format {%Y%m%d01}] 10800 3600 604800 60"]