Forum Discussion

jonesy77_222167's avatar
jonesy77_222167
Icon for Nimbostratus rankNimbostratus
Sep 16, 2015

iRule to forward traffic depending on specific IP to original pool when holding pool enabled.

I'm trying to setup an iRule for when our sites are being upgraded.

I've setup holding pools that will be enabled when sites are being upgraded so end users will see just a banner site when enabled. But I would like to setup a iRule that allows our internal testers via an external IP's (data group) to connect to the main pools whilst doing business testing and the holding pages on for external clients. This rule would be active only when these holding pages are enabled.

Pool setup holdingpool_1,2,3,4,5,6,7 (7 pools in total) pool_1,2,3,4,5,6,7 (7 pools in total)

My attempt started off like this:

when CLIENT_ACCEPTED { 
if { [class match [IP::remote_addr] equals external_ip] } { 
     pool origin_pool } 

 }

I've setup the data group with the our external IP's. I've seen you can use origin_pool but wasn't sure if origin_pool is the current active pools?

I'm new to iRules and F5 but was wondering if anyone had any suggestions or scripts?

Thanks in advance

Jonesy77

7 Replies

  • never seen origin_pool used before, with some googling i see it mentioned a couple of time, but then in old articles and related to caching.

     

    why do you want to use it, you could use the holdingpool_1 for your normal customers and pool_1 for the special IPs right?

     

  • I would probably go with something like this.

    when CLIENT_ACCEPTED { 
    if { [class match [IP::remote_addr] equals external_ip] } { 
        pool  
        }
    else { pool holding_pool }
     }
    

    I don't see why you would need seven different holding pools, but if you do then you'd have to get more complicated to rotate through those pools. I think it would be easier to combine all the "holding" servers into one pool.

    • jonesy77_222167's avatar
      jonesy77_222167
      Icon for Nimbostratus rankNimbostratus
      Steve, thanks for the response. It seems that we can probably amalgamate them to one holding pool – a legacy setup. Is it possible to add logic that – only when holding pool is enabled run this iRule when CLIENT_ACCEPTED { if { [class match [IP::remote_addr] equals external_ip] } { pool ---- not sure if you can add multiple pools in! } else { pool holding_pool } } Question: Would the rule be clever enough to work out which pool to go to depending on the traffic &8211; different pools listen out on different IP address? New to F5. Thanks Jonesy77
  • Hi jonesy77,

     

    can you explain what are conditions to choose pool_1, pool_2 ...

     

    a pool is a set of servers, if you want load balancing, you need to create ONE pool containing all servers.

     

    you can change pool depending on client connection condition or client request content such as URL.

     

  • Hi,

    your message is not formatted... and explanation are not clear...

    the better way is to give examples...

    I understand that you have 7 VS with:

    • 1 pool with 2 members (hosted on same 2 nodes for every VS, only port is different) named pool_test_X (X from 1 to 7)
    • 1 holding pool (hosted on same 2 nodes for every VS, only port is different) named holdingpool_test_X (X from 1 to 7)
    • users from IPs 222.222.222.225 and 222.222.222.226 (in data group external_ip) must be directed to pool_test_X
    • All other users must be directed to holdingpool_test_X

    you can use following irule:

    when CLIENT_ACCEPTED { 
        set default_pool [LB::server pool]
        if { [class match [IP::remote_addr] equals external_ip] } { 
            pool $default_pool
        } else { 
            pool  holding_$default_pool
        }
    }
    

    With this irule, the holding pool name must be holding_

  • Hi,

    did you try the irule with a test VS?

    If you use multiple time the holding pool, create a variable.. I recommend you to adapt the irule to:

    when CLIENT_ACCEPTED {
        set default_pool [LB::server pool]
        set holding_pool Holding_$default_pool
        if { ([active_members $holding_pool] >= 2) && ([class match [IP::remote_addr] ne external_ip]) } {  
            pool $holding_pool
        } else {
            pool $default_pool
        }
    }
    

    The logic of the expected scenario is not the same than the irule... can you check your expected scenario and add the name of the pool you want to count member.

    • 2 members servers enabled (Pool default or holding???) and remote_addr is equal external_ip = $default_pool
    • 2 members servers enabled (Pool default or holding???) and remote_addr is not equals external_ip = Holding_$default_pool
    • 1 members servers enabled (Pool default or holding???) and remote_addr is equal external_ip = $Holding_$default_pool
    • 1 members servers enabled (Pool default or holding???) and remote_addr is not equal external_ip = $Holding_$default_pool
  • your scenario is strange....

    holding pool with 2 members --> default pool holding pool with 1 members --> holding pool

    most of customer want to disable holding pool if less than 2 members are up.

    I never used

    ne
    operator with class match... can you check this irule :

    when CLIENT_ACCEPTED {
        set default_pool [LB::server pool]
        set holding_pool Holding_$default_pool
        if { ([active_members $holding_pool] >= 2) && !([class match [IP::remote_addr] equals Internal_ip]) } {  
            pool $default_pool
        } else {
            pool $holding_pool
        }
    }