How to get the local IPv6 address in WinXP

F

Frank Jiao

I can get my local IPv6 address in Win2003 use the source code as below:

string localName = Dns.GetHostName();
string address = "";
string scopeId = "";

IPHostEntry hostEntry = Dns.Resolve( localName );
foreach (IPAddress curAdd in hostEntry.AddressList)
{
if(curAdd.AddressFamily.ToString() ==
ProtocolFamily.InterNetworkV6.ToString())
{
scopeId = curAdd.ScopeId.ToString();
address = curAdd.ToString();
break;
}
}

Then, I set the config about IPv6 in WinXP as the same as Win2003. when I
run the source code in WinXP, I can only get the loopback:):1) address but
not local IPv6 address.
Thank you for your help!


Frank Jiao
 
C

cody

Iam no expert but could it be due to internal Firewall?

However instead of "if(curAdd.AddressFamily.ToString() ==
ProtocolFamily.InterNetworkV6.ToString())"
you should write "if (curAdd.AddressFamily==AddressFamily.InterNetworkV6)"

You should never rely on a specific representation of ToString(), because it
can depend on current culture and framework version.
 
F

Frank Jiao

Hi, cody
thank you very much, I try to use your method, but the same result
In the both OS, I can get two IPv6 address.
In Win2003, I can get four value(two IPv6 address/one is IPv6loopback
address/one is IPv4 address) after "IPHostEntry hostEntry = Dns.Resolve(
localName )", but there are only two value(one is IPv6loopback address/one
is IPv4 address) in WinXP. So I think the problem is DNS, but I don't know
how to resovle it.


Thank you
 
C

cody

Maybe your WinXP is not connected to the internet, I have no other idea :)
Maybe the currrent User rights prevent you from seeing another IPAdress?
Do you have a proxy? Is is properly configured?
What is if you use "ipconfig" from the console? What does it display?
These are just ideas, as I also have no clue :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top