Forum Discussion
iRule Newbie - Limit Access to URIs based on IP Source
Hi,
I am just starting out in the wold of iRules - apologises for any newbie errors.
We have a test site that where access control was based on a firewall ACL - pretty simple worked fine.
Now our developers have created an app they wish to test from anywhere on the Internet but still want restrict access based on source IP to the originlal test site.
i.e.
/authenticate :: permit 0.0.0.0/0
/* :: permit only x.x.x.x/y and host a.b.c.d
I have already created an iRule to rewite the client's URI request from "/" to our landing page - /web/landing_page - this is also working fine.
I was going to add a second iRule to the VS with priority set so that it execute following the rewrite iRule.
My logic for the second iRule:
priority 20
if http request uri eq /authenticate
permit
else if http request eq datagroup_string-class
permit
The data group would list the URI with a permited access-group address list as the value.
Questions:
Will my logic work?
Can I use a wildcard e.g. "/*" for the test site URI or do I have to have every URI listed?
Thanks!
Mark
4 Replies
- Mohamed_Lrhazi
Altocumulus
Can you show a made up example of the data group? - Rustic_57941
Nimbostratus
Hi,
The data group (string class) looks like this::
/authenticate:=Auth_Allowed_IPs
/web/landing_page:=Test_Allowed_IPs
Thanks - Mohamed_Lrhazi
Altocumulus
Maybe your data could be like so:
/authenticate:=0.0.0.0/32
/web/landing_page:=1.2.3.4/32,1.2.3.5/32,192.168.0.0/16
...
then your irule could lookup the list of subnets for that matches the current URI, split it and then test the client_ip against each, if no match found, reject.
else, fall through and use default pool.
Maybe there is a much simpler way. read about class for some ideas maybe: https://devcentral.f5.com/wiki/irules.class.ashx - Rustic_57941
Nimbostratus
Thanks - I have change thins a little by creating a address-class datagroup which has the permitted IP addresses. This is used on the following iRule:when HTTP_REQUEST { if { [string tolower [HTTP::path]] contains "/web/landing_page" } { if { !([matchclass [IP::client_addr] equals Test_Allowed_IPs])} { discard } } }
This working with initial testing.
Rgds,
Mark
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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