IP banning prevents users with specified IP addresses from using your website. Kentico CMS provides these levels of IP address banning:
Access to the website - users with the specified IP address cannot access the site at all.
Login - users cannot log in to the site.
Registration - users cannot register on the site.
All user actions - users can enter the site, but they are not allowed to register or log in, and they are not allowed to add any content to the site (e.g., blog comments, board messages, etc.).
How IP banning works
In Site Manager -> Administration -> Banned IPs, you can specify, which addressed will be banned. When typing an IP address, you can use the asterisk (*) wildcard character to cover a range of IP addresses (for example, 192.168.0.*).
If a user has the Access to the website ban type, then the user gets redirected when trying to access your website. Other IP ban types are handled by individual modules and parts of the system. The user gets usually informed about not being able to complete the given action (log in or register).
The IP address is provided by the HTTPHelper.UserHostAddress property, which is a value either set in the system, or obtained from the .NET (HttpContext.Current.Request.UserHostAddress).
When you ban an IP address globally, you have an option to Allow sites to overwrite the ban. This way, the site administrators can cancel the global ban (using the Allow IP address for this site if the IP address is banned globally option) on their sites.
Banned IPs are fully integrated into the system and affect all modules.
Banned IPs integration
If you want to integrate the IP banning module into your own code or modules, use the BannedIPInfoProvider.IsAllowed method:
if (!BannedIPInfoProvider.IsAllowed(CMSContext.CurrentSiteName, BanControlEnum.Complete))
// User is completely banned