-2

Without knowing much about system administration, here is in short what I noticed: running nslookup the-site.com returns some IP but running $_SERVER['SERVER_ADDR'] on that site returned different IP.

Could someone give a possible explanation of why is this difference?

Longer version: Why I'm asking this? I was trying to white-list a clients IP form my security plugin (on WordPress), but even after white-listing IP I got from nslookup he still seemed blacklisted. I then tried white-listing the IP returned by $_SERVER['SERVER_ADDR'] (executed on his site) and that did the trick.

Thanks!

lyros
  • 101
  • 1
  • This question is a bit unclear. A white-list isn't necessary unless you have introduced some blocking in the first place. And you haven't told us where you are blocking connections and what criteria that is based on. – kasperd Apr 14 '17 at 15:03
  • What is your web server and what is its configuration? How is the server set up? – Tero Kilkanen Apr 14 '17 at 15:28
  • Hi @kasperd, that's not important for my question. I use a wordpress plugin for security and blacklisitng/whitelisting among others. Question is pretty clear, why the other site that tries to connect to my site (why and how doesn't matter) has different IPs with nslookup and $_SERVER['SERVER_ADDR']. Tero Kilkanen, my server config has nothing to do, other site's server seems to have, and as I'm not an expert, I would like just some simple suggestions as in the accepted answer. Thanks for your interest guys! – lyros Apr 15 '17 at 16:17

1 Answers1

2

The PHP server variable $_SERVER['SERVER_ADDR'] is set by the webserver on which your PHP code is executed.

There are many situations in which the actual webserver that runs your code will have a different ip-address from the one associated with the DNS domain name in the URL:

  • The site is behind a CDN like CloudFront.
  • The site is behind a load-balancer
  • The site is behind a reverse proxy server
  • etc.
HBruijn
  • 77,029
  • 24
  • 135
  • 201