Exemplo n.º 1
0
        private void loadIpAddresses()
        {
            string      HostName    = Dns.GetHostName();
            IPHostEntry AddressesIP = Dns.GetHostEntry(HostName);
            string      firstEntry  = "127.0.0.1";
            IPAddress   firstIp     = null;

            firstIp = IPAddress.Parse(firstEntry);
            foreach (IPAddress AddressIP in AddressesIP.AddressList)
            {
                if (AddressIP.IsIPv6LinkLocal || AddressIP.IsIPv6Multicast || AddressIP.IsIPv6SiteLocal || AddressIP.IsIPv6Teredo)
                {
                    continue;
                }
                cbAddressList.Items.Add(firstIp);
                cbAddressList.Items.Add(AddressIP.ToString());
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            string HostName = Dns.GetHostName();

            IPHostEntry IPAdresses = Dns.GetHostEntry(HostName);

            int counter = 0;

            Console.WriteLine("Your Host Name is: " + HostName);

            foreach (IPAddress AddressIP in IPAdresses.AddressList)
            {
                if (AddressIP.ToString() == "127.0.0.1")
                {
                    Console.WriteLine("You are not connected to network: " + AddressIP.ToString());
                }
                else
                {
                    Console.WriteLine("Your IP Address " + ++counter + ":" + AddressIP.ToString());
                }
            }

            Console.ReadKey();
        }