I am writing a program to provide diagnostic information for laptop users on the road. I wish to find the default gateway assigned by the ISP so I can ping it and check it's responding.
I have written ping code
and I am able to get the machines IP address(es) using this function:
Public Function GetLocalIPAddress() As String
Dim h As IPHostEntry = Dns.GetHostByName(Dns.GetHostName)
Dim ip As IPAddress
Dim strOutput As String
For Each ip In h.AddressList
strOutput &= ip.ToString & " "
GetLocalIPAddress = strOutput.Trim
I want the default gateway IP as you would be able to get from running IPConfig/all at cmd prompt (but don't want to have to parse the output of a command line program).
Is it possible to do this using vb.net objects.