gpwr
gpwr

Reputation: 1025

How to find the IPv6 address of a client using Perl CGI script

In perl getting the external IPv4 address of a client is done by doing this:

$ip4_address = $ENV{"REMOTE_ADDR"};

What would you do to get the external IPv6 address from the client.

(Note that I need the external IPv6 address of the client connecting to the web server - I'm not trying to get the IPv6 address of a domain name)

Upvotes: 0

Views: 717

Answers (1)

LeoNerd
LeoNerd

Reputation: 8532

The REMOTE_ADDR CGI variable is simply populated from the peer address of the incoming HTTP connection. If that's over IPv6, then it'll be an IPv6 address. If it's over IPv4, then a IPv4 one.

If the client connects to you over IPv4, you can't know anything about the state of their IPv6 stack unless they tell you, and there isn't a common way that's done.

In summary: you can't know.

Upvotes: 4

Related Questions