This is more theory than code but I was wondering if I wanted to make a secure website, game or web application etc and I wanted to use IP to protect what ever it was, how would I go about doing it. A lot of things on the web use IP's for security but I couldn't think through a perfect system of how to do it.
The easiest way I could think of is just to log each users IP every time they log in but what if they log in using a proxy and then stop using the proxy and therefore not have there real IP logged, should I just the IP on every page load? But then there's a problem if they always use a proxy IP and therefore I can never log their real IP and therefore 1 person could be 2 users and the IP's wouldn't show that. But then again it works the other way as well, what happens if 2 people have the same IP but are different people using different computers with a shared IP which some hosts do.
Finally what happens if I want to IP ban someone and it stops everyone from that IP accessing the website, say if it was a public library, school or again just a shared IP address.
What's the best way of using IP's for security?