Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7756523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:50:44+00:00 2026-06-01T12:50:44+00:00

I have some existing code that worked fine under Windows 2003, to obtain the

  • 0

I have some existing code that worked fine under Windows 2003, to obtain the list of IP addresses bound to the server:

foreach (IPAddress addr in (Dns.GetHostEntry(Dns.GetHostName())).AddressList)
{
    // Code here to act on each address
}

When I run this code on our Windows 2008 server, it only returns one IP address. Upon further investigation, it seems all of the rest of the IP addresses that the machine is listening on were added using the netsh int ipv4 add address command and specifying the skipassource=true flag.

Is there a way to include those addresses in my query, i.e. return ALL addresses on the server?

(If you’re curious, the skipassource=true flag was set because Windows 2008 introduced new behavior in networking that allows it to decide which of your IP addresses it considers “primary,” and the rest of our applications rely on us being able to choose the primary. The only way to do that in Windows 2008 is to mark all other addresses as skipassource=true.)

Edit This question is now just to satisfy my curiosity, as I have worked around the problem. My original code above was used to run through all the IPs on the server, and see if it found a match to a specific IP I was looking for. I now check to see if the server I’m on is already running a service that listens to that specific IP address/port, so I no longer need to loop through ALL of the IPs. Still, I would be interested to hear if there is an answer to the original question.

Edit Thanks to @aKzenT for the solution on this. I now use NetworkInteface.GetAllNetworkInterfaces() to get access to all the IPs, rather than Dns.GetHostEntry(). My final code looks like this:

foreach (NetworkInterface netface in NetworkInterface.GetAllNetworkInterfaces())
{
    foreach (UnicastIPAddressInformation uni in netface.GetIPProperties().UnicastAddresses)
    {
        IPAddress addr = uni.Address;
        // Code here to act on each address
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T12:50:45+00:00Added an answer on June 1, 2026 at 12:50 pm

    skipassource is intended to not include an ip address in the DNS name system, so I think you have to find another way than Dns.GetHostEntry

    Did you try looking at the System.Net.NetworkInformation namespace?

    I think if you loop through the adapters via GetAllNetworkInterfaces then call GetIPProperties to get the IP properties of the adapter and then check the UnicastAddresses you can built a list of IP addresses. Not tested though.

    See also:
    http://msdn.microsoft.com/de-de/library/system.net.networkinformation.networkinterface.getallnetworkinterfaces.aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some existing custom Excel workbooks/applications with code-behind C#, which work fine. They
I have some existing code that retrieves data from a database using ADO.NET that
I'm new to StructureMap and have some existing code that I'm working with that
I am developing a C++ MPI application. I have some existing code that is
I have some existing code in C# that I'm trying to move to an
I have some pre-existing js code that manipulates a div via DOM. I have
I have some existing code that is querying a SQL database repeatedly with different
I have some existing code that uses an enum instead of a function pointer
I have some existing C code that uses ICMP raw sockets to do Ping
I have some existing code which isn't formatted consistently -- sometimes two spaces are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.