Forum Discussion
multiple DNS::answers from a Datagroup
multiple DNS answers in an iRule
We're looking to implement transparent caching on our LTM/DNS F5s. We have a few DNS entries that we want to statically rewrite on the F5. I've written a sample iRule, so that if the DNS::question matches a Datagroup, the response comes from the Datagroup. That works just fine. But we have one particular answer that we want to return multiple answers for a single question, but I can't seem to make it work.
Here is a simplified version of the iRule for example:
when DNS_REQUEST {
if { [class match [DNS::question name] equals dns-static-list ] and [DNS::question type] equals "A"}{
DNS::answer insert "[DNS::question name]. 10 [DNS::question class] [DNS::question type] [lindex [class match value [DNS::question name] equals dns-static-list] 0]"
DNS::return
}
}
Obviously the Datagroups won't let you have multiple values tied to the same string, so that doesn't work. I've also tried separating values with a ":", but doesn't return a valid response. I suspect my irule needs much more sophistication to return multiple values, but I didn't see any code examples that I could use as a template.
- Stanislas_Piro2
Cumulonimbus
In the data group, use space as field separator.
use this irule:
when DNS_REQUEST { if { [DNS::question type] equals "A" && [class match [DNS::question name] equals dns-static-list ]}{ foreach val [class match -value [DNS::question name] equals dns-static-list] { DNS::answer insert "[DNS::question name]. 10 [DNS::question class] [DNS::question type] $val" } DNS::return } }
Note : Edited to solve class match format with dash missing
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com