Forum Discussion

sys-team_172267's avatar
sys-team_172267
Icon for Nimbostratus rankNimbostratus
Mar 10, 2016

Blocking specific "USER AGENT" version and lower by iRule

Hello,

 

i want to use iRule to block requests that contain some "USER AGENT" version and lower("=<").

 

how can i do it?

 

Thanks.

 

  • Hi Sys-team,

    I'm afraid, you can't block user-agents by using a "version < X" syntax. You have to block them one-by-one by using

    -glob
    wildcard matches.

    Example to block Internet Explorer below v11:

    when HTTP_REQUEST {
        switch -glob -- [HTTP::header value "User-Agent"] "*MSIE 2*" - "*MSIE 3*" - "*MSIE 4*" - "*MSIE 5*" - "*MSIE 6*" - "*MSIE 7*" - "*MSIE 8*" - "*MSIE 9*" - "*MSIE 10*" {
            HTTP::respond 200 content "Unsupported Brwoser"
        }
    }
    

    Note: A great source for user-agent string values can be found here... http://www.useragentstring.com/pages/useragentstring.php

    Cheers, Kai

  • Hi,

     

    you will be able to do it when: * split HTTP User-Agent string into tcl list * for given set of Browsers (like Chrome) parse version list element to a float: version.minor_version * use <= on such a data, even using a data-group holding rules definitions:

     

    Chrome := 26.0

     

    Firefox := 27.1