1. if the proxy server is not used: REMOTE_ADDR your IPHTTP_VIA has no value or does not show HTTP_X_FORWARDED_FOR no value or does not show 2...
I. no proxy server is used:
REMOTE_ADDR = your IP address
HTTP_VIA = no value or no Display
HTTP_X_FORWARDED_FOR = no value or no Display
II. Transparent Proxy Server: Transparent Proxies
REMOTE_ADDR = IP address of the last proxy server
HTTP_VIA = proxy server IP address
HTTP_X_FORWARDED_FOR = your real IP address. when multiple proxy servers are used, this value is similar to the following: 203.98.1820.3, 203.98.1820.3, 203.129.72.215.
This type of proxy server still forwards your information to your access object, which cannot hide your real identity.
III. normal Anonymous proxy server: Anonymous Proxies
REMOTE_ADDR = IP address of the last proxy server
HTTP_VIA = proxy server IP address
HTTP_X_FORWARDED_FOR = proxy server IP address. when multiple proxy servers are used, this value is similar to the following: 203.98.1820.3, 203.98.1820.3, 203.129.72.215.
Your real IP address is hidden, but you are disclosed to the access object that you use the proxy server to access them.
IV. destorting Proxies
REMOTE_ADDR = proxy server IP address
HTTP_VIA = proxy server IP address
HTTP_X_FORWARDED_FOR = random IP address. when multiple proxy servers are used, the value is as follows: 203.98.182.163, 203.98.182.163, 203.129.72.215.
It tells the access object that you used the proxy server, but fabricated a false random IP address instead of your real IP address to cheat it.
5. High Anonymity Proxies (Elite proxies)
REMOTE_ADDR = proxy server IP address
HTTP_VIA = no value or no Display
HTTP_X_FORWARDED_FOR = no value or no value is displayed. when multiple proxy servers are used, the value is similar to the following: 203.98.182.163, 203.98.182.163, 203.129.72.215.
Instance
/*** Obtain the real IP address of the user ** @ access public * @ return string */function real_ip () {// initialize a variable $ realip static $ realip = NULL; // if $ realip is not true or NULL, the returned if ($ realip! = NULL) {return $ realip;} // if $ _ SERVER has a value if (isset ($ _ SERVER )) {// if $ _ SERVER ['http _ X_FORWARDED_FOR '] has a value // indicates that the client accesses the Internet through proxy if (isset ($ _ SERVER ['http _ X_FORWARDED_FOR']) {// Use The explode () function to split the 'and' into arrays $ arr = explode (',', $ _ SERVER ['http _ X_FORWARDED_FOR ']); /* obtain the first non-unknown valid IP string in X-Forwarded-For * // Start to traverse the array foreach ($ arr AS $ ip) {// remove the blank space at the beginning and end $ ip = trim ($ ip); // either unknown or the real Internet address, save the value and exit the loop if ($ ip! = 'Unknown ') {$ realip = $ ip; break ;}}} // $ _ SERVER ['http _ X_FORWARDED_FOR '] has no value and // $ _ SERVER ['http _ CLIENT_IP'] has a value, take the value as the real IP elseif (isset ($ _ SERVER ['http _ CLIENT_IP ']) {$ realip = $ _ SERVER ['http _ CLIENT_IP'];} // $ _ SERVER ['http _ X_FORWARDED_FOR '] no value (not used as a proxy to access the Internet) and // $ _ SERVER ['http _ CLIENT_IP '] does not have a value for else {// if $ _ SERVER ['remote _ ADDR'] has a value, take the value as the real IP if (isset ($ _ SERVER ['remote _ ADDR ']) {$ realip = $ _ SERVER ['R EMOTE_ADDR '];} no else // returns '0. 0.0.0 '{$ realip = '0. 0.0.0 ';}}// $ _ SERVER has no else value {// If getenv ('http _ X_FORWARDED_FOR ') if (getenv ('http _ X_FORWARDED_FOR ') {$ realip = getenv ('http _ X_FORWARDED_FOR ');} // If getenv ('http _ CLIENT_IP ') is not empty, use its value as the real IP elseif (getenv ('http _ CLIENT_IP ')) {$ realip = getenv ('http _ CLIENT_IP ');} // otherwise, take the value of getenv ('remote _ ADDR') as the real IP else {$ realip = getenv ('remo TE_ADDR ') ;}} preg_match ("/[d.] {7, 15}/", $ realip, $ onlineip); // why is this sentence used? Please kindly advise. $ Realip =! Empty ($ onlineip [0])? $ Onlineip [0]: '0. 0.0.0 '; // why is this sentence used? Please advise. Return $ realip ;}
Recently, a problem occurred when obtaining the IP address of the browser client. The main phenomenon is that the IP address of a client using Beijing Telecom in Wuhan cannot be accessed by my program, I checked some information and modified it. The main difference between the three attributes (HTTP_X_FORWARDED_FOR, HTTP_VIA, and REMOTE_ADDR) of the IP address obtained by c # is analyzed as follows:
I. no proxy server is used:
REMOTE_ADDR = your IP address
HTTP_VIA = no value or no Display
HTTP_X_FORWARDED_FOR = no value or no Display
II. Transparent Proxy Server: Transparent Proxies
REMOTE_ADDR = IP address of the last proxy server
HTTP_VIA = proxy server IP address
HTTP_X_FORWARDED_FOR = your real IP address. when multiple proxy servers are used, this value is similar to the following: 203.98.1820.3, 203.98.1820.3, 203.129.72.215.
This type of proxy server still forwards your information to your access object, which cannot hide your real identity.
III. normal Anonymous proxy server: Anonymous Proxies
REMOTE_ADDR = IP address of the last proxy server
HTTP_VIA = proxy server IP address
HTTP_X_FORWARDED_FOR = proxy server IP address. when multiple proxy servers are used, this value is similar to the following: 203.98.1820.3, 203.98.1820.3, 203.129.72.215.
Your real IP address is hidden, but you are disclosed to the access object that you use the proxy server to access them.
IV. destorting Proxies
REMOTE_ADDR = proxy server IP address
HTTP_VIA = proxy server IP address
HTTP_X_FORWARDED_FOR = random IP address. when multiple proxy servers are used, the value is as follows: 203.98.182.163, 203.98.182.163, 203.129.72.215.
It tells the access object that you used the proxy server, but fabricated a false random IP address instead of your real IP address to cheat it.
5. High Anonymity Proxies (Elite proxies)
REMOTE_ADDR = proxy server IP address
HTTP_VIA = no value or no Display
HTTP_X_FORWARDED_FOR = no value or no value is displayed. when multiple proxy servers are used, the value is similar to the following: 203.98.182.163, 203.98.182.163, 203.129.72.215.
The proxy server information replaces all your information, just as you directly access the object using the proxy server.
For the above property analysis, change the code:
////// Obtain the client Ip address //////
Public string GetUserIP () {string _ userIP; try {if (HttpContext. current. request. serverVariables ["HTTP_VIA"] = null) {_ userIP = HttpContext. current. request. userHostAddress;} else {_ userIP = HttpContext. current. request. serverVariables ["REMOTE_ADDR"] ;}} catch (Exception) {_ userIP = "unable to get this IP address" ;}return _ userIP ;}
Permanent address:
Reprint at will ~ Please bring the tutorial URL ^