Forum Discussion
jtostado_47719
Nimbostratus
Oct 21, 2009BIGIP 4.5 to 9.3.1 iRule Conversion
I need help converting this rule:
if (http_uri ends_with one of portal_redirect_class) {
redirect to "https://psp-portal.com/portal/server.pt"}
else {
use pool SHAREPOINT
}
27 Replies
- hoolio
Cirrostratus
Hi Sumod,
You can use matchclass to check whether a client IP is part of an address type datagroup. And you can also use matchclass to see if the requested URI is part of a string datagroup. [IP::client_addr] replaces ${client_addr}. You don't need to use "use pool" in 9/10.x; just "pool POOL_239_2" works. Also, you can combine client IP addresses that you want to send to the same pool in an address datagroup to reduce the number of IP checks you do. If you do want to check a single IP address or network, you can use the IP::addr command.
Here are a few links:
http://devcentral.f5.com/wiki/default.aspx/iRules/ip__addr
http://devcentral.f5.com/wiki/default.aspx/iRules/ip__client_addr
http://devcentral.f5.com/wiki/default.aspx/iRules/matchclass
http://devcentral.f5.com/wiki/default.aspx/iRules/pool
http://devcentral.f5.com/wiki/default.aspx/iRules/http__method
http://devcentral.f5.com/wiki/default.aspx/iRules/log
Aaron - Sams_88783
Nimbostratus
Hello Battman, Please help me with the above mentioned irule also
Thanks - Sams_88783
Nimbostratus
Hello Aron,
Thanks Alot it worked.
One more help...i am facing issue with converting one more iRule.Please help me in converting this as well...
if (client_addr == 10.1.8.2 netmask 255.255.255.255) {
if (http_uri contains one of MemberEligibility) {
use pool POOL_239_2
}
else {
use pool POOL_239_1
}
}
else if (client_addr == 10.1.6.2 netmask 255.255.255.255) {
if (http_uri contains one of MemberEligibility) {
use pool POOL_239_2
}
else {
use pool POOL_239_1
}
}
else if (client_addr == 10.2.8.2 netmask 255.255.255.255) {
if (http_uri contains one of MemberEligibility) {
use pool POOL_239_2
}
else {
use pool POOL_239_1
}
}
else if (client_addr == 10.2.6.2 netmask 255.255.255.255) {
if (http_uri contains one of MemberEligibility) {
use pool POOL_239_2
}
else {
use pool POOL_239_1
}
}
else if (client_addr == 10.2.8.5 netmask 255.255.255.255) {
if (http_uri contains one of MemberEligibility) {
use pool POOL_239_2
}
else {
use pool POOL_239_1
}
}
else if (client_addr == 10.2.8.4 netmask 255.255.255.255) {
use pool POOL_239_ALL
}
else if (client_addr == 10.2.6.5 netmask 255.255.255.255) {
use pool POOL_239_ALL
}
else if (client_addr == 10.2.3.5 netmask 255.255.255.255) {
use pool POOL_239_3
log "IVR request made."
}
else {
log "Using generic rule (IT2). Unexpected IP: ${client_addr}"
if (http_method == "GET") {
log "GET method used."
}
else if (http_method == "POST") {
log "POST method used."
}
else {
log "Unexpected method used."
}
if (http_uri contains one of MemberEligibility) {
use pool POOL_239_2
log "Eligibility request made."
}
else if (http_uri ends_with one of images) {
use pool POOL_239_ALL
log "Image request made."
}
else {
use pool POOL_239_1
log "Generic request made."
}
} - hoolio
Cirrostratus
The classes need to be defined separately from the iRule. You can do this in the GUI under Local Traffic >> iRules >> Datagroup List tab >> Create >> Type: string. After you create the classes, you can then create the iRule which references them.
Aaron - Sams_88783
Nimbostratus
If i remove class eligibility then i am getting.....
01070151:3: Rule [DOL_Test] error:
line 1: [undefined procedure: class] [class images {
".jpg"
".gif"
} ] - Sams_88783
Nimbostratus
01070151:3: Rule [DOL_Test] error:
line 1: [undefined procedure: class] [class eligibility {
type string
"/web/onetime/Inquiry"
"/web/onetime/Details"
"/web/onetime/DaveInquiry"
} ] - The_Bhattman
Nimbostratus
What is the error?
Bhattman - Sams_88783
Nimbostratus
hello Bhattman,
I have written a rule like below...but its giving me error.so please help me in correcting the same
class eligibility {
type string
"/web/onetime/Inquiry"
"/web/onetime/Details"
"/web/onetime/DaveInquiry"
}
class images {
".jpg"
".gif"
}
when HTTP_REQUEST {
if {[IP::addr[IP::client_addr] equals 10.1.1.1] } {
if { [matchclass [string tolower [HTTP::uri]] contains $::eligibility] } {
pool POOL_230_2
} else {
pool POOL_230_1
}
} elseif {[IP::add [IP::client_addr] eq 10.1.1.8] } {
pool POOL_230_ALL
} else {
switch [HTTP::method] {
"GET" { log local0. "GET method used" }
"POST" { log local0. "POST method used"}
default { log local0. "Unexpected method used" }
}
if { [matchclass [string tolower [HTTP::uri]] contains $::eligibility ]} {
pool POOL_230_2
log local0. "Eligibility request made."
} elseif { [matchclass [string tolower [HTTP::uri]] ends_with $::images ]} {
pool POOL_230_ALL
log local0. "Image request Made"
} else {
pool POOL_230_1
log local0. "Generic Request Made"
}
}
} - The_Bhattman
Nimbostratus
Hi Sumond,
Here is link to some instructions about creating data groups
https://support.f5.com/kb/en-us/solutions/public/6000/900/sol6911.html
These are not specific instructions for your case, but it shows you how to create Datagroup containing string information (which is URL info in your case)
I hope this helps
Bhattman - Sams_88783
Nimbostratus
from where i can create theat CLASS object ?
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
