using System; using System.Net; using System.Net.NetworkInformation; public class Test { public static void Main() { DisplayGatewayAddresses(); } public static void DisplayGatewayAddresses() { Console.WriteLine("Gateways"); NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces(); foreach (NetworkInterface adapter in adapters) { IPInterfaceProperties adapterProperties = adapter.GetIPProperties(); GatewayIPAddressInformationCollection addresses = adapterProperties.GatewayAddresses; Console.WriteLine(adapter.Description); if (addresses.Count >0) { foreach (GatewayIPAddressInformation address in addresses) { Console.WriteLine(" Gateway Address ......................... : {0}", address.Address.ToString()); } Console.WriteLine(); } } } }