The gateway is defined on a per network card level, so this code will get you the Gateway for each of the NICs installed on a machine:
Code:Dim sb As New StringBuilder sb.AppendLine() For Each n As NetworkInterface In NetworkInterface.GetAllNetworkInterfaces() sb.AppendLine(n.Description) sb.AppendLine("MAC:" & n.GetPhysicalAddress().ToString()) For Each u As UnicastIPAddressInformation In n.GetIPProperties().UnicastAddresses sb.AppendLine("IP:" & u.Address.ToString()) Next For Each g As GatewayIPAddressInformation In n.GetIPProperties().GatewayAddresses sb.AppendLine("Gateway:" & g.Address.ToString()) Next Next MessageBox.Show(sb.ToString())




Reply With Quote