Forum Discussion
scott_doty_2411
Nimbostratus
Sep 27, 2006Redirect to VIP based on source IP
Is it possible with iRules to redirect traffic destined for one VIP to a different VIP based on the source IP address of the traffic. In other words if 10.10.10.10 is connecting to VIP "VIP1" redirec...
hoolio
Cirrostratus
Sep 27, 2006If you want to redirect a single client to a different URL (or VIP), you can use a rule like this:
when HTTP_REQUEST {
if { [IP::addr [IP::remote_addr] equals 10.0.0.10] } {
HTTP::redirect "http://my.vip.example.com/"
}
}
Or if you want to make the decision based on multiple hosts or networks, you can use a class (called a datagroup in the GUI) and a rule that references it:
Datagroup definition:
class my_hosts_networks_class {
network 10.0.0.0 mask 255.0.0.0
host 192.168.0.100
}
And rule:
when HTTP_REQUEST {
if { [matchclass [IP::remote_addr] equals $::my_hosts_networks_class] } {
HTTP::redirect "http://my.vip.example.com/"
}
}
Note: to create the datagroup in the GUI, navigate to Local Traffic >> iRules and then click on the Datagroup tab. Enter the hosts/networks in the datagroup and then create the rule which references it.
Aaron
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