Hello, As an iRule newbie im tring to get my switch statements right instead of using “if” statements. This is for my own learning curve, can someone point me in the right direction please and explain to me what is wrong with the following?
when CLIENT_ACCEPTED {
switch [active_members SB_POOL]
{ "0" { reject
log local0. "iRule: Reject-No active members in pool SB_POOL."
}
}
switch [TCP::local_port]
{
"([TCP::local_port] >= 636) and ([TCP::local_port] <=7777)"
{
pool SB_POOL
log local0. "iRule: ACCEPT-Port [TCP::local_port] within range."
}
default { reject
log local0. "iRule: ACCEPT-Port [TCP::local_port] within range."
}
}
}
Symtoms
I test using greater than or less than the above range specified. In the LTM logs i get the following…
Rule /Common/SB-SWITCH : iRule: ACCEPT-Port 777 within range. Rule /Common/SB-SWITCH : iRule: ACCEPT-Port 7777 within range. Rule /Common/SB-SWITCH : iRule: ACCEPT-Port 500 within range. BUT i do not get the redirection to the pool which is up???
By the way the following using “if” statements works perfect… SO whats up with my switch statesments above? Any ideas?
when CLIENT_ACCEPTED {
if {[active_members SB_POOL] < 1}{
reject
log local0. "iRule: Reject-No active members in pool SB_POOL." }
elseif {([TCP::local_port] >= 636) and ([TCP::local_port] <=7777)}{
pool SB_POOL
log local0. "iRule: ACCEPT-Port [TCP::local_port] within range." }
else {
reject
log local0. "iRule: DROP-Port [TCP::local_port] out of range." }
Nitass, thanks great! thanks alot. I clearly need to get some practice in as an iRule newbie. And thanks for the tclsh tip too. Nice little feature. Ill have a read about for some more iRule fun…any pointers/ links would be much appreciated.
i think iRules 101 series here may be a good start. there are a few books written by Steven (What Lies Beneath) available at Amazon in case you want to take a look.