Forum Discussion
Rodney_Newton_7
Nimbostratus
Oct 05, 2005iRule Syntax
Can someone show me the equivalent syntax for the following 4.x iRule for version 9.x?
if (http_header("User-Agent") contains "test") {
use pool bot
}
else {
if (client_addr == 1.1.1.0 netmask 255.255.255.0) {
use pool test
}
else {
if (client_addr == 2.2.2.2) {
use pool test
}
else {
if (client_addr == 3.3.3.3) {
use pool test
}
else {
if (client_addr == 4.4.4.4) {
discard
}
else {
if (http_header("User-Agent") contains "test2") {
use pool test
}
else {
if (http_header("User-Agent") contains "test3") {
use pool test
}
else {
if (http_header("User-Agent") contains "test.test.com") {
use pool test
}
else {
use pool otherpool
}
}
}
}
}
}
}
}
- A direct mapping would be something like this (using elseif's instead of nested if's):
when HTTP_REQUEST { if { [HTTP::header "User-Agent"] contains "test" } { pool bot } elseif { [IP::addr "[IP::client_addr]/24" equals "1.1.1.0/24"] } { pool test } elseif { [IP::addr "[IP::client_addr]" equals "2.2.2.2"] } { pool test } elseif { [IP::addr "[IP::client_addr]" equals "3.3.3.3"] } { pool test } elseif { [IP::addr "[IP::client_addr]" equals "4.4.4.4"] } { discard } elseif { [HTTP::header "User-Agent"] contains "test2" } { pool test } elseif { [HTTP::header "User-Agent"] contains "test3" } { pool test } elseif { [HTTP::header "User-Agent"] contains "test.test.com" } { pool test } else { pool otherpool } }
- Rodney_Newton_7
Nimbostratus
Thanks Joe... - This looks good but you might want to check out this thread for some version specific issues with matchclass and netmasks.
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