Here is the goal.
Traffic from 192.168.1.0 to LTM --> http://example.com/ (rest of the url)
Traffic from anywhere else to LTM --> pool_A
Here is my attempt so far.
when HTTP_REQUEST {
if { [[IP::remote_addr] starts_with “192.168.1.”] }
{ HTTP::redirect "http://example.com/\[HTTP::uri] }
else {pool my_pool}
}
I don’t know much about iRules as I am just now learning them, but would love to know what needs to happen. Basically I want to F5 to redirect traffic away from the F5 to another server if it comes from 192.168.1.0/24. If it doesn’t come from that address then go to the specified pool.
This should do it;
when HTTP_REQUEST {
if { [IP::addr [IP::client_addr] starts_with 192.168.1.] } {
HTTP::redirect "http://example.com/[HTTP::uri]" }
else {
pool my_pool }
}
I think you should use the correct ip address tests, not a string comparison, like:
[IP::addr [IP::client_addr] equals 10.0.0.0/8]
See: DevCentral
Thanks Mohamed, so it would look like this;
when HTTP_REQUEST {
if { [IP::addr [IP::client_addr] equals 192.168.1.0/24] } {
HTTP::redirect "http://example.com/[HTTP::uri]" }
else {
pool my_pool }
}
nitass
October 31, 2012, 12:25am
5
i just removed / after example.com because it is included in HTTP::uri.
when HTTP_REQUEST {
if { [IP::addr [IP::client_addr] equals 192.168.1.0/24] } {
HTTP::redirect "http://example.com[HTTP::uri]" }
else {
pool my_pool
}
}