Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

3 Answers 3

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:

<?php

$allowed_ips = array('1.2.3.4','5.6.7.8');
$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

 
discard

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.