Forum Discussion
TMcGov_92811
Nimbostratus
Jan 21, 2009IRule to use Pool depending on Client source address
I need to add some more logic to an existing iRule, and I think I need to clean it up before doing so. I'm sure there must be a better way for me to do this. Basically, I just want to examine the client's source IP, and based on that, send them to a specific pool. Here's what I have now...how can I simplify this ?
when CLIENT_ACCEPTED {
switch [IP::client_addr] {
63.208.77.21 { pool http-Test-mediation }
166.90.79.2 { pool http-Test-mediation }
198.204.15.125 { pool http-Test-mediation }
198.204.15.126 { pool http-Test-mediation }
202.54.137.90 { pool http-Test-mediation }
203.99.192.0/19 { pool http-Test-mediation }
203.99.195.2 { pool http-Test-mediation }
203.99.208.0/23 { pool http-Test-mediation }
203.197.245.101 { pool http-Test-mediation }
203.199.245.10 { pool http-Test-mediation }
65.5.4.196 { pool alt-http-Test }
65.5.4.198 { pool alt-http-Test }
65.5.4.199 { pool alt-http-Test }
65.5.4.253 { pool alt-http-Test }
65.5.4.254 { pool alt-http-Test }
65.201.27.93 { pool alt-http-Test }
default { pool alt-http-Test-mediation }
}
}
6 Replies
- dennypayne
Employee
Hi,
You'll want to use the matchclass command with a couple of class files (Data Groups in the GUI). Click here
So if you build 2 class files, one called http-Test-mediation and the other alt-http-Test with the appropriate addresses, then use a rule like this:when CLIENT_ACCEPTED { if { [matchclass $::http-Test-mediation contains [IP::client_addr]] } { pool http-Test-mediation } elseif { [matchclass $::alt-http-Test contains [IP::client_addr]] } { pool alt-http-Test } else { pool alt-http-Test-mediation } }
then you should be able to update your class files without having to change the rule.
Denny - TMcGov_92811
Nimbostratus
I tried something similar but my syntax was wrong - Thanks this works great. - hoolio
Cirrostratus
I think that hyphens in TCL variables (or class names) need to be bracketed or they'll be interpreted incorrectly:
% set test-variable some_value
some_value
% puts $test-variable
can't read "test": no such variable
% puts ${test-variable}
some_value
It might be easier to use underscores instead of hyphens.
Aaron - TMcGov_92811
Nimbostratus
I think you're right, great catch I'll just skip them altogether. - krishna_52361
Nimbostratus
I have a doubt , is that a similar to Topology Load balancing in GTM - krishna_52361
Nimbostratus
I have a doubt , is that a similar to Topology Load balancing in GTM
Will this load the CPU of LTM or we can still use LTM for Source address Loadbalancing instead of GTM.
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