Forum Discussion

TMcGov_92811's avatar
TMcGov_92811
Icon for Nimbostratus rankNimbostratus
Jul 03, 2012

iRule - Using client source tcp port to forward to specific pool

Hello,

 

 

I'm looking to write an iRule and apply it to a wildcard virtual server listening on all ports. It would identify the client's source tcp port, and based on that, it would forward traffic to a certain pool.

 

 

 

Thanks, Tom

 

  • Richard__Harlan's avatar
    Richard__Harlan
    Historic F5 Account
    What I would do is do a class lookup based on the port and lookup the pool, then foward that traffic to the pool found in the class path. Question are you sure about client source port since most client pick a port at random or do you mean the dest port?

     

  • Correct - Brain freeze....

     

     

    Here is what I mean: Looking to write an iRule and apply it to a wildcard virtual server listening on all ports. It would identify the selected destination tcp port, and based on that, it would forward traffic to a certain pool.

     

     

     

     

     

     

  • You can refer these links for tcp port:

     

     

    https://devcentral.f5.com/wiki/iRules.tcp__local_port.ashx

     

    https://devcentral.f5.com/wiki/iRules.TCP__remote_port.ashx
  • I found a god way to accomplish this:

     

     

    when CLIENT_ACCEPTED {

     

    switch [TCP::local_port] {

     

    9951 { pool pool.xa_app_msgapps_9951}

     

    9971 { pool pool.xa_app_msgapps2_9971}

     

    default { discard }

     

    }

     

    }