Forum Discussion

AJN_Network_Tea's avatar
AJN_Network_Tea
Icon for Nimbostratus rankNimbostratus
Jan 09, 2017

Filtering client IP using HSL in irules

We have the following hsl configured on the irule which works just fine with all the traffic. I need to add a filter on the below HSL config to log traffic only from specific client IP addresses. Any guidance is appreciated.

when HTTP_REQUEST {

 

set hsl [HSL::open -proto UDP -pool SYSLOG_POOL] set http_request_time [clock clicks -milliseconds] HTTP::collect 4096 set LogString "<190> [IP::client_addr]:[TCP::client_port]->[IP::local_addr]:[TCP::local_port]; [HTTP::host]"

 

host header translation function

HSL::send $hsl "$LogString REQUEST HOST HEADER TRANSLATED -----> [HTTP::host]"

 

}

 

when HTTP_RESPONSE {

 

set hsl [HSL::open -proto UDP -pool SYSLOG_POOL] HSL::send $hsl "[IP::client_addr]:[TCP::client_port]->[IP::local_addr]:[TCP::local_port] RESPONSE FROM SERVER ---> [LB::server])"

 

}

 

1 Reply

  • Enclose the logic in an if statement:

     

    if { [IP::addr [IP::client_addr] equals 1.2.3.4] } {
        execute existing code
    }

    Make sure to do it in both events and you should be fine.

     

    /Patrik