Forum Discussion

Christopher_167's avatar
Christopher_167
Icon for Nimbostratus rankNimbostratus
Jan 21, 2012

iRule to use a pool based in incoming port ?

Hi, Anyone have an iRule that uses a pool based on the incoming port ?

 

 

(Note: I'm an iRule n00b. In fact this is my very first attempt at even thinking about iRules. So if you will please humor me...(searching didn't find an easy answer so I have begun reading documentation))

 

 

I have currently setup a many virtual servers, all listening on the same IP, on different ports. Each port is associated with a different pool. All of the virtual servers perform the exact same function which is to just FastL4 to the pool. My pools contain only a single node. In essence, this is a way for me to intentionally hit a single server from the outside.

 

 

I'm thinking that perhaps I could instead have an irule that handles this far more elegantly. Has anyone ever done something like that?

 

 

What if I create pools with names that contain port numbers.

 

 

For example:

 

 

pool_101

 

pool_102

 

pool_103

 

 

And then perhaps create an iRule that says something like:

 

 

$destination = "pool_"$inboundport

 

forward traffic to $destination

 

 

Any ideas on how to elegantly redirect traffic to a single node based on the incoming port?

 

 

--CL

1 Reply

  • Hi Christopher,

    You can try something like this:

    
    when CLIENT_ACCPEPTED {
    
     Try assigning the pool based on the client destination port
     If the pool assignment fails, use the VS default pool
    if {[catch {pool pool_[TCP::local_port]} result]}{
     Pool did not exist, so log the value for testing
     The VS default pool will be used
    log local0. "pool_[TCP::local_port] doe not exist"
    } else {
     Pool assignment succeeded
    }
    }
    

    Aaron