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 6703663
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:11:53+00:00 2026-05-26T07:11:53+00:00

I am trying to get the active network adapter’s IP address, so that I

  • 0

I am trying to get the active network adapter’s IP address, so that I avoid virtual and other VPN adapters that are not connected at present.

On my current laptop the following code returns 3 IP V4 addresses, and I don’t know how to get the “real”, in use IP address from that list.

        IPAddress[] ipV4Addresses = Array.FindAll(
            Dns.GetHostEntry(String.Empty).AddressList,
            a => a.AddressFamily == AddressFamily.InterNetwork);

Looking at MSDN doc here, I thought maybe I was on the right track. Has anyone obtained the list of IP addresses per adapter successfully? If so, please share your wisdom. Thanks!

This is all prototype at this point. I have this code (thanks to SO!), and the string[] netAddresses is always null, even with the computer connected to a network and with a functioning IP address.

        string wmiQuery = "SELECT * FROM Win32_NetworkAdapter WHERE NetConnectionId != NULL";
        ManagementObjectSearcher moSearch = new ManagementObjectSearcher(wmiQuery);
        ManagementObjectCollection moCollection = moSearch.Get();

        foreach (ManagementObject mo in moCollection)
        {
            Console.WriteLine("{0} is {1}", mo["Name"], mo["NetConnectionStatus"]);
            string[] netAddresses = (string[])mo["NetworkAddresses"];
            if (netAddresses != null)
            {
                foreach (string netAddress in netAddresses)
                {
                    Console.WriteLine("\tnet addresses:");
                    Console.WriteLine("\t\t{0}", netAddress);
                }
            }
        }
  • 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-05-26T07:11:54+00:00Added an answer on May 26, 2026 at 7:11 am

    from MS docs: http://msdn.microsoft.com/en-us/library/windows/desktop/aa394216%28v=vs.85%29.aspx

    NetworkAddresses

    Data type: string array
    Access type: Read-only

    Array of network addresses for an adapter. This property is inherited from CIM_NetworkAdapter.

    This property has not been implemented yet. It returns a NULL value by default.

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

Sidebar

Related Questions

I'm trying to get build a simple Active Directory tools that allows me to
I'm trying to get all users that belong to a group in the Active
I have trouble with my app, when i'm trying to get active user from
I'm trying to get user GUID from Active Directory. My code: DirectoryEntry entry =
Trying to get comfortable with jQuery and I have encountered some sample code that
I'm trying to get a tab bar effect not unlike Russell Quinn's Creative Review
I am trying to get all of the CN's out of active directory in
I am trying to get the inner active add Api to work with QML.
i am trying to get the childs active when the parent is active. So
I'm trying to get a list of recently active customers, based on their last

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.