Router IP's

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi, some help please, i need to create a network map (from any pc). For now i get my own ip, the router ip, but i cant get the IP from others pcs connected to the router. Can i get the IPs only with the framework? or i need another external library?
The code
Dim strHostName as String = Dns.GetHostName()<br/>
RichTextBox1.Text &= "Local Machines Host Name: " + strHostName & vbCrLf
Then using host name, get the IP address list..<br/>
Dim ipEntry As IPHostEntry = Dns.GetHostEntry(strHostName)<br/>
Dim addr As IPAddress() = ipEntry.AddressList
I get my own IP
Dim i As Integer = 0<br/>
While i < addr.Length<br/>
col.Add(addr(i).ToString())<br/>
RichTextBox1.Text &= "IP Address {0}: {1} " & addr(i).ToString() & vbCrLf<br/>
i += 1<br/>
End While
Dim NetworkAdapters() As NetworkInterface = NetworkInterface.GetAllNetworkInterfaces<br/>
Dim myAdapterProps As IPInterfaceProperties = Nothing<br/>
Dim myGateways As GatewayIPAddressInformationCollection = Nothing<br/>

Get Router IP
For Each adapter As NetworkInterface In NetworkAdapters<br/>
myAdapterProps = adapter.GetIPProperties<br/>
myGateways = myAdapterProps.GatewayAddresses<br/>
For Each Gateway As GatewayIPAddressInformation In myGateways<br/>
If Not Gateway.Address.ToString = "0.0.0.0" Then<br/>
RichTextBox1.Text &= "Router IP is " & Gateway.Address.ToString & vbCrLf<br/>
End If<br/>
Next<br/>
Next



<br/>



View the full article
 
Back
Top