Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between REMOTE_HOST and REMOTE_ADDR

What is the difference between these two variables?

REMOTE_HOST and REMOTE_ADDR.

like image 734
hd. Avatar asked Sep 28 '10 11:09

hd.


People also ask

What is Remote_host?

A remote host is a computer outside your firewall with which you want to connect. Connecting with a remote host through an Internet Session requires that you have: Configured a NAT rule that translates a public IP address to your internal network.

What is SERVER Remote_addr?

$_SERVER['REMOTE_ADDR'] Returns the IP address from where the user is viewing the current page.

What is Remote_addr header?

REMOTE_ADDR is the IP of the system that contacted your site - and that could actually be a proxy address rather than the clients real IP. If HTTP_X_FORWARDED_FOR is filled out, it should include the clients real IP AND any proxy IP's they trsversed to get to your site as a comma seperated list.

Is Remote_addr secure?

Yes, it's safe. It is the source IP of the TCP connection and can't be substituted by changing an HTTP header.


2 Answers

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.

like image 173
Ruel Avatar answered Oct 07 '22 08:10

Ruel


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 | "-" 
like image 26
NOZUONOHIGH Avatar answered Oct 07 '22 07:10

NOZUONOHIGH