Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6751123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:53:23+00:00 2026-05-26T12:53:23+00:00

I often hear people say to use $_SERVER[‘SERVER_ADDR’] , but that returns the LAN

  • 0

I often hear people say to use “$_SERVER['SERVER_ADDR']“, but that returns the LAN IP of my server (e.g. 192.168.1.100). I want the external IP.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T12:53:24+00:00Added an answer on May 26, 2026 at 12:53 pm

    Just query a host that returns your IP address:

    $externalContent = file_get_contents('http://checkip.dyndns.com/');
    preg_match('/Current IP Address: \[?([:.0-9a-fA-F]+)\]?/', $externalContent, $m);
    $externalIp = $m[1];
    

    or, set up a service that simply echoes just the IP, and use it like this:

    $externalIp = file_get_contents('http://yourdomain.example/ip/');
    

    Set up the service yourself by simply echoing the remote IP address, or pay someone to host it. Do not use somebody else’s server without permission. Previously, this answer linked to a service of mine that’s now being hit multiple times a second.

    Note that in an IP network with one or more NATs, you may have multiple external IP addresses. This will give you just one of them.

    Also, this solution of course depends on the remote host being available. However, since there is no widely implemented standard (no ISP and only some home routers implement UPnP), there is no other way to get your external IP address. Even if you could talk to your local NAT, you couldn’t be sure that there isn’t another NAT behind it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I often hear around here from test driven development people that having a function
I often hear complaints that programming languages that make heavy use of symbols for
I often hear people bashing ORMs for being inflexible and a leaky abstraction, but
I often hear a Model must be wrapped by a ViewModel that the View
I often hear people complain how expensive MATLAB licenses are. Then I wonder why
I often hear people praise languages, frameworks, constructs, etc. for being explicit. I'm trying
I often hear that mongodb can perform atomicity at one collection level. Do you
I often hear/read about interfaced based programming but I am not exactly clear on
I often hear developers say C# functions are very powerful. Having heard this so
I use Mac as my primary OS, but I often work on ASP.NET MVC

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.