Forum Discussion
Svevak_211593
Nimbostratus
Feb 25, 2016whitelist + geoblocking in iRule
Hi,
the problem is I would like to allow some countries and some IPs from not allowed countries to get access.
I'm not quite sure why this won't work:
when CLIENT_ACCEPTED {
switch[ whereis [IP::client_addr] country ] {
"DE" { set allowed 1 }
"AT" { set allowed 1 }
"CH" { set allowed 1 }
"LI" { set allowed 1 }
"LU" { set allowed 1 }
default { set allowed 0 }
}
elseif {
if {
[matchclass [IP::client_addr] equals datagroup whitelistIP ] } {
pool datagroup-whitelistIP
}
else {
reject
}
}
Can anybody help me?
1 Reply
Hi
you may try the iRule below as a starting point...
when CLIENT_ACCEPTED { if { [class match [IP::client_addr] equals whitelistIP] } then { pool insert_your_pool_name } else { switch -exact -- [whereis [IP::client_addr] country] { "DE" - "AT" - "CH" - "LI" - "LU" { pool insert_your_pool_name } default { reject } } } }Note: Reordered the
and[if]
nestings, optimized the[switch]
command and finally changed the[switch]
(is a deprecated command) to become[matchclass]
.[class match]Cheers, Kai
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
