merlin
merlin

Reputation: 2917

REMOTE_ADDR returns 2 IPv4 instead of one

I am storing IPs to a DB which used to work under char(15), recently I get more and more IPs that look like this:

'172.29.93.25, 94.56.207.248'

The majority of entries look OK, though. This is less then 1% of all cases.

The command I am using:

$ip = $_SERVER['REMOTE_ADDR'] 

The above IP does not look like IPv6 to me, but rather like two IPv4s separated be comma. How is this possible?

Upvotes: 2

Views: 3330

Answers (3)

Asaph
Asaph

Reputation: 162801

The first IPv4 address is probably the internal IP address of a load balancer. The second IPv4 address is likely the IP address of the client and was probably included by the load balancer in the X-Forwarded-For http header.

Update:

I see you've edited the question and replaced an example with a 10.x.x.x IP address with a new example that has a 172.x.x.x IP address. In this new case, the first IP could be a proxy server. In general, you can have a comma delimited list of IP addresses in this field that could be arbitrarily long and it represents all the proxies and load balancers that the request went through. The last IP address is the originating client's IP.

Upvotes: 4

HenryTK
HenryTK

Reputation: 1287

The first address is a private address, you can learn about the address allocation for private internets here.

Upvotes: 1

Machavity
Machavity

Reputation: 31624

The first address is a 10.10 address, meaning it's a non-routing address. Either this is a load balancer or you have a virtual machine (i.e. Amazon AWS) that has a non-public address that is reaching the internet through some gateway.

Upvotes: 1

Related Questions