Forum Discussion
Joseph_Goyette_
Nimbostratus
Mar 16, 2005matchclass and syntax errors
I've got a simle iRule below based on the example in the Writing iRules section of the LTM guide.
In a nutshell, I am attempting to direct requests to specific urls based on the client's ip address. I've copied the matchclass syntax directly from the manual yet I keep getting a syntax error:
Line 10: [parse error: PARSE syntax 264 {syntax error in expression "[IP::remote_addr] eq matchclass Esc-External-Networks ": variable references require preceding $}] [{[IP::remote_addr] eq matchclass Esc-External-Networks }]
Substituting the generic "aol" data group name produces the same error.
when HTTP_REQUEST
{
if {[HTTP::uri] starts_with "/all/"} {
use pool ALL-POOL
}
elseif {[HTTP::uri] starts_with "/CustomerA/"} {
use pool POOL-A
}
elseif {[HTTP::uri] starts_with "/CustomerB/"} {
if {[IP::remote_addr] eq matchclass Esc-External-Networks } {
use pool POOL-B
} else {
HTTP::redirect "http://www.escription.com/"
}
}
}
What am I missing here ?
Thanks !
Joe
- unRuleY_95363Historic F5 AccountI believe the syntax in your matchclass usage is wrong. Try this instead:
if {[matchclass [IP::remote_addr] eq $::Esc-External-Networks] } { use pool POOL-B } else { HTTP::redirect "http://www.escription.com/" }
- James_Thomson
Employee
What if you wanted to not specify the pool, but deny everything outside of the matchclass, how would you do a "does not equal". Something like this:when CLIENT_ACCEPTED { if {[matchclass [IP::remote_addr] !eq $::allowed-group] } { discard } }
- unRuleY_95363Historic F5 AccountTry this:
when CLIENT_ACCEPTED { if {not [matchclass [IP::remote_addr] eq $::allowed-group] } { discard } }
- James_Thomson
Employee
That worked, thanks.
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