Forum Discussion

Javier_Fernand2's avatar
Javier_Fernand2
Icon for Nimbostratus rankNimbostratus
Jul 04, 2005

set Persist iRule to match across virtual server

I want to configure an iRule to set the persistence for 2 virtual server by source address affinity, I want that if the client's IP begins with 195.53.125.1* always goes to the same server. The virtual server are in the same IP but different port (one of then is http and the another is https). I have tried to config this with the following irule:

 

when HTTP_REQUEST {

 

if { [IP::client_addr] starts_with "195.53.125.1" } {

 

persist source_addr

 

}

 

 

But it doesn't work, when the client goes to one virtual server the persistence works on this virtual server but when the clients goes to the other virtual server the persistence changes for it. In other words, the persistence iRule is working on each virtual server but it doesn't match across both virtual server. I don't know how I have to write the iRule to set the paramether "Match across Virtual Server".

 

 

 

Do you know how can I config it? Do you know how can I write the irule to Match the persistence acroos virtual server?

 

 

 

Thanks
  • unRuleY_95363's avatar
    unRuleY_95363
    Historic F5 Account
    You simply need to configure a persist profile of type source address and check the "across virtuals" box. Then add this profile to the virtual server. It will act as the default. Then, when you don't want to persist based on source address, you'll need to invert your logic in your rule and execute a "persist none" statement. For example:

     
     if { not ( [IP::client_addr] starts_with "195.53.125.1" ) } { 
        persist none 
     } 
     

  • Firstly thanks for your answer.

     

    But I forgot to say that I have set one persist profile by cookie for 2 virtual Servers, and I want to change or use only different persist method in that case.

     

     

    Regards,
  • unRuleY_95363's avatar
    unRuleY_95363
    Historic F5 Account
    That's ok. You should still be able to handle it similarly. You will likely still want to create a source address persist profile with the "across virtuals" box checked and assign it to the virtual. Then you would use a rule more like this:

     
        if { not ( [IP::client_addr] starts_with "195.53.125.1" ) } { 
           persist cookie insert "MyCookieName" 
        } 
     

    The available syntaxes for the "persist cookie" command are:

    persist cookie

    persist cookie insert ?"name"? ??

    persist cookie rewrite ?"name"? ??

    persist cookie passive ?"name"?

    persist cookie hash "name" ?{ ?? } ???

    ?? denotes an optional argument.

    is of the format: "d ::" or simply ""

    You can assign both persist profiles to the virtual on the command line or in the bigip.conf file (the first one listed is the default), however the GUI does not support this. Then you can use your rule to simply select between the persistence types and you don't need to specify all the characteristics in the rule.

    Hope this helps.