I need to see if a request is coming from a certain domain (www.domain.com).
So far, I only know how to get the IP address of the request (by using the request.getRemoteHost() method). The problem is that one domain might map to a lot of different IP addresses (for balance purposes), so I can not do something like this:
request.getRemoteHost().equals("200.50.40.30")
because there might be different IP address returned by the DNS when it resolves http://www.domain.com.
I want to be able to do something like this:
request.getRemoteHost().equals("www.domain.com")
But so far, I have no clue (and Google didn’t help me) on how to do that.
Does somebody have any ideas??
Thank you in advance! 🙂
After contacting the domain I was trying to verify the request was coming from, they provided me the whole range of IPs their servers might start a request from. Having all those IPs and masks in hands, this is what I did to verify the request was coming from them:
Hope this code also helps someone!