Old problem of getting the Internet IP address of the local machine

Source: Internet
Author: User
The problem of getting the Internet IP address of the local machine is the same as that in the previous post.
Various methods to obtain the local Internet ip address, a variety of return: 1.
Most of them are caused by ipv6. However, the computer cannot access the Internet.
I don't know if there are any solutions besides interfaces.


Reply to discussion (solution)

Ipv6: 1, which is the ipv4 127.0.0.1
I don't know how you did it.

What do you get is ipv6?

Ipv6: 1, which is the ipv4 127.0.0.1
I don't know how you did it.


Du Niang "local internet IP address php" will show a solution to n, the following screenshot is an example:
function get_onlineip() { $onlineip = ''; if(getenv('HTTP_CLIENT_IP') && strcasecmp(getenv('HTTP_CLIENT_IP'), 'unknown')) { $onlineip = getenv('HTTP_CLIENT_IP'); } elseif(getenv('HTTP_X_FORWARDED_FOR') && strcasecmp(getenv('HTTP_X_FORWARDED_FOR'), 'unknown')) { $onlineip = getenv('HTTP_X_FORWARDED_FOR'); } elseif(getenv('REMOTE_ADDR') && strcasecmp(getenv('REMOTE_ADDR'), 'unknown')) { $onlineip = getenv('REMOTE_ADDR'); } elseif(isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], 'unknown')) { $onlineip = $_SERVER['REMOTE_ADDR']; } return $onlineip; } var_dump(get_onlineip());

The local machine is from Wuhan, and the intention is to obtain the IP address of the local machine: 27.19.xxx.xxx such as Wuhan telecom of Hubei province. I don't know much about $ _ SERVER either. It runs on localhost, so it appears: 1 is because of ipv6 or localhost, and I am not very clear about it. You can leave this question alone, because you only want to get an IP address like 27.19.xxx.xxx from php.

Trouble

You can only get: 1, 127.0.0.1, or the ip address of your machine when accessing the local machine.
The Internet ip address must be accessed from the Internet.

In Linux, run "curl ifconfig. me" in php to obtain the Internet IP address.

You can only get: 1, 127.0.0.1, or the ip address of your machine when accessing the local machine.
The Internet ip address must be accessed from the Internet.


Well, someone else told me about it.
I am surprised that Du Niang's "local internet IP address" will give me the IP address of 27.19.xxx.xxx. I don't have a page for him to access to get my Internet IP address, so I cannot use ipconfig in cmd.
How does Niang Nadu get "27.19.xxx.xxx?

In Linux, run "curl ifconfig. me" in php to obtain the Internet IP address.


Thank you ~~ The currently used wamp environment.

When you access him, do you use an Internet ip address?

When you access him, do you use an Internet ip address?


Understand .. 3Q ..

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.