Forum Discussion
Ranvir_Floura_7
Nimbostratus
Mar 25, 2009redirect based on source ip address
Need a little help in coming up with an iRule where if the client IP matches i want it going to a pool, if not just redirect to a url. I am missing something here
when CLIENT_ACCEPTED {
if { [IP::addr [IP::client_addr] equals x.x.x.10] } {
} elseif { [IP::addr [IP::client_addr] equals x.x.x.11]} {
} elseif { [IP::addr [IP::client_addr] equals x.x.x.12]} {
} elseif { [IP::addr [IP::client_addr] equals x.x.x.13]} {
} elseif { [IP::addr [IP::client_addr] equals x.x.x.14]} {
} elseif { [IP::addr [IP::client_addr] equals x.x.x.15]} {
pool xyz
}
}
else {
HTTP::redirect http://impacii.nih.gov
}
Thanks!
- hoolio
Cirrostratus
Hi,when HTTP_REQUEST { Check if client IP is in the datagroup if {[matchclass [IP::client_addr] equals $::my_client_ips_class]}{ pool xyz } else { HTTP::redirect "http://redirect.example.com" } }
- Ranvir_Floura_7
Nimbostratus
Hi Aaron, - dennypayne
Employee
The class syntax should not be part of the iRule, that syntax is what ends up in the bigip.conf file if you create a Data Group in the GUI (I wish that they had named it the same thing in the GUI as in the config file but hey...). - What am I doing wrong ? I have the following, and it is dropping all connections
- dennypayne
Employee
The wiki says - "Use of IP::addr is not necessary if matchclass command is used to perform the address-to-address comparison" but nonetheless you may want to try:if { [matchclass IP:addr[IP::client_addr] equals $::relay_hosts_allowed]} {
when CLIENT_ACCEPTED { if { [matchclass [IP::client_addr] equals $::relay_hosts_allowed]} { log local0. "[IP::client_addr] matched an allowed host." forward } else { log local0. "[IP::client_addr] didn't match, dropping" drop } }
- I think my problem was that I was using forward instead of snat automap.
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