Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Results 1 to 8 of 8
  1. #1
    Member lvlind's Avatar
    Join Date
    Jun 2007
    Location
    Vinnica, Ukraine
    Posts
    32

    Question How to limit Access to CPanel from 1 IP?

    How to limit Access to CPanel from 1 IP? Is it possible do not use .htaccess file?
    Last edited by lvlind; 07-19-2009 at 03:57 AM.

  2. #2
    Super Moderator This forum account has been confirmed by cPanel staff to represent a vendor. chirpy's Avatar
    Join Date
    Jun 2002
    Location
    Go on, have a guess
    Posts
    13,495

    Default

    The simplest way would be to use an iptables firewall and block access to the relevant ports and only open access to those ports to specific IP addresses.
    Jonathan Michaelson

    Need your cPanel servers secured and tuned?
    cPanel Server Configuration, Security, Recovery and Antivirus/AntiSpam Services
    Developers of the most effective (and free) Firewall & Security Solution for cPanel Servers - csf
    http://www.configserver.com

  3. #3
    Member serversignature's Avatar
    Join Date
    Nov 2007
    Location
    Bangalore
    Posts
    107

    Default

    true .. you can use iptables to rate-limit incoming connections.
    Serversignature.com - Professional Linux Consulting.

  4. #4
    cPanel Partner NOC cPanel Partner NOC Badge
    Join Date
    Mar 2003
    Location
    NC
    Posts
    725
    cPanel/Enkompass Access Level

    Root Administrator

    Default

    Quote Originally Posted by serversignature View Post
    true .. you can use iptables to rate-limit incoming connections.
    Out of curiosity how would you use rate limiting to help here over just blocking all and allowing one IP?

  5. #5
    Member serversignature's Avatar
    Join Date
    Nov 2007
    Location
    Bangalore
    Posts
    107

    Default

    Limit if not from my source IP

    -s ! $MY_IP -m limit
    Serversignature.com - Professional Linux Consulting.

  6. #6
    Super Moderator This forum account has been confirmed by cPanel staff to represent a vendor. chirpy's Avatar
    Join Date
    Jun 2002
    Location
    Go on, have a guess
    Posts
    13,495

    Default

    Quote Originally Posted by serversignature View Post
    Limit if not from my source IP

    -s ! $MY_IP -m limit
    Won't that still allow non-matching IP addresses to still connect at 3/hour (the default for the --limit rate)?
    Jonathan Michaelson

    Need your cPanel servers secured and tuned?
    cPanel Server Configuration, Security, Recovery and Antivirus/AntiSpam Services
    Developers of the most effective (and free) Firewall & Security Solution for cPanel Servers - csf
    http://www.configserver.com

  7. #7
    Member serversignature's Avatar
    Join Date
    Nov 2007
    Location
    Bangalore
    Posts
    107

    Default

    Yes, that needs to be checked.

    .
    Serversignature.com - Professional Linux Consulting.

  8. #8
    BANNED
    Join Date
    Jun 2005
    Location
    Wild Wild West
    Posts
    2,025

    Exclamation

    Everyone completely lost me at the rate limiting discussion since the original poster's question about "limiting access" which almost always refers to blocking connections to all IP's except the poster's own IP address ...

    I can only speculate the reason why they would want to block other connections and it is a bit odd since it would effectively make the server only usable by the owner only and not by anyone else who might otherwise have accounts on the server. Perhaps they only have the server setup for their own use?

    However ...

    Code:
    iptables -A INPUT -s ! x.x.x.x -p tcp --dport 2082:2087 -j DROP
    (By the way, x.x.x.x is your IP address and DO NOT forget the exclamation point!)

    For those not so versed in the use of IPTABLES, the above command basically tells the firewall to drop all TCP packets destined for ports 2082 through 2087 (cpanel port) which does not originate from the given IP address.

    The above just kills connections to all except for the IP given. As for rate limiting connections though ....

    Here is a set of rules to rate limit Cpanel connections to 3 attempts per minute to all except a specific IP address PLUS if any rate limited visitor establishes any additional NEW connections beyond the allowed 3 within a 60 second period following a previous allowed connection and sends more than 5 packets, they get their connections to Cpanel dropped entirely so that will help prevent anyone trying to flood opening up Cpanel logins as well :

    Code:
    
    iptables -A INPUT -s ! x.x.x.x -p tcp --dport 2082:2087 -m state --state NEW -m recent --set
    iptables -A INPUT -s ! x.x.x.x -p tcp --dport 2082:2087 -m state --state NEW -m recent --update --seconds 60 --hitcount 5 -j DROP
    
    To ServerSignature:

    You may want to be a little more careful with those IPTABLE recommendations:
    Code:
    -s ! $MY_IP -m limit
    If someone were to use exactly what you posted, you would rate limit not just CPANEL but EVERY CONNECTION on the entire server that doesn't originate from the source IP address. That means that FTP, normal web access (ouch!), email, and completely everything will be rate limited and not just by service type either! Each and every connection made to the server that didn't originate from the specified IP address would be counted into that rate limit as a whole
    effectively bringing down the entire server and rendering it effectively useless to the outside world and also making the server virtually unable to function except for exclusive connections to the IP you specified!

    Not exactly what you were intending ey?

    If you were going to blindly rate limit the CPANEL connections to the default then I would probably do a variation of what you said something more along the lines of the following:
    Code:
    iptables -A INPUT -s ! x.x.x.x -p tcp --dport 2082:2087 -m limit
    There you have it fans! Blocking or rate limiting connections to Cpanel except for one address or CIDR range!
    Last edited by Spiral; 07-22-2009 at 11:19 PM.

Similar Threads & Tags
Similar threads

  1. Limit User Access?
    By ghv in forum cPanel and WHM Discussions
    Replies: 6
    Last Post: 08-21-2008, 03:00 PM
  2. Limit access to Munin
    By Ferdinant in forum cPanel Developers
    Replies: 0
    Last Post: 11-08-2006, 03:31 AM
  3. Limit cpanel to Mail options only... no FTP access
    By StJohn in forum cPanel and WHM Discussions
    Replies: 1
    Last Post: 01-26-2005, 10:58 AM
  4. Limit SSH Access
    By cosmin in forum cPanel and WHM Discussions
    Replies: 7
    Last Post: 09-29-2003, 07:50 AM
  5. Limit SSH Access
    By silvernetuk in forum cPanel and WHM Discussions
    Replies: 1
    Last Post: 02-12-2003, 01:00 PM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube