Forum Discussion
Irule to Load Balance traffic based on group of IP's
I would like to write an Irule to basically say "if a group of IP's come into the VIP, load balance to server 1 and 2, all others hit server 3" I'm newish to Irules so would like some help please.
Thanks
2 Replies
- Greg_Labelle
Nimbostratus
There are a few ways to deal with this, but one example is to use an iRule data group and match the specific source IP and make a decision based on that. I would set this up using two pools, a data group and a rule as per this example:
Pool1 - Server 1 and 2 Pool2 - Server 3
iRule Data group (String type)
Name: Pool1IPs Add the IP Addresses to route to Pool1iRule to direct the traffic:
when HTTP_REQUEST { if {[class match [IP::client_addr] equals Pool1IPs} { Pool Pool1 } else { Pool Pool2 } } Hello,
You can use list directly in the irule as shown in the example below :
when RULE_INIT { set static::ipaddress ["10.1.1.1" "10.1.1.2" "10.1.1.3"] } when HTTP_REQUEST { if { [lsearch -glob $static::ipaddress "[IP::client_addr]"] != -1 } { pool mypool } else { pool default_pool } }
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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