Forum Discussion

Thiago_Morais's avatar
Thiago_Morais
Icon for Altostratus rankAltostratus
Jan 11, 2021

iRule with HTTP::request and datagroup

Hi Guys,

 

I need to create an iRule that will check two conditions:

 

1) HTTP::request contain a specific word "test"

2) The source IP is a member of the Datagroup

 

I would like to create an iRule using only one if statement (one line) to check both conditions above?

 

Thanks in advance

4 Replies

  • Here, you can use logical AND operator to check both conditions and if both are fulfilled, set required actions.

    Below is IF statement for your reference.

    if { ([HTTP::host] contains "test") && ([class match [IP::client_addr] equals Allow-List]) }

    Hope it helps!

    • Samir's avatar
      Samir
      Icon for MVP rankMVP

      Add string tolower functions may help here.

  • I can use this irule inside a HTTP_REQUEST event? The HTTP_REQUEST event allows me to check the client IP address in datagroup?

  • Yes it should! I tested below iRule on my lab setup and it is working fine. You can try your iRule using above IF Statement and test.

    when HTTP_REQUEST {
     
    if {([HTTP::host] contains "test") && ([class match [IP::client_addr] equals Allow-List])} {
     
        pool TEST-Pool
    log local0. "Allowed client IP is  [IP::client_addr]"
    } else {
      
        log local0. "Dropped IP is [IP::client_addr]"
    }
    }

    Hope it helps!