Forum Discussion
ibehavior_37902
Nimbostratus
Aug 31, 2010Load balance on source ip address
Hello -
I need to be able to load balance incoming traffic to one of 4 back end pools based on some part of the source IP address. I have found several examples of how to do this at the subnet level but this is an internet facing device and I could get traffic from any subnet. A suggestion what to use some portion of the IP address, like the last octet and load balance based on the value.
For example:
000 - 064 - Pool_1
065 - 128 - Pool_2
129 - 192 - Pool_3
193 - 255 - Pool_4
Another thought was to do a MD5 hash on the source IP address but I did not have any luck finding any information on this.
Any help would be appreciated, kind of new to the F5's
Thanks
Dan
- Chris_Miller
Altostratus
Hoolio wrote something up for SNATing based on the 3rd Octet...that logic could easily be ported over...if I find time today, I'll try writing something upwhen CLIENT_ACCEPTED { Use a local array to configure the 5 SNAT addresses set snat_ips(0) 1.1.1.1 set snat_ips(1) 2.2.2.2 set snat_ips(2) 3.3.3.3 set snat_ips(3) 4.4.4.4 set snat_ips(4) 5.5.5.5 Use getfield to parse the third octet from the client IP address Get the modulus of the third octet against the number of the SNAT IPs in the array set snat_number [expr {[getfield [IP::client_addr] "." 3] % [array size snat_ips]}] log local0. "Client IP: [IP::client_addr], SNAT number $snat_number, SNAT IP: $snat_ips($snat_number)" Apply the SNAT snat $snat_ips($snat_number) }
- Chris_Miller
Altostratus
Quick mod....test it out and see whether it works for you...I pretty much just did find and replace so I very well may have missed something.when HTTP_REQUEST { Use a local array to configure the 4 pools set pool_choice(0) pool_1 set pool_choice(1) pool_2 set pool_choice(2) pool_3 set pool_choice(3) pool_4 Use getfield to parse the third octet from the client IP address Get the modulus of the third octet against the pool members in the array set pool_number [expr {[getfield [IP::client_addr] "." 3] % [array size pool_choice]}] log local0. "Client IP: [IP::client_addr], Pool number $pool_number, Pool Choice: $pool_choice($pool_choice)" choose a pool pool $pool_choice($pool_number) }
- ibehavior_37902
Nimbostratus
Chris - - The_Bhattman
Nimbostratus
Hi Dan, - ibehavior_37902
Nimbostratus
Bhattman - - The_Bhattman
Nimbostratus
Hi Dan,
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects