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

Say I'd like to restrict access to a virtual host to multiple IP ranges. How to do that? The Perl regex syntax style doesn't work, and i don't want loose restrictions like 10.*

The code below works for a single range:

$HTTP["host"] == "adm.example.org" {
    $HTTP["remoteip"] != "10.0.0.0/28" {
            url.access-deny = ( "" )
        }
}

Thanks in advance.

share|improve this question
    
I really need ranges, not single IP addresses. –  weeheavy May 3 '10 at 12:47

2 Answers 2

up vote 3 down vote accepted
$HTTP["remoteip"] !~ "192.168.2.*|192.168.0.*|10.8.9.*" {
  url.access-deny = ( "" )
}

or to include for the 192.168.0.0 network only this range: 192.168.0.180 - 192.168.0.188

$HTTP["remoteip"] !~ "192.168.2.*|192.168.0.18[0-8]|10.8.9.*" {
  url.access-deny = ( "" )
}
share|improve this answer
    
This is it! I used your first configuration, this does what I need. Thanks very much. –  weeheavy Jun 14 '10 at 8:38
$HTTP["host"] == "adm.example.org" {
    $HTTP["remoteip"] != "1.2.3.4|5.6.7.8|9.10.11.12" {
            url.access-deny = ( "" )
        }
}

And so forth

share|improve this answer
    
This may work with IP addresses but doesn't with IP ranges. If I do it like that, access is allowed from everywhere. –  weeheavy May 3 '10 at 12:42

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.