Forum Discussion
Allanwynn_16283
Nimbostratus
Oct 17, 2015Redirect to an internal site based on client source network (IP)
Hi all,
I am not really familiar with iRule, so can you help me:
An iRule where it is based on client's source network (not specific IP) to be redirected to an internal site?
i.e. 172.1...
Oct 17, 2015
It's to check if the IP is even or odd. If it's 172.16.4.15 it will be 15 % 2, which is 1. If it's 172.16.4.14 it will be 14 % 2, which is 0.
when HTTP_REQUEST {
Get the last octet. For 172.16.4.11 that would be 11
set lastoctet [lindex [split [IP::client_addr] .] 3]
Check if the octet is odd or even with modulus (remainder)
if { [expr $lastoctet % 2] == 1 } {
HTTP::respond 301 Location "http://mysite1.com"
} else {
HTTP::respond 301 Location "http://mysite2.com"
}
}
/Patrik
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