The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Deny all ip, except allowed

Discussion in 'General Discussion' started by redwood, Feb 12, 2009.

  1. redwood

    redwood Member

    Joined:
    Apr 4, 2007
    Messages:
    16
    Likes Received:
    0
    Trophy Points:
    1
    One of my customers runs an application on one of our cPanel servers, and he wants the following.

    Specify the IP's which have access. So that his office,employees and homecomputer can access them, and deny all other ip's.

    Is this possible? Ofcourse there is the IP DENY MANAGER but that one is for the ip's to deny. I want something for the ip's that are only allowed!

    Thank you
     
  2. arunsv84

    arunsv84 Well-Known Member

    Joined:
    Oct 20, 2008
    Messages:
    373
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    127.0.0.1
    cPanel Access Level:
    Root Administrator
    You can block or allow IP addresses from accessing the site by adding the following lines in .htaccess file.

    order deny,allow
    deny from 192.168.1.40

    The order directive set the order in which the allow and deny directives will be processed and also the default access control state. In the above case, the default access control state is allow, which means everyone can access the site and the deny directives will be processed before the allows. It is possible to specify more than one deny or allow directives, like

    order deny,allow
    deny from 192.168.1.40
    deny from 192.168.1.41

    It will block access from those IPs to the site. It is also possible to specify partial IP address, like

    order deny,allow
    deny from 192.168.1

    In this case, it will block the access from 192.168.1.0 - 192.168.1.255 range.

    We can also specify IP range in network/netmask or CIDR notation, like
    order deny,allow
    deny from 192.168.1.0/255.255.255.0 or deny from 192.168.1.0/24

    In the above examples, all type of http methods will be blocked from those IP addresses. If you only want to restrict certain methods say POST, PUT, DELETE from the IP address, you need to use the limit directive.

    <Limit POST PUT DELETE>
    order deny,allow
    deny from 192.168.1.40
    </Limit>

    Hope this helps...:)

    Cheers!!!
     
    #2 arunsv84, Feb 12, 2009
    Last edited: Feb 12, 2009
  3. redwood

    redwood Member

    Joined:
    Apr 4, 2007
    Messages:
    16
    Likes Received:
    0
    Trophy Points:
    1
    Thanks... i've just read some htaccess about this,
    What i need is something like this, would it work?

    order deny,allow
    deny from all
    allow from 192.168.1.41
    allow from 192.168.138.9

    In this case, only the 192.168.1.41 & 192.168.138.9 can that domain.

    Is this right?
     
  4. arunsv84

    arunsv84 Well-Known Member

    Joined:
    Oct 20, 2008
    Messages:
    373
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    127.0.0.1
    cPanel Access Level:
    Root Administrator
    #4 arunsv84, Feb 12, 2009
    Last edited: Feb 12, 2009
  5. britsenigma

    britsenigma Well-Known Member

    Joined:
    Dec 14, 2008
    Messages:
    85
    Likes Received:
    0
    Trophy Points:
    6
    by "application" do you mean something running through the web server, or is it a daemon or something like that?
     
  6. redwood

    redwood Member

    Joined:
    Apr 4, 2007
    Messages:
    16
    Likes Received:
    0
    Trophy Points:
    1
    it's an php application. It's password protected and now ip protected ;-)

    Thanks for the help arunsv84
     
  7. arunsv84

    arunsv84 Well-Known Member

    Joined:
    Oct 20, 2008
    Messages:
    373
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    127.0.0.1
    cPanel Access Level:
    Root Administrator
    You are always welcome... :)
     
Loading...

Share This Page