1

I need to find out my web hosting server's IP address. Its on a shared hosting server and from experience, it's usually not the same as the incoming IP address that you would get by just pinging the domain name. Is there a php script I can run or something to find our the outbound IP address my website is using when connecting to a SMTP server for example?

1
  • Who is the host?
    – SgtOJ
    Nov 28, 2010 at 12:31

4 Answers 4

4

I have success when I try

curl -s ip.appspot.com

Or with PHP:

<?php
echo file_get_contents("http://ip.appspot.com");
?>
3

You could do a web request from code (PHP or other) and request a URL such as www.whatismyip.com and save it as a file that you open and look at.

Reading Remote URL HTML Source in PHP shows some examples. If your PHP installation allows for it, then this could be as simple as creating a file with the following, and then point your browser to it:

<?php
  // See http://www.whatismyip.com/automation for the exact URL
  echo file_get_contents(
    "http://www.whatismyip.com/automation/n09230945.asp");
?>
2
0

The host server outbound IP address is the one you see when you ping it, regardless of whether the shared host is name or IP based.

  • For name based shared hosts (all websites share the same IP), the user agent will add the hostname to its requests, which will allow the server to determine which website to show.

  • For IP based shared hosts (each website has its own IP), name resolution is straightforward.

If you are looking instead for the internal IP address used by your server in its network, this information can be accessed by connecting to your server through a secure shell, which most web hosts provide.

-1

I think you are looking for this...

<?php echo $_SERVER['SERVER_ADDR']; ?>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .