Forum Discussion
access control iRule
I cannot seem to get an access control iRule working. I am trying to limit access to a virtual server to only two external IP addresses. I have copied and modified an iRule found on F5 support site but when applied it blocks all traffic to this VS.
20 Replies
- Cory_50405
Noctilucent
Good catch mimlo. This one should work properly with parentheses:
when CLIENT_ACCEPTED { if { ! ([IP::addr [IP::client_addr] equals 10.10.10.10] or [IP::addr [IP::client_addr] equals 10.10.10.20])} { reject log local0. "Connection dropped from [IP::client_addr]" } } - Terry_Schmidt_1
Nimbostratus
good enough. It let me load this latest iRule and we are currently testing. If this works in dev then we'll apply to prod.
- Terry_Schmidt_1
Nimbostratus
unfortunately this iRule blocked all traffic to this VS.
- Cory_50405
Noctilucent
Stupid question but did you change the IP addresses in the rule to the two hosts that you want to permit?
- Kevin_Davies_40
Nacreous
Just another way of doing the same...
when CLIENT_ACCEPTED { switch [IP::client_addr] { 10.10.10.10 - 10.10.10.20 { return } } reject log local0. "Connection rejected from [IP::client_addr]" } - Terry_Schmidt_1
Nimbostratus
Valid question Cory, but yes, I am replacing the 10.x.x.x addresses with two external addresses with 67.x.x.x and 65.x.x.x. I'll keep working on this.
- Cory_50405
Noctilucent
Is the iRule logging the rejection messages to /var/log/ltm from the two IP addresses you have specified that should be permitted?
- Terry_Schmidt_1
Nimbostratus
Thanks Cory, but I think we have solved this by using this code:
when CLIENT_ACCEPTED { if { not ( [class match [IP::client_addr] equals rtp_allow] ) } { reject } }
This has a Data Group (rtp_allow) with the two IP address in it that are to be allowed. In testing we were able to include my IP address in this Data Group and I was able to access the internal web server page and when my IP address gets removed from the Data Group the web page is not available.
- Cory_50405
Noctilucent
That's a good scaling solution if you want to add more addresses to it moving forward. Glad to hear you got it working.
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