Is it possible to restrict the login or role access by IP in drupal 7.Is there any module available in drupal 7 to provide similar functionality Restrict Login Any one guide me do this.


  • If there is no current D7 method for this, I have this on my todo list, and was hoping to get it in in the next month or two.
    – mpdonadio
    Jan 24, 2012 at 17:13
  • I’m voting to close this question because it asks to find, recommend, or suggest hosting providers, tools, modules, themes, distributions, books, tutorials, documentation, or other off-site resources.
    – apaderno
    Dec 15, 2022 at 10:10

2 Answers 2


I don't know of a module for Drupal 7.

However, you can add your IP check by implementing hook_form_alter for the login form. Just add a validate call back for your IP. See this post about some more information about hook_form_alter.


Check out the Restrict IP module.

This module allows administrators to restrict access to the site to an administrator defined set of IP addresses. Anyone trying to access the site from an IP address not in the list of allowed IP addresses will be redirected to an access denied page with the message "Your address is not in the list of allowed IP addresses". No blocks will be rendered, and no JavaScript will be added to the page. This will happen for any and all pages these users try to access. The module also has various configuration options to whitelist or blacklist pages, bypass IP checking by role, and alter the output when the user is blocked.

Not the answer you're looking for? Browse other questions tagged or ask your own question.