Forum Discussion
Marc_Weisbrod_6
Nimbostratus
Nov 09, 2006IRule to redirect to another side based on network
All,
I am trying to write an Irule to redirect users who are not on our local site to another page. I have written this Irule but I am unsure if the Irule can accept subnets.
when HTTP_REQUEST {
if { [[IP::client_addr] is "10.1.0.0/16"] } {
pool http-pool
} elseif {
[[IP::client_addr] is "10.2.0.0/16"] } {
pool http-pool
} elseif {
[[IP::client_addr] is "172.16.0.0/16"] } {
pool http-pool
} else {
HTTP::redirect "http://192.168.0.12/local_only.jsp"
}
}
Basically anyone who connects with 10.1.x.x or 10.2.x.x or 172.16.x.x should get the site, but if you connect from 10.3.x.x you get redirected.
Thanks
- hoolio
Cirrostratus
You can set up your hosts and networks in a class (datagroup in the GUI) and then reference that class in a rule. Here is an example:class my_hosts_networks_class { network 10.0.0.0 mask 255.0.0.0 host 192.168.0.100 }
rule filter_clients_rule { when HTTP_REQUEST { if { [matchclass [IP::remote_addr] equals $::my_hosts_networks_class] } { pool http-pool } else { HTTP::redirect "http://192.168.0.12/local_only.jsp" } } }
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