allow users from specific static ip
We already completed the site. The problem is The site is having 3 logins . one is the main super admin for the client another two is for college admin .(Colleges will login here) & their students. All the works are completed.
For example: College IP:
172.16.4.1
172.16.1.101
This college should not be able to login except from this 开发者_Go百科IP
.
And there might be many college and each college can login only from there static IP
.
will it be possible.
Thanks
Since there is no language mentioned, I give a sample in php
function canLogin() {
$allowed = array ('172.16.4.1', '172.16.1.101');
if (in_array ($_SERVER['REMOTE_ADDR'], $allowed)) return 1;
else return 0;
}
All you have to do is find the REMOTE_ADDR (user IP) and check if it is in approved list.
Note: It is possible to spoof remote address. But the above sample is simpler solution and better than nothing.
精彩评论