Link to home
Start Free TrialLog in
Avatar of wallacef
wallacefFlag for United Kingdom of Great Britain and Northern Ireland

asked on

get default gateway ip address using vb.net

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 & " "
  next
  GetLocalIPAddress = strOutput.Trim
End Function

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.

Thanks, Fiona
ASKER CERTIFIED SOLUTION
Avatar of CuSo4
CuSo4

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial