Drupal is a registered trademark of Dries Buytaert
Protected Pages 3.0.0 Major update available for module protected_pages (3.0.0). Commerce Core 3.3.8 Minor update available for module commerce (3.3.8). Search API HTML Element Filter 1.0.7 Minor update available for module search_api_html_element_filter (1.0.7). Layout Builder Reorder 2.0.1 Minor update available for module layout_builder_reorder (2.0.1). Ban 1.1.0 Minor update available for module ban (1.1.0). Field Formatter Range 2.0.0 Major update available for module field_formatter_range (2.0.0). Field Formatter Range 8.x-1.8 Minor update available for module field_formatter_range (8.x-1.8). Varbase Media Header 9.2.1 Minor update available for module varbase_media_header (9.2.1). Search API Solr 4.3.11 Module search_api_solr updated after 14 months of inactivity (4.3.11). Provus Mega Menu Module provus_mega_menu crossed 1,000 active installs.

This module allows site administrators to block access to their Drupal site based on a user's country of origin, using the Smart IP module to determine location. Administrators can create a list of countries to block and set a custom message for users who are denied access.

This module allows site administrators to block access to their Drupal site based on the user's country of origin. It uses the Smart IP module to determine the user's location from their IP address. If a user is visiting from a country on the blocklist, they will be denied access and shown a configurable message.

Features

This module provides a simple yet effective way to control access to your site based on geography.

  • Block by Country: Easily block entire countries using a simple list of country codes.
  • Configurable Blocklist: An administrator can add or remove countries from the blocklist through a user-friendly interface.
  • Customizable Message: Set a custom message that will be displayed to users who are denied access.
  • Permission-based Access: Configuration is protected by a dedicated permission, ensuring only authorized users can change the settings.

This module is ideal for sites that need to restrict content based on regional licensing, comply with legal requirements, or reduce malicious traffic from specific parts of the world.

Post-Installation

Once installed, follow these steps to configure the module:

  1. Set Permissions: Navigate to the permissions page
    (/admin/people/permissions) and grant the "Administer Country Block" permission to the appropriate user roles (e.g., Administrator).
  2. Configure Settings: Go to the module's configuration page at /admin/config/system/country-block.
  3. Add Blocked Countries: In the "Blocked Countries" text area, enter the two-letter country codes (ISO 3166-1 alpha-2) for the countries you wish to block. Each code should be on a new line. For your convenience, the form includes a link to a list of country codes.
  4. Customize the Message: In the "Blocked Message" field, you can edit the default message that will be shown to users from a blocked country.
  5. Save: Click "Save configuration". The country block is now active.

Additional Requirements

This module requires the following:

  • Smart IP (smart_ip) module: This module is essential for identifying the user's country based on their IP address. The Smart IP module itself requires a configured data source (e.g., a GeoIP database) to function correctly. Please follow the installation and configuration instructions for the Smart IP module.

There are no other recommended modules for this project. However, it is highly recommended to keep the GeoIP database used by the Smart IP module up-to-date to ensure accurate country detection.

Similar projects

While other modules may provide geographic tools, Country Block is focused on simplicity and ease of use for one specific task: blocking countries. Modules like IP-based Determination of Country, City, and Language offer broader location data but do not provide a direct blocking mechanism. Country Block is a lightweight solution for those who need a simple "on/off" switch for country access.

πŸ‡ΊπŸ‡¦

This module is maintained by Ukrainian developers.

Please consider supporting Ukraine in the fight for their freedom and the safety of Europe.

Activity

Total releases
6
First release
Feb 2026
Latest release
5 months ago
Releases (12 mo)
6 ▲ from 0
Maintenance
Active

Release Timeline

Releases

Version Type Release date
1.0.4 Stable Feb 8, 2026
1.0.x-dev Dev Feb 8, 2026
1.0.3 Stable Feb 8, 2026
1.0.2 Stable Feb 7, 2026
1.0.1 Stable Feb 7, 2026
1.0.0 Stable Feb 7, 2026