PHP Gets a detailed description of the real client's real IP

Source: Internet
Author: User
This paper mainly introduces the method of obtaining real IP (remote_addr,http_client_ip,http_x_forwarded_for) of real client by PHP, which has good reference value. Let's take a look at the little series.

REMOTE_ADDR is the IP of your client when it "shakes hands" with your server. If you use anonymous proxy, REMOTE_ADDR displays the IP of the proxy server.

HTTP_CLIENT_IP is the HTTP header sent by the proxy server. If "Super Anonymous proxy", the value of none is returned. Similarly, REMOTE_ADDR will be replaced with the IP of this proxy server.

$_server[' REMOTE_ADDR ']; The IP of the access side (possibly the user, possibly the proxy)

$_server[' Http_client_ip ']; Agent-side (may exist, can be forged)

$_server[' http_x_forwarded_for ']; The user is the agent in which IP is used (may exist or can be forged)

The three values differ as follows:

One, not using the proxy server situation:

REMOTE_ADDR = Your IP

Http_via = no value or no display

Http_x_forwarded_for = no value or no display

Second, the use of transparent proxy server situation: Transparent Proxies

REMOTE_ADDR = Last Proxy server IP

Http_via = Proxy Server IP

Http_x_forwarded_for = Your real IP, after multiple proxy servers, this value resembles the following: 203.98.182.163, 203.98.182.163, 203.129.72.215.

This type of proxy server also forwards your information to your Access object, and does not achieve the purpose of hiding the true identity.

Third, the use of ordinary anonymous proxy server situation: Anonymous Proxies

REMOTE_ADDR = Last Proxy server IP

Http_via = Proxy Server IP

Http_x_forwarded_for = Proxy IP, after multiple proxies, this value resembles the following: 203.98.182.163, 203.98.182.163, 203.129.72.215.

Hides your real IP, but reveals to the Access object that you are using a proxy server to access them.

Iv. use of deceptive proxy servers: distorting Proxies

REMOTE_ADDR = Proxy Server IP

Http_via = Proxy Server IP

Http_x_forwarded_for = Random IP, after multiple proxy servers, this value is similar to the following: 203.98.182.163, 203.98.182.163, 203.129.72.215.

Tells the Access object that you used a proxy server, but fabricated a bogus random IP to spoof it instead of your real IP.

V. Use of highly anonymous proxy servers: High anonymity Proxies (Elite Proxies)

REMOTE_ADDR = Proxy Server IP

Http_via = no value or no display

Http_x_forwarded_for = no value or not displayed, after multiple proxy servers, this value is similar to the following: 203.98.182.163, 203.98.182.163, 203.129.72.215.

Full use of Proxy server information replaces all of your information, as if you were using the proxy server directly to access the object.

Get user Ip$ip = '; foreach (' Http_client_ip ', ' http_x_forwarded_for ', ' http_from ', ' remote_addr ') as $v) {  if ( Isset ($_server[$v]) {    if (! Preg_match ('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $_server[$v])) {        continue ;  }      $ip = $_server[$v];  }} Uset ($ip, $v);

The above is PHP to get real client real IP details of the content, more relevant content please pay attention to topic.alibabacloud.com (www.php.cn)!

  • Related Article

    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.