Forum Discussion
GTM iRule to set different TTL for each RR
Hi,
In our GTMs, I have the requirement to set manually the TTL timeout for a wide-IP,let's call it www.example.com (it is within our enterprise not in the internet), based on RTT and static methods:
- First run the RTT method (and set TTL 60sec on the DNS answer)
- If not working or not already evaluated, use the first DC as DNS answer static (with TTL 30sec)
- And finally if the first DC is dead, try with randomly the other 2 DCs (with TTL 20sec)
I realized that this cannot be done but with a GTM iRule, using something like this:
https://devcentral.f5.com/wiki/iRules.DNS__ttl.ashx
As i never wrote GTM iRuls, would you be able to give me some starting hint how to write this?
GIulio.
4 Replies
- Mohamed_Lrhazi
Altocumulus
it sounds like the logic is to be implemented by GTM itself (pools and load balancing methods on the wideip and pool), not the iRule. Then the iRule would inspect the decided answer and modify its TTL based on which DC the answer is for... you probably could not tell from an iRule what LB method was used, but you could just set the default TTL to 60 seconds.
Hi, ok thanks for the answer.
But what is the iRule function to be used for specifying the results coming from the RTT.
Can somebody help me to write something like that?
when DNS_response {
if {the result from RTT method is there}
ttl = 60 else { answer with DC_first ttl == 30 } if (all DCs not available) { return DC_random ttl = 20 }}
This is the example i found in the wiki. But it doesnt cover the situation of DNS::answer == "use the RTT method" function.
when DNS_RESPONSE { set rrs [DNS::answer] foreach rr $rrs { DNS::ttl $rr 60 } }- Mohamed_Lrhazi
Altocumulus
You need to inspect the DNS answer records, and make decisions about the TTL to set, based on the IP addresses in those DNS answers, right? In the sample iRule you post, you see how you can access the list of RRs in the answer, and how to loop tru them, right? you get one RR in a variable named $rr, then you can dissect that record like so: [DNS::name $rr] [DNS::ttl $rr] [DNS::class $rr] [DNS::type $rr] [DNS::rdata $rr] I guess the record type needs to be "A", then the rdata would be a list of IP addresses? I would right the iRule to just log all those fields and learn how to parse it out from there....
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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