Technical Articles
F5 SMEs share good practice.
Showing results for 
Search instead for 
Did you mean: 
Community Manager
Community Manager

I love ingenuity.  DevCentral community member wassim asked a question a little more than a month ago that has been asked several times before: How do you build a class in GTM so you don’t have to use a hoard of if statements to account for your addresses?  Well, classes (datagroups) aren’t yet supported in GTM iRules, so the options have been sparse.  One option that could be utilized is to build a list that you can initialize in RULE_INIT:

   1: when RULE_INIT {
   2:     set addr_group1 [list \
   3:         "" \
   4:         "" \
   5:         "" \
   6:     ]
   7:     set addr_group2 [list \
   8:    "" \
   9:         "" \
  10:         "" \
  11:     ]
  12: }

This, while possible, is hardly ideal.  A few days ago, rather than drop the issue, wassim posted back with an alternative solution: Regions.  GTM Regions allows one to assemble groups of topology records, which once assembled, can be referenced from an iRule:

   1: when DNS_REQUEST {
   2:     if { [matchregion ldns addr_group1] } {
   3:         host
   4:     elseif { [matchregion ldns addr_group2] } {
   5:         host
   6:     } else {
   7:         host
   8:     }
   9: }

Still have if/else statements, but it will be trimmed down to as many regions as you have defined.  Nice work, wassim!

Related Articles
Looks like this post has been corrupted. Any chance of getting it restored? I'd really like to see how to implement classless classes in GTM.
Community Manager
Community Manager
All fixed up, sorry about that Robert!
Version history
Last update:
‎23-Mar-2011 14:47
Updated by: