Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to allow anonymous from anywhere, while limiting authenticated to one or few IP blocks.

Can this be done in drupal 6?

share|improve this question
up vote 1 down vote accepted

Check "access rules" in your control panel: admin/user/rules

Adding a rule and selecting "host" you can allow or deny access by a specified IP Address (tipically allow your range then deny everything else, no implicit deny here.) Unfortunatly this is a "global option" (not user or group based) so act carefully you can shut yourself out from your own site.

share|improve this answer

This is absolutely a hack, but you could add something like the following in the login module/script (or include it) thus preventing those not in the IP range from accessing the login module:


$allowed_ips = array('','');
$client_ip = $_SERVER['REMOTE_ADDR'];

if(!in_array($client_ip,$allowed_ips)) {
    die('authentication denied'); // or you could redirect to a 403 or whatever
share|improve this answer

Looks like there is a feature request pending, however, a developer has already put together some code which may work: Support for role based IP restriction

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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