Click here to Skip to main content
6,634,665 members and growing! (16,298 online)
Email Password   helpLost your password?
General Programming » Internet / Network » Network     Intermediate

HostName, IP, and MAC Address

By MahendranG

This will guide you to understand and trace network host information, IP, and MAC address information.
C#.NET 1.1, Win2K, WinXPVS.NET2003, Dev
Posted:23 Jan 2005
Views:126,897
Bookmarked:70 times
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
25 votes for this article.
Popularity: 4.72 Rating: 3.38 out of 5
5 votes, 20.0%
1
4 votes, 16.0%
2

3
5 votes, 20.0%
4
11 votes, 44.0%
5

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


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 Satyam Computer Services, India.
Occupation: Web Developer
Location: India India

Other popular Internet / Network articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 25 of 35 (Total in Forum: 35) (Refresh)FirstPrevNext
GeneralGreat article PinmemberEaverae1:58 2 Oct '09  
GeneralError when running your util HostNIPAddr.exe Pinmembersmith6669:06 7 Oct '08  
GeneralHow to Get WorkGroupNames in LAN PinmemberGowri1234562:25 13 Jun '08  
Generalworkgroup n ames in lan Pinmemberthiruvadi_anand2:58 31 Mar '08  
Questionno working in other range IP Pinmemberpablohack0:23 5 Sep '07  
GeneralUsage of variable names. PinmemberDesotron7:34 17 May '07  
GeneralHelp me! Pinmembernguyenquanglamcnttk270:57 8 May '07  
GeneralIs there a way to detect Network Printers' IP addresses? PinmemberJan Palmer0:55 26 Dec '06  
GeneralMAC address of Linux, Solaris... machine? Pinmemberhnim21:46 20 Dec '06  
GeneralRe: MAC address of Linux, Solaris... machine? PinmemberMahendranG7:54 21 Dec '06  
GeneralRe: MAC address of Linux, Solaris... machine? Pinmemberhnim21:35 25 Dec '06  
GeneralRe: MAC address of Linux, Solaris... machine? PinmemberMahendranG7:53 26 Dec '06  
GeneralHow to get the MAC from NIC Hardware PinmemberReader Man San21:51 31 Oct '06  
GeneralHostname from IP Address PinmemberDaLucifer0:03 1 Jul '06  
GeneralRe: Hostname from IP Address PinmemberMahendranG18:57 25 Jul '06  
GeneralRe: Hostname from IP Address PinmemberDaLucifer6:07 26 Jul '06  
GeneralHow to Get MAC Address from an IP Address in Internet Pinmemberdathq8:02 22 May '06  
GeneralMAC Address of PC;s turned off... PinmemberKevinReece5:34 19 Apr '06  
GeneralRe: MAC Address of PC;s turned off... PinmemberMahendranG19:48 19 Apr '06  
GeneralVB.NET 2005 Example PinmemberFloatingPointCode5:43 6 Apr '06  
GeneralRe: VB.NET 2005 Example PinmemberMahendranG18:14 10 Apr '06  
GeneralRe: VB.NET 2005 Example PinmemberFloatingPointCode6:04 11 Apr '06  
GeneralRe: VB.NET 2005 Example Pinmemberjuacar0110:20 29 Jul '06  
GeneralsendARP PinmemberESTANNY5:50 27 Jan '06  
Generalworkgroup name Pinmember10164:33 24 Jan '06  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 23 Jan 2005
Editor: Sumalatha K.R.
Copyright 2005 by MahendranG
Everything else Copyright © CodeProject, 1999-2009
Web22 | Advertise on the Code Project