How Get Information's About Your Internet In VB.NET

Today i will show you how you can obtain the computers mac address, local ip and outgoing ip
First create a new project


1. Open Visual Studio or Visual Basic.
2. Create a new windows form project and name it whatever you want.

Now to add the controls.
1. Add 3 textboxes, name the first outtext the second iptext and the last mactext.
2. add 4 buttons, name the first copyout the second copyip and the last copymac, you dont need to rename
the last its just to get all the information.
3. Set the text on the copy buttons to copy.

Now to the code first you add at the top of your code.

Imports System.Net

then you add this below public class.
 Dim ip As New WebClient

Now add this so that when you click on the buttons you copy it
    Private Sub CopyOut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CopyOut.Click
        Clipboard.SetText(OutText.Text)
    End Sub

    Private Sub CopyIp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CopyIp.Click
        Clipboard.SetText(IPtext.Text)
    End Sub

    Private Sub CopyMac_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CopyMac.Click
        Clipboard.SetText(MACText.Text)
    End Sub
Now we will add the code that gets the mac address the outgoing ip and the local ip, add this to your code.
Private Sub getoutip()
'Get outgoing ip
        Try
            OutText.Text = ip.DownloadString("http://www.networksecuritytoolkit.org/nst/tools/ip.php/")

        Catch ex As Exception
            OutText.Text = "No connection"
        End Try
    End Sub

    Private Sub obtip()
        'MAC Address
        For Each nic As System.Net.NetworkInformation.NetworkInterface In System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()
            MACText.Text = String.Format("{2}", nic.Description, Environment.NewLine, nic.GetPhysicalAddress())
            Exit For
        Next
'Get local ip
        Dim host As String = System.Net.Dns.GetHostName()
        Dim LocalHostaddress As String = System.Net.Dns.GetHostByName(host).AddressList(0).ToString()
        IPtext.Text = LocalHostaddress
    End Sub



What this does is that it, downloads your ip address from http://www.networksecuritytoolkit.org/nst/tools/ip.php/ so that we can see it in the textbox
and it finds the mac address and the local ip in the network.

now to the last button add this.
getoutip()
obtip()

You now done and it should look something like this



Please dont repost without giving credits to the right website, thank you
Written and coded by: AnoPem

3 comments

But I am using the Windows .
So Can you tell me What is the Windows Address.
Instead of mac address...

And yeah if you can update the code like this :
If windows then windows address elseif mac then mac Address
so this identifier will help us to be used in the same application.

If you update code then please inform me 1st. of all

Reply

it's not Apple MAC , it's M-A-C.

Reply

Post a Comment

Note: Only a member of this blog may post a comment.