且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

网络扫描应用程序

更新时间:2022-10-21 10:50:11

使用以下方式快速搜索Google: c#本地网络发现 - Google搜索 [ ^ ]



发现这个: C# - SubnetScanner - 扫描你的(本地)网络 - *** [ ^ ]它有一个支持页面&源码下载链接: C#子网扫描仪 - KIJUKA [ ^ ]



我知道这是C#,但不应该是太难转换为VB。将压缩的项目文件上传到此处:代码转换器 [ ^ ]它将为您完成大部分工作...



更新:实际上,您正在寻找 OriginalGriff [ ^ ] :检索局域网的IP和MAC地址 [ ^ 一>

Hi,
We have around 400 PC's in our network which is segregated by department wise. Each department has its own subnet for example : dept1 has the ip series 192.168.20.X and dept2 has 192.168.11.X.

My question is that how could i get the ipaddress, hostname and mac address with a VB .net application and store it in the database.

Hope i am clear enough.

Thank you.

What I have tried:

I have tried using:

<pre>For i = 1 To 254
            Try
                hostname = ""
                ipaddr = "192.168.12." & i.ToString
                hostname = (System.Net.Dns.GetHostEntry("192.168.12." & i.ToString).HostName.ToString)
                timestamp = DateAndTime.Now.ToString
                If hostname <> "" Then
                    If con.State = ConnectionState.Closed Then
                        con.Open()
                    End If
                    sql = "insert into ipstats values(?,?,?)"
                    cmd = New SqlCeCommand(sql, con)
                    cmd.Parameters.AddWithValue("hostname", hostname)
                    cmd.Parameters.AddWithValue("ipddr", ipaddr)
                    cmd.Parameters.AddWithValue("timestamp", timestamp)
                    retvals = cmd.ExecuteNonQuery()
                End If
            Catch ex As Exception
            End Try
        Next


But it take around an hour to scan whole network and it does not get all the machine in the network.

And also i could not figure out how to get mac address.

A quick Google Search using: c# local network discovery - Google Search[^]

Found this: C# - SubnetScanner - Scan your (local) Network - ***[^] which has a support page & source download link: C# Subnet Scanner - KIJUKA[^]

I know that this is C#, but should not be too difficult to convert to VB. Upload the zipped project file to here: Code Converter[^] and it will do most of the work for you...

UPDATE: Actually, this is what you are looking for courtesy of OriginalGriff[^] : Retrieving IP and MAC addresses for a LAN[^]