Forum Discussion

danielng_19608's avatar
danielng_19608
Icon for Nimbostratus rankNimbostratus
Feb 17, 2010

Need help with Load Balancing iRule

Hi all, i have been working on this iRule to load balance traffic based on source ip addresses. Basically i wish to balance source traffic by throwing them to 2 of the proxy servers based on source ip addresses. i have came up with something listed below:

 

 

when CLIENT_ACCEPTED {

 

if { [IP::addr 10.0.0.1/32 equals 10.0.0.0/24] } {

 

pool Cache_Pool_HTTP member 5.5.5.5 80

 

}

 

else {

 

pool Cache_Pool_HTTP member 5.5.5.6 80

 

}

 

}

 

 

please advise if i am missing anything out here?
  • hoolio's avatar
    hoolio
    Icon for Cirrostratus rankCirrostratus
    Hi Daniel,

     

     

    If you change the IP::addr command to check the client IP address it should work fine to check if the client IP is in the 10.0.0.0/24 network:

     

     

    if { [IP::addr [IP::client_addr] equals 10.0.0.0/24] } {

     

     

    Aaron
  • hoolio's avatar
    hoolio
    Icon for Cirrostratus rankCirrostratus
    Or are you trying to alternate between the two pool members based on the last octet of the client IP? If so, this might be relevant:

     

     

    http://devcentral.f5.com/Default.aspx?tabid=53&forumid=5&tpage=1&view=topic&postid=61264

     

     

    Check if client IP address is odd or even

     

    if { [IP::addr [IP::client_addr] equals 0.0.0.0/1] } {

     

     

    Aaron
  • thanks alot for the input hoolio, what i was trying to achieve was to alternate between pool members based on ip subnets. your first input really helped! thanks again