Forum Discussion

teknet7_237497's avatar
teknet7_237497
Icon for Nimbostratus rankNimbostratus
Dec 14, 2015

iRule: persist uie "$var1:$var2"

Hello Team,

I have just found i can create persistence entry using two variables example:

persist uie "$var1:$var2"

But not sure how can later use it.

Is it possible to hit it if matching $var1 OR $var2 ? Or maybe i have to match both $var1 AND $var2 ?

How it works ? Do i have any control over that ?

I need to have "OR" logic because subsequent flows/protocols might not contain both - but just one matching attribute/variable.

Thanks, Michal

19 Replies

  • Hi Stephan,

     

    Yes have confirmed all of that. I am using just one pool member right now. Radius client is my own code (http://sourceforge.net/projects/radiustest/) - i am sending just a single Access-Request with 11:11:11:11:11:11 as calling-station-id and 1.2.3.4 as framed-ip-address and getting the result:

     

    : session table entry added: 
    : session table lookup result for calling station ID of 11:11:11:11:11:11: 172.16.34.100
    : lookup match: 172.16.34.100
    : session table entry added: 

    That is with the following irule:

     

    when LB_SELECTED {
        log local0. "session table entry added: "
        session add uie "persist:[RADIUS::avp 31]" [LB::server addr]
    }
    
    when CLIENT_DATA {
       log local0. "session table lookup result for calling station ID of [RADIUS::avp 31]: [session lookup uie "persist:[RADIUS::avp 31]"]"
        if {[session lookup uie "persist:[RADIUS::avp 31]"] ne ""} {
           log local0. "lookup match: [session lookup uie "persist:[RADIUS::avp 31]"]"
           node [session lookup uie "persist:[RADIUS::avp 31]"]
           log local0. "session table entry added: "
           session add uie "persist:[RADIUS::avp 8]" [IP::remote_addr]
       }
    }

    Logs looks nice but how can i check the results ? Persistence and sys connection tables are empty. And i do suspect it's not working correctly because if i add a second member to the pool (172.16.34.101), and send two identical radius packets the second one is going to the second pool member:

     

    : session table entry added: 
    : session table lookup result for calling station ID of 11:11:11:11:11:11: 172.16.34.101

    So it looks like there is no session and we always start a new session and adding new session table entry (using session add from LB_SELECTED) instead of reusing the same node for which we do have that session already.

     

    Also why we do use "node" in CLIENT_DATA if that is displayed by the logs after LB_SELECTED ? Should not we stick/persistent the session before we do create persistence entry/session entry (to be sure we do hit the one which was created previously) ?

     

    Thanks, Michal

     

    • StephanManthey's avatar
      StephanManthey
      Icon for MVP rankMVP
      Hi Michal, please change the rule for accounting as follows by replacing the line of: session add uie "persist:[RADIUS::avp 8]" [IP::remote_addr] with the following: session add uie "persist:[RADIUS::avp 8]" [session lookup uie "persist:[RADIUS::avp 31]"] Now a new table entry will be created using the "persist:(framed-ip)" as key with a value of the pool member IP. This table entry will be used by a third iRule associated with your virtual server for web: when HTTP_REQUEST { log local0. "session table lookup result for web client of [IP::client_addr]: [session lookup uie "persist:[IP::client_addr]"]" if {[session lookup uie "persist:[IP::client_addr]"] ne ""} { node [session lookup uie "persist:[IP::client_addr]"] } } Assuming the client with the IP address matching the framed IP found in RADIUS will send a http request. Now the session table will be looked up for a key matching "persist:(web-client-ip)". The entry will be found and the value retrieved to pick the right pool member. Thanks, Stephan PS: Edited to fix formatting ...
    • Joad's avatar
      Joad
      Icon for Nimbostratus rankNimbostratus

      Hello,

       

      is it also possible to create a persistence iRule based on both Calling-station-ID and Audit-Session-ID ?

       

      Thanks in advance

       

      Regards

       

    • RaghavendraSY's avatar
      RaghavendraSY
      Icon for Altostratus rankAltostratus

      Try below iRules:

       

      With client IP and HTTP host:

       

      when HTTP_REQUEST { persist uie "[IP::client_addr]:[HTTP::host]" }

       

      (If you want to specific URI)

       

      when HTTP_REQUEST { persist uie "[IP::client_addr]:[URI::query [HTTP::uri] param1]" }