Forum Discussion
Subhajit1107_38
Nimbostratus
Apr 11, 2019iRule to block IP and URL
Hi,
I want an iRule to block a set of IP's hitting a set of url's and log the blocking Could you please check the below iRule and update if any error.
when HTTP_REQUEST {
set url [HTTP::host][HTTP::uri]
if {[class match $url contains blocklist_url] and [class match [IP::client_addr] equals restrict_ip]} {
drop
log local0. "Blocking clientIP:[IP::client_addr] trying to access $url"
}
}
- Lee_Sutcliffe
Nacreous
The variable $url will not contain the protocol (HTTP or HTTPS)
It will contain a value such as this:
This isn’t an issue but you need to make sure you have configured your data group to use this format.
Other than that, looks ok. Just try it!
- youssef1
Cumulonimbus
Hi,
It looks ok, you confirm that you ant to block a specific IP AND URL (AND and not OR)?
You can also achieve your need using ltm Policy...
regards
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