Board index » delphi » How to get the MAC Address from an IP Address?

How to get the MAC Address from an IP Address?

Hi, Can someone tell me where to look to find out how to get the MAC address
of a client using the IP Address?

Regards,

M. Said
mune...@mail.com

 

Re:How to get the MAC Address from an IP Address?


On Tue, 10 Jun 2003 08:42:59 -0500, "M. Said" <mune...@xmail.com>
wrote:

Quote
>Hi, Can someone tell me where to look to find out how to get the MAC address
>of a client using the IP Address?

See "Address Resolution protocol"  

type "arp -a" in a command window

Regards from Germany

Franz-Leo

Re:How to get the MAC Address from an IP Address?


Thanks for the Quick Response.

I would like to programaticaly do this.  Even "arp -a" does not show MAC
addresses out of my subnet.

I tried to use SendARP, worked on local subnet only.

I will next try to use WinPCap, but I would to see if there is something
easier I can use.

Regards,

M. Said
mune...@mail.com

Quote
"Franz-Leo Chomse" <franz-leo.cho...@samac.de> wrote in message

news:o7sbev4djeq5a5kc8argfiiuk327e1eq0u@4ax.com...
Quote
> On Tue, 10 Jun 2003 08:42:59 -0500, "M. Said" <mune...@xmail.com>
> wrote:

> >Hi, Can someone tell me where to look to find out how to get the MAC
address
> >of a client using the IP Address?

> See "Address Resolution protocol"

> type "arp -a" in a command window

> Regards from Germany

> Franz-Leo

Re:How to get the MAC Address from an IP Address?


Quote
"M. Said" <mune...@xmail.com> wrote:
>I tried to use SendARP, worked on local subnet only.

I am not sure you will get anything useful beyond your local
subnet. As soon as you're talking to a 'remote' machine (in
a different subnet), you're in fact talking to the MAC Address
of the router.
If the machine is running TCPBEUI (aka netbios over tcp/ip) then
you could try the MS KB Article Q175472 (deals with VB, but you
should get the idea).

--
Ben

Re:How to get the MAC Address from an IP Address?


Quote
>I tried to use SendARP, worked on local subnet only.

That's as designed.

Quote
>I will next try to use WinPCap, but I would to see if there is something
>easier I can use.

ARP is the level at which the information is available.

Regards from Germany

Franz-Leo

Re:How to get the MAC Address from an IP Address?


have a look at this below.
 you can read up on more details in the winsock2 specs..
look for NetBios/
Uses Nb30;

procedure TForm1.Button1Click(Sender: TObject);
type
 TAstat = Record
   A:TAdapterStatus;
   N:TNameBuffer;
  End;

Var
 Ast:Tastat;
 NCB:TNCB;
 X:integer;
 S:String;
begin
 Listbox1.Clear;
 Fillchar(Ast, sizeof(Ast),0);
 NCB.ncb_command := Char(NCBRESET);
 NetBios(@NCB);
 NCB.ncb_lana_num := #0;
 NCB.ncb_callname := '*           ';
 NCB.ncb_buffer := @Ast;
 NCB.ncb_length := Sizeof(Ast);
 Byte(NCB.ncb_command) :=  NCBASTAT;
 NetBios(@NCB);
 S := '';
 For X := 0 to 5 do
  Begin
   if S <> '' Then S := S+'-';
   S := S+IntToHex(Byte(ASt.A.Adapter_address[x]),2);
  End;
  ListBox1.Items.add(S);
end;

Quote
"M. Said" wrote:
> Hi, Can someone tell me where to look to find out how to get the MAC address
> of a client using the IP Address?

> Regards,

> M. Said
> mune...@mail.com

Re:How to get the MAC Address from an IP Address?


Thanks for the info.

I will try using SNMP and get the info from the router.  I know it is there
<g>

Regards,

mune...@mail.com

Quote
"Franz-Leo Chomse" <franz-leo.cho...@samac.de> wrote in message

news:2uubevcnv05tf69srbaegb49007q500hk8@4ax.com...
Quote

> >I tried to use SendARP, worked on local subnet only.

> That's as designed.

> >I will next try to use WinPCap, but I would to see if there is something
> >easier I can use.

> ARP is the level at which the information is available.

> Regards from Germany

> Franz-Leo

Re:How to get the MAC Address from an IP Address?


Quote
> I tried to use SendARP, worked on local subnet only.

Outside of your subnet, you would only get the router MAC address.
However you could interrogate the router ARP table to get what is known from
the router point of view. Not an easy task...

--
Contribute to the SSL Effort. Visit
http://overbyte.delphicenter.com/eng/ssl.html
--
francois.pie...@overbyte.be
The author for the freeware multi-tier middleware MidWare
The author of the freeware Internet Component Suite (ICS)
http://www.overbyte.be

Other Threads