How can I get the IP of an incoming request?

I’m trying to get a user/request’s IP so I can only allow certain IP’s. How can I do this?