Forum Discussion

jj24_43946's avatar
jj24_43946
Icon for Nimbostratus rankNimbostratus
Apr 02, 2012

evaluate IP::remote_addr as string

Hello and thanks in advance for your expertise:

 

 

My problem is that I want to be able to assign traffic to different pools based on the end digit of an IP address. For example, if it's from 0-4 go to POOL A, and if from 5-9 go POOL B.

 

 

What is the most efficient, resource-wise, method to achieve this? Below is what I'm doing right now.

 

 

 

when CLIENT_ACCEPTED {

 

set client_ip [IP::remote_addr]

 

if { [ $client_ip ends with "5" ] } {

 

pool poolB

 

return

 

}

 

}

 

 

Again, thanks for any assistance anyone can provide.

 

  • when CLIENT_ACCEPTED {

     

    set client_ip [getfield [IP::remote_addr] . 4]

     

    if { $client_ip < 5 } {

     

    pool POOLA

     

    }

     

    else {

     

    pool POOLB

     

    }

     

    }