Click here to Skip to main content
13,291,084 members (69,917 online)
Click here to Skip to main content
Add your own
alternative version


103 bookmarked
Posted 23 Jan 2005

HostName, IP, and MAC Address

, 23 Jan 2005
Rate this:
Please Sign up or sign in to vote.
This will guide you to understand and trace network host information, IP, and MAC address information.

Sample Image - Host_Info_within_Network.jpg


This article is used to get the intranet information in a network. It shows information like the host name, corresponding IP address and also physical address.

Using the code

The code retrieves all the System names using the Directory entries information.

//       // Use Your work Group WinNT://Baba(Work Group Name)
//     DirectoryEntry DomainEntry = 
//         new DirectoryEntry("WinNT://" + this.TxtWorkGroup.Text.Trim());
//     DomainEntry.Children.SchemaFilter.Add("computer");

Then we collect the IP address using the DNS.

//    System.Net.IPHostEntry Tempaddr = 
 //     (System.Net.IPHostEntry)Dns.GetHostByName(machine.Name);
//    System.Net.IPAddress[] TempAd = Tempaddr.AddressList;

The physical MAC address is collected using the DLL "iphlpapi.dll" with the API SendARP().

For each System, we use the Hostname to retrieve the MAC address.

//    [DllImport("iphlpapi.dll", ExactSpelling=true)]
//    public static extern int SendARP( int DestIP, int SrcIP, 
//         [Out] byte[] pMacAddr, ref int PhyAddrLen );

Points of Interest

This is my first article in CodeProject.


  • 01/24/2005

    Article released.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Technical Lead
India India
I loves computers. I am interested in programming such like Networking using Sockets, Imaging, Telecom and robotics.

I am very much interested in programming in windows and Linux.

I am working with Verizon Data Services India Ltd.,

You may also be interested in...

Comments and Discussions

GeneralRe: MAC address of Linux, Solaris... machine? Pin
hnim25-Dec-06 21:35
memberhnim25-Dec-06 21:35 
GeneralRe: MAC address of Linux, Solaris... machine? Pin
MahendranG26-Dec-06 7:53
memberMahendranG26-Dec-06 7:53 
QuestionHow to get the MAC from NIC Hardware Pin
Reader Man San31-Oct-06 21:51
memberReader Man San31-Oct-06 21:51 
GeneralHostname from IP Address Pin
DaLucifer1-Jul-06 0:03
memberDaLucifer1-Jul-06 0:03 
GeneralRe: Hostname from IP Address Pin
MahendranG25-Jul-06 18:57
memberMahendranG25-Jul-06 18:57 
GeneralRe: Hostname from IP Address Pin
DaLucifer26-Jul-06 6:07
memberDaLucifer26-Jul-06 6:07 
QuestionHow to Get MAC Address from an IP Address in Internet Pin
dathq22-May-06 8:02
memberdathq22-May-06 8:02 
AnswerRe: How to Get MAC Address from an IP Address in Internet Pin
darkhuntercode28-Jan-11 10:25
memberdarkhuntercode28-Jan-11 10:25 
there is no way you can see the mac addres over internet becouse this mac addres is remove in every step in the path from router to router and is replaced with the mac addres of the router sending the packet and the mac addres of the router that receives

sorry for my english i hope this is a good explination
GeneralMAC Address of PC;s turned off... Pin
KevinReece19-Apr-06 5:34
memberKevinReece19-Apr-06 5:34 
GeneralRe: MAC Address of PC;s turned off... Pin
MahendranG19-Apr-06 19:48
memberMahendranG19-Apr-06 19:48 
GeneralVB.NET 2005 Example Pin
FloatingPointCode6-Apr-06 5:43
memberFloatingPointCode6-Apr-06 5:43 
GeneralRe: VB.NET 2005 Example Pin
MahendranG10-Apr-06 18:14
memberMahendranG10-Apr-06 18:14 
GeneralRe: VB.NET 2005 Example Pin
FloatingPointCode11-Apr-06 6:04
memberFloatingPointCode11-Apr-06 6:04 
GeneralRe: VB.NET 2005 Example Pin
juacar0129-Jul-06 10:20
memberjuacar0129-Jul-06 10:20 
GeneralsendARP Pin
ESTANNY27-Jan-06 5:50
memberESTANNY27-Jan-06 5:50 
Generalworkgroup name Pin
101624-Jan-06 4:33
member101624-Jan-06 4:33 
GeneralRe: workgroup name Pin
ESTANNY27-Jan-06 5:54
memberESTANNY27-Jan-06 5:54 
GeneralRe: workgroup name [modified] Pin
rchi83-Sep-07 22:04
memberrchi83-Sep-07 22:04 
GeneralRe: workgroup name Pin
FloatingPointCode6-Apr-06 5:39
memberFloatingPointCode6-Apr-06 5:39 
Generalwirless Pin
aglt11-Sep-05 3:24
memberaglt11-Sep-05 3:24 
GeneralRe: wirless Pin
Anonymous16-Sep-05 4:37
sussAnonymous16-Sep-05 4:37 
Generaldetermining type of connection Pin
shihab1234567824-Jul-05 7:35
membershihab1234567824-Jul-05 7:35 
GeneralRe: determining type of connection Pin
Anonymous27-Jul-05 8:19
sussAnonymous27-Jul-05 8:19 
Generaldetect multiple lan cards Pin
Adnan Siddiqi17-Apr-05 21:48
memberAdnan Siddiqi17-Apr-05 21:48 
GeneralRe: detect multiple lan cards Pin
MahendranG17-Apr-05 23:49
memberMahendranG17-Apr-05 23:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.171207.1 | Last Updated 24 Jan 2005
Article Copyright 2005 by MahendranG
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid