Forum Discussion

ispksas_39015's avatar
ispksas_39015
Icon for Nimbostratus rankNimbostratus
Jun 26, 2009

iRule for persistence bsed on tcp source port

Hello,

 

Can anyone guide me on iRule to acheive persistence based on srouce tcp port?

 

 

when CLIENT_ACCEPTED {

 

if {[TCP::client_port] != 0} {

 

persist uie [TCP::client_port]

 

}

 

}

 

 

 

Thanks.

4 Replies

  • I did this once for a customer, you can remove the client_addr portion to to get what you want:

     

     

    when CLIENT_ACCEPTED {

     

    persist uie "[IP::client_addr]:[TCP::remote_port]"

     

    }

     

     

    To apply these, go to "Local Traffic -> iRule -> Create" and give appropriate name, then copy and paste the rule.

     

     

    Then go to "Local Traffic -> Profiles -> Persistence (in the main frame, gray bar) -> Create" and name appropriately, and use "Universal" for the Persistence Type.

     

     

    In the iRule section on the box below, select the iRule and specify the timeout value.

     

     

    Finally, apply the persistence profile to appropriate virtual server under "Resources".

     

     

  • Thanks John for your immediate response.

     

     

    Isn't remote port would look for server dest port in this case?

     

     

    Actually i have a server (lets call it Server A) that initiates TCP session to the set of servers (lets call it B & C)behind the F5. The destination ip on server A is the VIP address with the dst port 8771 for all sessions. The source port on this session from server A is changing for every session and that's what i'm trying to use for persistence.

     

     

    Do you still think that the irule you suggested or the one i posted is valid?
  • The remote port in a clientside event is the client's source port. You could use TCP::client_port which returns the client's port in all events (client or serverside context) for something more intuitive. If the client's IP address won't change over the course of a session, you would probably want to include the client IP address in the persistence record as johns has done.

     

     

    Aaron
  • Thanks Aaron and Johns. I'm currently in a process of applying this irule and will test it out this evening. Will let you know.

     

     

    Thanks alot.