What is the difference between these two variables?
REMOTE_HOST
and REMOTE_ADDR
.
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.
$_SERVER['REMOTE_ADDR'] Returns the IP address from where the user is viewing the current page.
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.
Yes, it's safe. It is the source IP of the TCP connection and can't be substituted by changing an HTTP header.
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.
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 )
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 | "-"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With