Forum Discussion

Yugandhar's avatar
Yugandhar
Icon for Nimbostratus rankNimbostratus
Jul 18, 2018

Reason for iRule Execution Error

Hi

Multiple URLs are pointing to the same Virtual Server IP but persistence of 600 secs is needed only for a few of them.

Configured the below iRule and applied to the VS but got an Execution error.

===================

when HTTP_REQUEST {

                if { [string tolower [HTTP::host]] equals "access.testxyz45.com" or "abc.testxyz45.com" or "def.testxyz45.com" or "mail.testxyz45.com" } {

                      persist source_addr [IP::client_addr] 600


                } else { }    

}

=============

Could you please help as i am unable to figure out the error.

Thanks,

Yugandhar.

11 Replies

  • err tmm5[17765]: 01230140:3: RST sent from 10.16.240.15:443 to 192.168.25.56:49366, [0x2684cbf:1410] iRule execution error

     

  • You if statement is wrong, please try using this iRule, I've used a switch statement as it is less cluttered than several 'or' statements.

    when HTTP_REQUEST {
        switch -glob -[string tolower [HTTP::host]] {
            "access.testxyz45.com" -
            "abc.testxyz45.com" -
            "def.testxyz45.com" -
            "mail.testxyz45.com" {
                persist source_addr [IP::client_addr] 255.255.255.255 600
            }
        }
    }
    
  • Hi Yugandhar.

    You have a syntax problem. your condition need to be explicit for each value.

    you can't set one condition with multiple value. look what you should have done:

    if { [string tolower [HTTP::host]] equals "access.testxyz45.com" or [string tolower [HTTP::host]] equals  equals "abc.testxyz45.com" or [string tolower [HTTP::host]] equals  "def.testxyz45.com" or [string tolower [HTTP::host]] equals   "mail.testxyz45.com" } {
    
    persist source_addr [IP::client_addr] 600
    
    
    } else { }  
    

    By the way you have to optimise your irule by set your host variable:

    set host [string tolower [HTTP::host]]
    
    if { $host == "access.testxyz45.com" || $host  == "abc.testxyz45.com" || $host ==  "def.testxyz45.com" || $host == "mail.testxyz45.com" } {
    
    persist source_addr [IP::client_addr] 600
    
    } else { }  
    

    and finally you have to optimize his irula for his execution as shown by lee:

    when HTTP_REQUEST {
    set host [string tolower [HTTP::host]]
        switch -glob $host {
            "access.testxyz45.com" -
            "abc.testxyz45.com" -
            "def.testxyz45.com" -
            "mail.testxyz45.com" {
                persist source_addr [IP::client_addr]
            }
        }
    }
    
  • JG's avatar
    JG
    Icon for Cumulonimbus rankCumulonimbus

    Try this one to see if there is a difference:

    when HTTP_REQUEST {
        if { [string tolower [HTTP::host]] equals ( "access.testxyz45.com" or "abc.testxyz45.com" or "def.testxyz45.com" or "mail.testxyz45.com" ) } {
            persist source_addr [IP::client_addr] 600
        }
    }
    
  • Will go bit different way to solve issue. It will be easy to add more url in datagroup

    class
    . Lets try and update if working.

    class host_url {
        access.testxyz45.com
        abc.testxyz45.com
        def.testxyz45.com
        mail.testxyz45.com  
        }
    
        when HTTP_REQUEST {
           if { [matchclass [string tolower [HTTP::host]] equals host_url] } {
           persist source_addr 255.255.255.255 600
             persist source_addr [] [] -- DevCentral Syntax
           Link : https://devcentral.f5.com/wiki/iRules.persist.ashx
        }
    }
    

    I will request user to click iRule which working and solving issue. So that other can be refer.

    • Yugandhar's avatar
      Yugandhar
      Icon for Nimbostratus rankNimbostratus

      Hi F5_Rock,

      Thank you for providing the iRule, Can we use a Switch Statement instead of an If stmt.

      ===========

      class host_url {

      access.testxyz45.com
      
      abc.testxyz45.com
      
      def.testxyz45.com
      
      mail.testxyz45.com  
      
      }
      

      when HTTP_REQUEST {

      switch -glob -[string tolower [HTTP::host]] {
      
          host_url {
      
              persist source_addr 255.255.255.255 600
          }
      }
      

      }

      Thanks,

      Yugandhar.

    • Samir_Jha_52506's avatar
      Samir_Jha_52506
      Icon for Noctilucent rankNoctilucent

      Syntax is different for switch statement. @youssef has already provided switch iRule. Refer his iRule n let us know if any issue.

       

    • Yugandhar's avatar
      Yugandhar
      Icon for Nimbostratus rankNimbostratus

      Thank you .. I thought 'host_url' will be replaced with the values specified in the Data Group...So we can't refer a Data Group in the Switch Statement :)