Forum Discussion

Kannan_Thalaia1's avatar
Oct 08, 2020

iRule with multiple if condition Issue

Hello, I am very beginner to iRule creation. In GTM I tried to create irule as below. But getting error.

 

Our intention is we need to reroute the DNS query to different pool based on client IP and pool availability.

 

Appreciate any help on this.

 

when DNS_REQUEST {

 

if { [IP::addr [IP::client_addr] equals 10.222.152.101/32] or [IP::addr [IP::client_addr] equals 10.222.152.104/32]} and {[active_members LDAP_POOL1_PROD] > 0 } {

     then pool LDAP_POOL1_PROD

   } elseif { [IP::addr [IP::client_addr] equals 10.235.4.74/32] or [IP::addr [IP::client_addr] equals 10.235.4.75/32]} and {[active_members LDAP_POOL2_PROD] > 0 } {

      then pool LDAP_POOL2_PROD

   }

   else {

      pool LDAP_POOL3_PROD

     }

}

2 Replies

  • I have corrected the syntax only. Not checked any other conditions.

    when DNS_REQUEST {
    if { ([IP::addr [IP::client_addr] equals 10.222.152.101] or [IP::addr [IP::client_addr] equals 10.222.152.104]) and ([active_members LDAP_POOL1_PROD] > 0) } {
         pool LDAP_POOL1_PROD
       } elseif { ([IP::addr [IP::client_addr] equals 10.235.4.74] or [IP::addr [IP::client_addr] equals 10.235.4.75]) and ([active_members LDAP_POOL2_PROD] > 0) } {
          pool LDAP_POOL2_PROD
       }
       else {
          pool LDAP_POOL3_PROD
         }
    }