I have created a website for the company where I work.
I would like to restrict access to the user preset with subnet mask. Is this possible with PHP?. The IP is known.
I have created a website for the company where I work. I would like
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The way you’ve asked the question? No. You cannot determine the client’s subnet mask from the server side.
You can, however, define your own network and mask on the server side to match client IPs against to determine whether or not to grant access. You should first read up on how subnetting works, then use the
ip2long()function and bitwise operations to grant access to particular network segments.Honestly though, the majority of the time when you want to restrict access by IP address you’re going to want to do this at the network/firewall level, not in the application.