Reputation:
In my ASP.NET application, I'm saying something like this to get the client IP address:
string ipAddress = HttpContext.Current.Request.UserHostAddress;
This is the normal, straightforward way that I've always used, and it's always seemed to work. Everybody knows that the above statement is just a wrapper for the REMOTE_ADDR server variable.
Simple enough, right? Well, in the last few days I've been noticing that on my local dev machine, it's returning this as the value:
"fe80::dde4:def3:7f1b:a582%10"
I have no earthly idea why. I'm running Vista x64 and running my app with IIS7. I do have IPv4 and IPv6 enabled, but that usually returns something like:
"1::"
I have no idea why this is happening. Rebooting solves nothing.
EDIT:
I'm using Chrome when this happens.
Upvotes: 2
Views: 5096
Reputation: 10239
Are you using FireFox when you see this issue? That by default will use IPv6 when available. I'd recommend turning that off:
This will also speed up local development and debugging, as FF hangs sometimes for no apparent reason when IPv6 is enabled.
The other option I'd recommend is to just disable IPv6. It's not useful right now unless you're running IPv6 end-to-end, which no end user ISP's are. Just open connection properties on your connection and untick the "Internet Protocol Version 6 (TCP/IPv6)" box.
Upvotes: 4
Reputation: 63435
It looks like it's returning IPv6.
::1
is the loopback address for IPv6, which is simply the reversed byte order of 1::
.
I should also note that fe80::/10
addresses in IPv6 are Autoconfiguration IP addresses (in IPv4, these are 169.254.0.0/16
). If for example you are on a private LAN and cannot access a DHCP server, Windows will automatically assign your ethernet adapter an autoconfiguration IP address.
Just FYI, You should generally assign a private IP address to adapters that are not able to reach a DHCP server.
Upvotes: 8