Forum Discussion

Albert__Tase_70's avatar
Albert__Tase_70
Icon for Nimbostratus rankNimbostratus
Jan 11, 2010

need somew help setting persistance with irule

Basically they want to match urls and then apply source_address persistance I used contains and the or statement and used

 

 

when HTTP_REQUEST {

 

if { ([HTTP::uri] contains "x") or ([HTTP::uri] contains "y") or ([HTTP::uri] contains "z") or ([HTTP::uri] contains "a") or ([HTTP::uri] contains "b") or ([HTTP::uri] contains "c") or ([HTTP::uri] contains "d") or ([HTTP::uri] contains "e"}{

 

persist source_addr 300

 

 

}

 

}

 

 

just not seem to presist is the presist command correct?

 

or should I use startwith instead of contains ?

 

 

 

Thanks
  • Hi Albert,

     

    You can certain rewrite you code to the following

     

     

     
     when HTTP_REQUEST { 
        switch -glob [HTTP::uri] { 
       "*x*" - 
       "*y*" - 
       "*a*" - 
       "*b*" - 
       "*c*" - 
       "*d*" - 
       "*e*" - { persist source_addr 300 } 
        } 
     } 
     

     

     

    I hope this helps

     

     

    Bhattman

     

  • How can I set up logging on this rule to verify its firing and setting persistance ?

     

     

     

    Thanks

     

     

    Al Tase
  • Hi All

    Here is a log syntax to see if it's matching or not.

     
      when HTTP_REQUEST {  
         switch -glob [HTTP::uri] {  
        "*x*" -  
        "*y*" -  
        "*a*" -  
        "*b*" -  
        "*c*" -  
        "*d*" -  
        "*e*" - {  
                 persist source_addr 300  
                 log local0. "Matching" 
                  } 
         Default { 
                  log local0. "Not matching" 
                   }  
          }  
      }  
      

    Bhattman
  • nbeed more help with the logging need to be able to return the source ip when it matches and need to be able to log the url when it matches and dose not match is this possible ?

     

     

     

     

     

    Thanks
  • This might work for you:

       
      when HTTP_REQUEST {    
           switch -glob [HTTP::uri] {    
          "*x*" -    
          "*y*" -    
          "*a*" -    
          "*b*" -    
          "*c*" -    
          "*d*" -    
          "*e*" - {    
                   persist source_addr 300    
                   log local0. "Matching [IP::client_addr] on [HTTP::uri]"   
                    }   
           Default {   
                    log local0. "Not matching [HTTP::uri]"   
                     }    
            }    
        }