// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Net.NetworkInformation; using System.Xml; namespace E { public class MainClass { public static void Main(string[] args) { NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces(); foreach (NetworkInterface adapter in adapters) { foreach(IPAddressInformation ip in adapter.GetIPProperties().UnicastAddresses) { Console.WriteLine(ip.Address); } } XmlDocument doc = new XmlDocument(); doc.Load("http://www.showmyip.com/xml/"); Console.WriteLine(doc.SelectSingleNode("//ip_address/ip").FirstChild.Value); } } }