Forum Discussion
mbamusa_59409
Nimbostratus
Jan 24, 2012Restrict Access based on country using LTM or ASM
hi all;
could you please help me to find a way to restrict access to virtual server for some countries using irule and GEOLocation Data Base .
thank you
Mbamusa
9 Replies
- frank_30469
Nimbostratus
Hello,
you can find more info on how to use this on: http://devcentral.f5.com/wiki/iRules.whereis.ashx - Arie
Altostratus
mbamusa, can you work with Frank's answer or do you need additional information and/or help? - mbamusa_59409
Nimbostratus
thank you Frank and Arie for the support , but could you please provide me an example (i.e. restrict access comes from China and Russia ) - hoolio
Cirrostratus
Here's a positive example:when CLIENT_ACCEPTED { Get the country client IP switch [whereis [IP::client_addr] country] { US - CA - MX { set allowed 1 } default { set allowed 0 } } } when HTTP_REQUEST { if {$allowed == 0}{ HTTP::respond 403 content {Blocked!} } }
And here's a negative example:when CLIENT_ACCEPTED { Get the country client IP switch [whereis [IP::client_addr] country] { "CN" - "RU" { set allowed 0 } default { set allowed 1 } } } when HTTP_REQUEST { if {$allowed == 0}{ HTTP::respond 403 content {Blocked!} } }
If you don't need to send an HTTP response you can use reject to reset the TCP connection:when CLIENT_ACCEPTED { Get the country client IP switch [whereis [IP::client_addr] country] { "CN" - "RU" { Reset the TCP connection reject } } }
Aaron - nitass
Employee
can you try this?[root@ve1023:Active] config b rule myrule list rule myrule { when CLIENT_ACCEPTED { switch [whereis [IP::client_addr] country] { CN - RU { drop } default { do something else } } } } - nitass
Employee
oops! my page was not updated. Aaron's one is nicer. please follow his. :-) - mbamusa_59409
Nimbostratus
Thank You All for your kind Support , i'll Try the IRule and I'll get back to you with the result .
mbamusa - mbamusa_59409
Nimbostratus
Dear All;
i tried hoolio's Irule and it's working perfect thank you all for your kind support .
mbamusa - Vijith_182946
Cirrostratus
I think iRule take a lots of resources, you should try the ASM geolocation feature before u make up your mind on iRule. The detailed write is here.
Cheers
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
