Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

Country Block

Security covered Maintenance fixes only 8 sites

Part of the Country ecosystem · 6 projects

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.
Drupal 10–11

Ask your assistant about Country Block

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

Depends on

Dependencies of the latest stable release

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
7
Tracked since
Feb 2026
Latest release
2 weeks ago
Releases (12 mo)
7 ▲ from 0
Maintenance
Active

Release Timeline

Releases

Version Type Core PHP Release date
1.0.5 Stable 10–11 Sep 30, 2026
1.0.4 Stable 10–11 Feb 8, 2026
1.0.x-dev Dev 10–11 Feb 8, 2026
1.0.3 Stable 10–11 Feb 8, 2026
1.0.2 Stable 10–11 Feb 7, 2026
1.0.1 Stable 10–11 Feb 7, 2026
1.0.0 Stable 10–11 Feb 7, 2026