matchclass 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

I 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/" 
 }

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 
    } 
 }

It doesn’t like the !eq section. Any ideas how to do this?

Try this:

when CLIENT_ACCEPTED { 
    if {not [matchclass [IP::remote_addr] eq $::allowed-group] } { 
       discard 
    } 
 }

That worked, thanks.