Forum Discussion
yves_werniers_1
Nimbostratus
Oct 14, 2009class and v9.1.2
Hello,
It seems like the class command was introduced in v10.0, whereas matchclass was introduced in v9.0.
I am running v9.1.2. How can I cerate something classlike and use classmatch?
I want to limit connections to certain url/uri combinations based on the source ip address. I am using the X-Forwarded-For header because it is behind a reverse proxy.
This is the script I would like to use:
class hrmstest_uris {
"/hraccent/ess/client_prod"
"/hraccent/ess/login.php?company=client_prod"
"/hraccentops/ess/client_prod"
"/hraccentops/ess/login.php?company=client_prod"
}
when HTTP_REQUEST {
set my_uri [string tolower [HTTP::uri]]
if {[HTTP::host] == "www.host.com" and [matchclass $my_uri starts_with $::hrmstest_uris] } {
if { [HTTP::header X-Forwarded-For] != "ip1" and [HTTP::header X-Forwarded-For] != "ip2" and [HTTP::header X-Forwarded-For] != "ip3"}{
log local0. "\[request blocked\] : [HTTP::header X-Forwarded-For]"
drop
}
}
}
4 Replies
- hoolio
Cirrostratus
You can use matchclass in 9.x or 10.x to evaluate an IP address or string against a class.
You might also consider adding the three IP addresses to an address type datagroup (aka class) and then use matchclass again to check the XFF header value against the datagroup.
Be aware that it's likely that attackers could bypass your logic though using obfuscation techniques:
http://devcentral.f5.com/Default.aspx?tabid=53&view=topic&postid=30900
Aaron - yves_werniers_1
Nimbostratus
but the big problem is that I cannot even save that iRule. I get an error on the class line:
undefined procedure: class
any thoughts? - hoolio
Cirrostratus
Ah, the class definition is separate from the iRule. You define the class (called a datagroup in the GUI) under Local Traffic | iRules | Datagroup List. Then define the iRule under the iRules tab.
Aaron - yves_werniers_1
Nimbostratus
yes! That's what I was missing.
thanks a lot !
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects