Click here to Skip to main content
Licence 
First Posted 23 Jan 2005
Views 176,775
Bookmarked 87 times

HostName, IP, and MAC Address

By | 23 Jan 2005 | Article
This will guide you to understand and trace network host information, IP, and MAC address information.

Sample Image - Host_Info_within_Network.jpg

Introduction

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.

History

  • 01/24/2005

    Article released.

License

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

MahendranG

Technical Lead

India India

Member

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.,

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralThis code does not work on Windows 7.Please help. Pinmemberrohini.vangury2:17 1 Nov '10  
GeneralTo get the User Name of the client accessing a website PinmemberMoiz Ahmed23:28 8 Jan '10  
GeneralGreat article PinmemberEaverae0:58 2 Oct '09  
GeneralError when running your util HostNIPAddr.exe Pinmembersmith6668:06 7 Oct '08  
QuestionHow to Get WorkGroupNames in LAN PinmemberGowri1234561:25 13 Jun '08  
Generalworkgroup n ames in lan Pinmemberthiruvadi_anand1:58 31 Mar '08  
Questionno working in other range IP Pinmemberpablohack23:23 4 Sep '07  
GeneralUsage of variable names. PinmemberDesotron6:34 17 May '07  
GeneralHelp me! Pinmembernguyenquanglamcnttk2723:57 7 May '07  
I have error in programming!
so I need your asistance.
desciption:
<img scr="http://aycu20.webshots.com/image/16019/2005784138176631572_rs.jpg">

 
QuangLam

QuestionIs there a way to detect Network Printers' IP addresses? PinmemberJan Palmer23:55 25 Dec '06  
QuestionMAC address of Linux, Solaris... machine? Pinmemberhnim20:46 20 Dec '06  
AnswerRe: MAC address of Linux, Solaris... machine? PinmemberMahendranG6:54 21 Dec '06  
GeneralRe: MAC address of Linux, Solaris... machine? Pinmemberhnim20:35 25 Dec '06  
GeneralRe: MAC address of Linux, Solaris... machine? PinmemberMahendranG6:53 26 Dec '06  
QuestionHow to get the MAC from NIC Hardware PinmemberReader Man San20:51 31 Oct '06  
GeneralHostname from IP Address PinmemberDaLucifer23:03 30 Jun '06  
GeneralRe: Hostname from IP Address PinmemberMahendranG17:57 25 Jul '06  
GeneralRe: Hostname from IP Address PinmemberDaLucifer5:07 26 Jul '06  
QuestionHow to Get MAC Address from an IP Address in Internet Pinmemberdathq7:02 22 May '06  
AnswerRe: How to Get MAC Address from an IP Address in Internet Pinmemberdarkhuntercode9:25 28 Jan '11  
GeneralMAC Address of PC;s turned off... PinmemberKevinReece4:34 19 Apr '06  
GeneralRe: MAC Address of PC;s turned off... PinmemberMahendranG18:48 19 Apr '06  
GeneralVB.NET 2005 Example PinmemberFloatingPointCode4:43 6 Apr '06  
GeneralRe: VB.NET 2005 Example PinmemberMahendranG17:14 10 Apr '06  
GeneralRe: VB.NET 2005 Example PinmemberFloatingPointCode5:04 11 Apr '06  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    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 | Mobile
Web04 | 2.5.120529.1 | Last Updated 24 Jan 2005
Article Copyright 2005 by MahendranG
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid