Forum Discussion

bbensten_8485's avatar
bbensten_8485
Icon for Nimbostratus rankNimbostratus
Jul 07, 2014

logging only when statment is true.

Hi,

 

I am using the following irule that works perfectly but I would like to insert a log local statement that only logs if an attempt is made that does not meet the IP list (a log on the blocking essentially). Can someone please help me with the syntax to do so?

 

when HTTP_REQUEST { if { [string tolower [HTTP::path]] contains “/blah” } { if { ! [class match [IP::client_addr] equals allowed_IPs]} { discard } } }

 

  • e.g.

    when HTTP_REQUEST { 
      if { [string tolower [HTTP::path]] contains "/blah" } { 
        if { ! [class match [IP::client_addr] equals allowed_IPs]} { 
          log local0. "[IP::client_addr]:[TCP::client_port] does not match the allowed IP list"
          discard 
        } 
      } 
    }