tyntwitch_13422
Dec 04, 2013Nimbostratus
Block 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 it right. Can anyone offer a suggestion that would help?
when RULE_INIT {
set static::IPBlock "ServerServer Error`-999999 `
API traffic is currently blocked. Please contact your System Administrator for assistance. BLOCKBLOCK 0
DISTRIBUTION MESSSAGE "
}
when CLIENT_ACCEPTED {
if { [IP::addr [IP::client_addr] equals 172.18.33.226] } {
set clientIP [IP::client_addr]
}
when HTTP_REQUEST {
if {$clientIP eq 172.18.33.226}
HTTP::respond 200 content "${static::IPBlock}"
}
}