Forum Discussion

Jeff_92092's avatar
Jeff_92092
Icon for Nimbostratus rankNimbostratus
Feb 22, 2012

How to inherit a generic irules?

 

Hi, Guys. I am new to the irules business. Please help.

 

 

I need to create hundreds of irule on GTM box like below. (one rule for each webserver). the only difference will be name of the webservers.

 

 

when DNS_REQUEST {

 

if {[DNS::rrtype] eq "A" and [active_members webserver1-pool] > 0} {

 

pool webserver1-pool

 

} elseif {[DNS::rrtype] eq "AAAA" and [active_members webserver1-pool-v6]> 0} {

 

pool webserver1-pool-v6

 

}

 

}

 

 

 

Now I have a generic-v6-irules accepted by the GTM TMOS

 

when DNS_REQUEST {

if {[DNS::rrtype] eq "A" and [active_members $pool4] > 0} {

 

pool $pool4

 

} elseif {[DNS::rrtype] eq "AAAA" and [active_members $pool6] > 0} {

 

pool $pool6

 

}

 

}

 

 

How can I write the rule to inherit this generic-v6-irules so I can get the equivalent like the first irule? any suggestions? Thanks in advance!

 

 

 

2 Replies

  • Hamish's avatar
    Hamish
    Icon for Cirrocumulus rankCirrocumulus
    I think I see what youre after. Use a datagroup as a lookup table. You use the webserver as the key and the pool as the value (Or you could encode several parameters in the value as for example colon delimited). The class command then does the lookup for you.

     

     

    H
  • Here is an easy solution which works perfectly to my expection.

     

     

    Create 1 irules for each webserver

     

    server1-rules

     

    when DNS_REQUEST {

     

    set pool4 "server1-pool-v4"

     

    set pool6 "server1-pool-v6"

     

    }

     

     

     

    I already created generic-v6-irules

     

    when DNS_REQUEST {

     

    if {[DNS::rrtype] eq "A" and [active_members $pool4] > 0} {

     

    pool $pool4

     

    } elseif {[DNS::rrtype] eq "AAAA" and [active_members $pool6] > 0} {

     

    pool $pool6

     

    }

     

    }

     

     

    Then apply both server1-rules and generic-v6-irules to the wide IP.

     

    (server1-rules needs to be in front of generic-v6-irules. so pool4 and pool6 are defined)