简体   繁体   中英

How to get IP of VPN / Network with specific name and if it is connected?

looking at "network connections" in windows server 2008, I have a connection called "company".

How can I figure out if this VPN is currently connected and what internal IP(*) it has assigned?

(*) with internal IP I refer to the one of the local computer so I can use this IP in my "BindIPEndPointDelegate"

This might help you:

        foreach (var item in System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces())
        {
            Console.Write(item.Name + " - " + item.OperationalStatus.HasFlag(System.Net.NetworkInformation.OperationalStatus.Up) + " : ");
            foreach (var item2 in item.GetIPProperties().UnicastAddresses)
            {
                if (!item2.Address.IsIPv6LinkLocal)
                    Console.Write(item2.Address.ToString());
            }
            Console.WriteLine();
        }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM