Forum Discussion
Dave_22402
Nimbostratus
Mar 16, 2010irule based on ip and url
I am trying to construct an Irule that first checks for a url and then allows access based on IP.
Example -
if the url is "/foo/*" and IP = 123.123.123.123
then go to this pool, if not go to bad pool and deny access or drop.
- Dave_22402
Nimbostratus
also there may be 15 or so ip addresses and possibly networks involved. - Dave_22402
Nimbostratus
when HTTP_REQUEST { - Dave_22402
Nimbostratus
this is on LTM 9.4.5 - JRahm
Admin
Which do you want, to send to bad pool, or discard? I think what you want is:when HTTP_REQUEST { if { ([string tolower [HTTP::uri]] starts_with "/foo/") && [matchclass [IP::client_addr] equals allowed_IPs] } { pool good_pool } else { discard } }
- hoolio
Cirrostratus
Keep in mind that an attacker could probably bypass this iRule validation very simply using URL obfuscation techniques like: - Ahh indeed...
- JRahm
Admin
The attacker would have to come from the specified range of ip's, though. And yes, you'd need to create the "allowed_IPs" datagroup. Sorry for leaving that detail out. - hoolio
Cirrostratus
If an attacker bypasses the URI check then it wouldn't matter which IP address they make the request from as it's a logical AND in the iRule. - JRahm
Admin
Using //foo/ and /foo/../not_foo from curl, first doesn't work at all, second only works when my IP address is out of range, as I'd expect. I guess I'm a little dense in not understanding. How would the URI check be bypassed? The conditional is expecting a string, it matches or it doesn't. If it does, then the IP address also has to match. If it doesn't, it doesn't matter what the IP is, the rule moves on to the else statements. - hoolio
Cirrostratus
Some of the URL obfuscation techniques only work on IIS. For example, this request does work on microsoft.com to make a request for /en/us/default.asp:
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