Link to home
Start Free TrialLog in
Avatar of CraigLazar
CraigLazar

asked on

Get ip address and network info vb.net

Hi,
I have written a small app in vb.net 08 and i need to somehow fetch the IP address(s) plus, subnet mask, default gateway and DNS server info if possible from a machine

thanks allot

cheers
ASKER CERTIFIED SOLUTION
Avatar of Dirk Haest
Dirk Haest
Flag of Belgium image

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
For Each f As NetworkInterface In NetworkInterface.GetAllNetworkInterfaces()
    If f.OperationalStatus = OperationalStatus.Up Then
        For Each d As GatewayIPAddressInformation In f.GetIPProperties().GatewayAddresses
            MessageBox.Show(d.Address.ToString())
        Next
    End If
Next
Avatar of CraigLazar
CraigLazar

ASKER

Hi Dhaest,
Thanks for the code,
i got ur first post working, but i checked on MSDN and see that using Win32_NetworkAdapterConfiguration, there is no property to indicate wheather the ip is connected or not.
I need to report all the netwrok adapters with there information and if they are connected or not

is that possible?

thanks
>> I need to report all the netwrok adapters with there information and if they are connected or not

That's another question than the original question where you asked for the  address(s) plus, subnet mask, default gateway and DNS server info if possible from a machine

I'm not sure if you can see this !
Hi Hhaest,

Ok i found hte Class librabries for WMI on Microsofts web site. There are a number of Netwotk classes. And i have found that i need to use a combination of Win32_NetworkAdapterConfiguration and Win32_NetworkAdapter and link it by Mac Address which is common in both calls to then be able to show in a select statement the details that i need

thanks allot for the help

http://msdn.microsoft.com/en-us/library/aa394582(VS.85).aspx



cheers