Forum Discussion
tyntwitch_13422
Nimbostratus
Dec 04, 2013Block request by IP and send an HTTP response
Just getting into iRules and I want to block a specific IP from being able to access a webpage but return an HTTP response back to the browser. I am attempting to do this, but still not quite getting...
uni
Altocumulus
Dec 04, 2013The CLIENT_ACCEPTED event is not required. [IP::client_addr] is available in the HTTP_REQUEST event. There is a bracket missing after the 'if' in the HTTP_REQUEST event. You should use the IP::addr command to compare IP addresses
when HTTP_REQUEST {
if {[IP::addr [IP::client_addr] equals 172.18.33.226]} {
HTTP::respond 200 content "${static::IPBlock}"
}
}
Your use of a static variable to hold the response is ok, but I would consider using an iFile, which makes it easier to manage.
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