Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Net.NetworkInformation;
- using System.Net.Sockets;
- namespace Articulo.Pregunta.P1320
- {
- public class IpPrivada
- {
- public static void Main()
- {
- // Ciclo por todas las interfaces de red en este dispositivo:
- foreach (var interfaces in NetworkInterface.GetAllNetworkInterfaces())
- {
- // Direcciones de unicast asignadas a la interfaz de red actual:
- foreach (var direccion in interfaces.GetIPProperties().UnicastAddresses)
- {
- // Valida que se trate de una IPv4:
- if (direccion.Address.AddressFamily == AddressFamily.InterNetwork)
- {
- Console.WriteLine ("Dirección IP privada: {0}", direccion.Address.ToString());
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement