Forum Discussion
Simon_Coffin_16
Nimbostratus
Aug 20, 2014iRule to load balance based on source IP
Hi Folks,
This is my first attempt at an iRule so I wanted to bounce it off all of you for comment. There are, no doubt, syntax and logic errors.
The purpose of this iRule is to load balance based...
Simon_Coffin_16
Nimbostratus
Aug 20, 2014Let's try that again with better formatting.
when CLIENT_ACCEPTED {
! Use getfield to pull the source IP address's third octet and determine if its
! even or odd.
set third-octet [expr {[getfield [IP::client_addr] "." 3]}]
if { [$third-octet ends_with 0,2,4,6,8]
{ set destination even }
elseif
{ set destination odd }
! Send even sources to one Pool member, odds to the other.
if { [$destination eq odd]
pool Application-pool member server1 80
persist source_addr 14400
}
if { [$destination eq even]
pool Application-pool member server2 80
persist source_addr 14400
}
}
!If a pool member is not available, send the session back to the Pool and
!set the persistence for a 60 minute timeout
when LB_FAILED {
pool Application-pool
persist source_addr 3600 LB::reselect
}
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
