Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
    
Who is the host? –  SgtOJ Nov 28 '10 at 12:31
add comment

4 Answers 4

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");
?>
share|improve this answer
2  
See also whatismyip.com/automation which currently refers to whatismyip.com/automation/n09230945.asp for use in scripts. –  Arjan Nov 28 '10 at 12:47
    
Awesome answer, but that URL (whatismyip.com/automation) doesn't work anymore. Why not just leave it as http://www.whatismyip.com? Then you'll see the same page you would see if you navigated there in your browser, except with the server's IP instead of yours. –  regularmike Oct 22 '13 at 16:24
add comment

I have success when I try

curl -s ip.appspot.com
share|improve this answer
add comment

I think you are looking for this...

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

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.