I use Request.UserHostAddress, can only get IPv4 address, how to get IPv6 address of a visitor?
Given a string S consisting of N characters, the task is to check if the given string S is IPv4 or IPv6 or Invalid. If the given string S is a valid IPv4, then print “IPv4”, if the string S is a valid IPv6, then print “IPv4”. Otherwise, print “-1”. A valid IPv4 address is an IP in the form “x1.
Test an IPv6 configuration by using the PING command To obtain the IPv6 configuration for a computer: Click Start, point to All Programs, point to Accessories, and then click Command Prompt. At the command prompt, type ping ::1 to locate the loopback address.
Generic unix instructions for determining your IPv6 address and default route: Run ifconfig -a and look for inet6 to see your possible IPv6 addresses. Run netstat -nr and look for inet6 or Internet6 or similar to find the IPv6 portion; then look for default or :: or ::/0 .
An IPv4 address is translated to an IPv6 address by placing the 4 octets of the IPv4 address into the rightmost 4 octets of the IPv6 address.
After inserting the 4 octets of the IPv4 address into the rightmost 4 octets of the IPv6 address, the remaining left-most octets would be 0 in value.
I assume you're talking about HttpRequest.UserHostAddress. It will always return the address that was used to connect to you. If the request was made over IPv6, it will return their IPv6 address; if the request was made over IPv4, it will return their IPv4 address.
You should start by investigating why the request is being made over IPv4. And the folks at http://serverfault.com will probably be of more help on that.
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