Difference between REMOTE_HOST and REMOTE_ADDR

ApacheServer Variables

Apache Problem Overview


What is the difference between these two variables?

REMOTE_HOST and REMOTE_ADDR.

Apache Solutions


Solution 1 - Apache

REMOTE_HOST pertains to the hostname of the client (i.e. the computer making the request). REMOTE_ADDR refers to the IP address of the client.

There would be times when the hostname is unresolvable so the REMOTE_HOST will return the REMOTE_ADDR or the IP address instead.

Solution 2 - Apache

From RFC-3875

  • REMOTE_ADDR:The REMOTE_ADDR variable MUST be set to the network address of the client sending the request to the server.
      REMOTE_ADDR  = hostnumber
      hostnumber   = ipv4-address | ipv6-address
      ipv4-address = 1*3digit "." 1*3digit "." 1*3digit "." 1*3digit
      ipv6-address = hexpart [ ":" ipv4-address ]
      hexpart      = hexseq | ( [ hexseq ] "::" [ hexseq ] )
      hexseq       = 1*4hex *( ":" 1*4hex )
  • REMOTE_HOST:The REMOTE_HOST variable contains the fully qualified domain name of the client sending the request to the server, if available, otherwise NULL. Fully qualified domain names take the form as described in section 3.5 of RFC 1034 [17] and section 2.1 of RFC 1123 [12]. Domain names are not case sensitive.
The REMOTE_HOST variable contains the fully qualified domain name of
   the client sending the request to the server, if available, otherwise
   NULL.  Fully qualified domain names take the form as described in
   section 3.5 of RFC 1034 [17] and section 2.1 of RFC 1123 [12].
   Domain names are not case sensitive.

      REMOTE_HOST   = "" | hostname | hostnumber
      hostname      = *( domainlabel "." ) toplabel [ "." ]
      domainlabel   = alphanum [ *alphahypdigit alphanum ]
      toplabel      = alpha [ *alphahypdigit alphanum ]
      alphahypdigit = alphanum | "-"

Solution 3 - Apache

1. $_SERVER['REMOTE_ADDR'] - This contains the real IP address of the client. That is the most reliable value you can find from the user.

2. $_SERVER['REMOTE_HOST'] - This will fetch the Host name from which the user is viewing the current page. But for this script to work, Hostname Lookups On inside httpd.conf must be configured.

Solution 4 - Apache

Remote: is a computer that resides in some distant location from which data retrieved it typically refer to a server in a private network or the public internet.

Remote_ host will return the REMOTE_ ADDR Or the IP address instead .

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionhd.View Question on Stackoverflow
Solution 1 - ApacheRuelView Answer on Stackoverflow
Solution 2 - ApacheNOZUONOHIGHView Answer on Stackoverflow
Solution 3 - ApacheK.SuthagarView Answer on Stackoverflow
Solution 4 - ApacheIrfan deenarkhilView Answer on Stackoverflow