Restricted Access based on IP Address in website with cPanel

In some project, we want to only allow few up address to use our system. In that case, up address restrictions are mandatory. We can do this using cPanel.

This is mostly used for in-house web applications to only work in the office network. This is also a situation where we want to use IP address level restrictions. These restrictions will completely block access to the website or web application. So now let’s see how to actually do this thing.

It is very simple to do. Only you have to put the IP address or range of IP address to block.

Step 1: login to cPanel.

Step 2: find IP blocker option.

Step 3: enter the IP address or range of IP address.

Step 4: click on add button.

Not using cPanel

Now if you are not using cPanel and using the unmanaged server. And still, you want to block the IP address then you need to block using PHP or other programming languages if you are using asp.net or Java. But the logic will remain the same. So I will show you a demo of PHP to block access.

<?php
   $ip = $_SERVER['REMOTE_ADDR'];
   $block_ip = array("192.168.1.200");
   foreach($block_ip as $i){
     if($ip == $i){
      die();
     }
   }
?>

 

2 thoughts on “Restricted Access based on IP Address in website with cPanel”

  1. Greetings from Colorado! I’m bored at work so I
    decided to browse your blog on my iphone during lunch break.
    I love the information you present here and can’t wait to take
    a look when I get home. I’m surprised at how quick your blog loaded on my phone ..
    I’m not even using WIFI, just 3G .. Anyways, great
    blog!

Leave a Reply

Your email address will not be published. Required fields are marked *

Please wait...

Subscribe to our newsletter

Want to be notified when our article is published? Enter your email address and name below to be the first to know.