Forum Discussion

Marvin_129795's avatar
Marvin_129795
Icon for Nimbostratus rankNimbostratus
Jul 09, 2018

Irule persist lookup source_addr for specific virtual server

Is there a way to lookup (persist lookup) the source IP address persistence for a specific VS only?

 

The tmsh command is like this but is there an equivalent using the persist lookup in Irule?

 

tmsh ltm persistence persist-records virtual VS1 client-addr 1.1.1.1

 

2 Replies

  • Unless 'Persist Across Virtuals' is set then the persistence is per virtual server anyway. If it is set then yes, you can control this with the command as per https://devcentral.f5.com/wiki/iRules.persist.ashx

    persist lookup   [all|node|port|pool]  
    "all" or no specification returns a list containing the node, port and  pool name.  
    Specifying any of the other return types will return the specified item only.       
     =  | {  [any virtual|service|pool] [pool ] }        
    the latter key specification is used to access persistence entries across virtuals, services, or pools.
    
  • Jason_Cohen_417's avatar
    Jason_Cohen_417
    Historic F5 Account

    Marvin,

    For the most part, getting an added command to look across other virtuals persist records without enabling persist across * is slim. There are probably too many dark corners around which that could / would break. The preferred mechanism to do this would be with the table commands.

    A minimal framework using the table commands could look similar to this:

    when RULE_INIT {
         probably makes more sense to use data groups here
         quick and dirty PoC
        set static::web1_peer "/Common/vs_web2"
        set static::web2_peer "/Common/vs_web1"
    }
    
    when LB_SELECTED {
      table set [virtual name]:[IP::client_addr] [LB::server]
    }
    
    when HTTP_REQUEST {
        if { [virtual] eq "/Common/vs_web1" } {
            set peer ${static::web1_peer}
        }
        elseif { [virtual] eq "/Common/vs_web2" } {
            set peer ${static::web2_peer}
        }
        set peer_persist [table lookup ${peer}:[IP::client_addr]]
        if { ${peer_persist} ne "" } {
            log local0. "${peer} persist-record: ${peer_persist}. Select and persist to partner memeber."
        }
        else {
            log local0. "Peer persist-record not found.  Making selection."
        }
    
    }