Forum Discussion
Welson_Alexandr
Nimbostratus
May 18, 2007Route base on source address
This is my first try at iRules.
I would like to route a users to a pool in Data Center 1 if let's say they are coming from subnet 10.200.0.0 else redirect them to http://otherurl.com:8080 that is a VIP in Data Center 2
Will this work:
when CLIENT_ACCEPTED {
if { [IP::addr [IP::client_addr]/8 equals 10.200.0.0] } {
pool dev_testpool
} else {
HTTP::redirect "http://otherurl.com:8080/"
}
}
1 Reply
- Nathan_McKay_67
Nimbostratus
You might want to structure this a bit differently and use the matchclass command with an appropriate data group to contain the desired source addresses to match against. Something like:when HTTP_REQUEST { if { not [ matchclass [ IP::client_addr ] equals $::subnet_group ] { HTTP::redirect "http://otherurl.com:8080[HTTP::uri]" } }
Then just set the default pool for the VS to dev_testpool or whatever. This way you execute code to handle the exceptions, can manage stacked iRules a little better, and also redirect them to the URI that was originally requested (if you wanted to do that).
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