I am developing a web system for my school (it's in PHP, but that's not important).
The system needs to have different behaviors depending on whether or not the user is on the school network (specifically, if they are not on the school network, they need to log in).
So I need a reliable, ideally foolproof (that may be asking too much...) way of checking whether clients are on the local network.
It seems that the usual way of doing this is comparing the user's subnet to the server's subnet. However, our school has multiple subnets (including multiple campuses each with multiple subnets as well as VPN), only one of which is the server's subnet. So that method won't work
I read RFC1918, which reserves the following IP spaces for private networks:
10.*.*.*
172.16.*.* - 172.31.*.*
192.168.*.*
So could I just check if the client IP is within any of these private subnets? Is there any possibility that users outside of the network could have such an IP? Or that users connected to the school network would not have an IP in one of those ranges?