Forum Discussion

Jim_Mathers_131's avatar
Jim_Mathers_131
Icon for Nimbostratus rankNimbostratus
Jun 10, 2015

GTM iRule to return CNAMEs based on LB_SELECTED

Hello,

Just want to make sure my iRule beneath my signature is correct. My intent:

  1. If the GTM chooses server 1.1.1.1, return cname "foo1.bar.com".
  2. If the GTM chooses server 2.2.2.2, return cname "foo2.bar.com"
  3. If the GTM chooses another server not equal to 1.1.1.1 or 2.2.2.2, return that server's IP address directly to the LDNS client.

Will this work?

Thanks, Jim

when LB_SELECTED {

    if {[LB::server addr] equals "1.1.1.1"} {
        persist enable
        cname "foo1.bar.com"
    }
    elseif {[LB::server addr] equals "2.2.2.2"} {
        persist enable
        cname "foo2.bar.com"
    }
}
  • Something like this. Please try link.

            when DNS_REQUEST {
                 if { [IP::addr [IP::remote_addr] equals 10.10.1.0/32] } {
                     cname foo1.bar.com
                } elseif {[IP::addr [IP::remote_addr] equals 2.2.2.2/32] } {
                     cname foo2.bar.com
                      }
                }
    
    • Jim_Mathers_131's avatar
      Jim_Mathers_131
      Icon for Nimbostratus rankNimbostratus
      Hello Samir, Thank you for the answer. My intent is not to return CNAMEs based on DNS_REQUEST but instead to return a CNAME based on the Pool Member selected by the GTM, which is why I think the event LB_SELECTED is more appropriate. In your config, you are triggering on DNS_REQUEST, I need to trigger based on LB_SELECTED (I think). Thanks, Jim