PC Review


Reply
Thread Tools Rate Thread

Getting MAC address from IP Address

 
 
Jean-Michel Cafagna
Guest
Posts: n/a
 
      18th May 2005
Hi all,

I have a question for you,

I'm looking for a way to have the IP address corresponding to a MAC address

I've found this piece of code ( vbs was the original extension ) which gives
me the local IP address but I would like to enter a MAC address ( like
00-01-02-03-04-05 ) and then I would like in return the corresponding IP
address of the remote computer.

I'm not looking for code that gives me the MAC from an IP ( ping 1.1.1.1 and
arp -a will gives the answer)



strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set IPConfigSet = objWMIService.ExecQuery("Select IPAddress from
Win32_NetworkAdapterConfiguration where IPEnabled = TRUE")
For Each IPConfig In IPConfigSet
If Not IsNull(IPConfig.IPAddress) Then
For i = LBound(IPConfig.IPAddress) To UBound(IPConfig.IPAddress)
WScript.Echo IPConfig.IPAddress(i)
Next
End If
Next


Thanks for your help
J-Michel


 
Reply With Quote
 
 
 
 
Kurt
Guest
Posts: n/a
 
      18th May 2005
You can use nbtstat -A and type the IP address which will return (at the
bottom of the listing) the MAC address. You could write a little script that
tries every possible IP address in the subnet and outputs the results to a
file. Not exactly what you're looking for, but maybe an alternative. (Note:
your computer would have to be in the same broadcast domain as the computers
you're checking).

....kurt

"Jean-Michel Cafagna" <jmcafagna°AT°@hotmail.com> wrote in message
news:428b34c9$0$22981$(E-Mail Removed)...
> Hi all,
>
> I have a question for you,
>
> I'm looking for a way to have the IP address corresponding to a MAC

address
>
> I've found this piece of code ( vbs was the original extension ) which

gives
> me the local IP address but I would like to enter a MAC address ( like
> 00-01-02-03-04-05 ) and then I would like in return the corresponding IP
> address of the remote computer.
>
> I'm not looking for code that gives me the MAC from an IP ( ping 1.1.1.1

and
> arp -a will gives the answer)
>
>
>
> strComputer = "."
> Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
> Set IPConfigSet = objWMIService.ExecQuery("Select IPAddress from
> Win32_NetworkAdapterConfiguration where IPEnabled = TRUE")
> For Each IPConfig In IPConfigSet
> If Not IsNull(IPConfig.IPAddress) Then
> For i = LBound(IPConfig.IPAddress) To UBound(IPConfig.IPAddress)
> WScript.Echo IPConfig.IPAddress(i)
> Next
> End If
> Next
>
>
> Thanks for your help
> J-Michel
>
>



 
Reply With Quote
 
Al Dykes
Guest
Posts: n/a
 
      18th May 2005
In article <(E-Mail Removed)>,
Kurt <(E-Mail Removed)> wrote:
>You can use nbtstat -A and type the IP address which will return (at the
>bottom of the listing) the MAC address. You could write a little script that
>tries every possible IP address in the subnet and outputs the results to a
>file. Not exactly what you're looking for, but maybe an alternative. (Note:
>your computer would have to be in the same broadcast domain as the computers
>you're checking).
>
>...kurt
>
>"Jean-Michel Cafagna" <jmcafagna°AT°@hotmail.com> wrote in message
>news:428b34c9$0$22981$(E-Mail Removed)...
>> Hi all,
>>
>> I have a question for you,
>>
>> I'm looking for a way to have the IP address corresponding to a MAC

>address
>>
>> I've found this piece of code ( vbs was the original extension ) which

>gives
>> me the local IP address but I would like to enter a MAC address ( like
>> 00-01-02-03-04-05 ) and then I would like in return the corresponding IP
>> address of the remote computer.
>>
>> I'm not looking for code that gives me the MAC from an IP ( ping 1.1.1.1

>and
>> arp -a will gives the answer)
>>
>>
>>
>> strComputer = "."
>> Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
>> Set IPConfigSet = objWMIService.ExecQuery("Select IPAddress from
>> Win32_NetworkAdapterConfiguration where IPEnabled = TRUE")
>> For Each IPConfig In IPConfigSet
>> If Not IsNull(IPConfig.IPAddress) Then
>> For i = LBound(IPConfig.IPAddress) To UBound(IPConfig.IPAddress)
>> WScript.Echo IPConfig.IPAddress(i)
>> Next
>> End If
>> Next
>>
>>
>> Thanks for your help
>> J-Michel
>>
>>

>
>



If you ping an IP number and then do an arp -a the IP number shows
up, so in a script youi can do something like this

ping nn.nn.nn.nn | grep nn.nn.nn.nn

A little more scripting will extract the MAC number from the rest of
the info returned. the IP number has to be in the same mask, of
course.

Am I missing something ?


--
a d y k e s @ p a n i x . c o m

Don't blame me. I voted for Gore.
 
Reply With Quote
 
Al Dykes
Guest
Posts: n/a
 
      19th May 2005
In article <428b34c9$0$22981$(E-Mail Removed)>,
Jean-Michel Cafagna <jmcafagna°AT°@hotmail.com> wrote:
>Hi all,
>
>I have a question for you,
>
>I'm looking for a way to have the IP address corresponding to a MAC address
>
>I've found this piece of code ( vbs was the original extension ) which gives
>me the local IP address but I would like to enter a MAC address ( like
>00-01-02-03-04-05 ) and then I would like in return the corresponding IP
>address of the remote computer.
>
>I'm not looking for code that gives me the MAC from an IP ( ping 1.1.1.1 and
>arp -a will gives the answer)
>
>
>
>strComputer = "."
>Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
>Set IPConfigSet = objWMIService.ExecQuery("Select IPAddress from
>Win32_NetworkAdapterConfiguration where IPEnabled = TRUE")
>For Each IPConfig In IPConfigSet
> If Not IsNull(IPConfig.IPAddress) Then
> For i = LBound(IPConfig.IPAddress) To UBound(IPConfig.IPAddress)
> WScript.Echo IPConfig.IPAddress(i)
> Next
> End If
>Next
>
>
>Thanks for your help
>J-Michel
>
>



If you ping an IP number and get a response then do an arp -a you'll
find the MAC address, which could be grepped in a script.

--
a d y k e s @ p a n i x . c o m

Don't blame me. I voted for Gore.
 
Reply With Quote
 
Jean-Michel Cafagna
Guest
Posts: n/a
 
      19th May 2005
Thanks kurt for your reply but Actually that was not the way I was thinking
doing the things but anyway I'm trying since this morning to write a script
using WSH ( and actually to execute VBscript code ) I wrote the logic but I
still missing a function to first ping a host, and secondly a function to
get the MAC address from the arp table.
I would prefer not to use the commands arp and ping, because I don't know
how to get the correct information and if the ping command fails, I don't
know how and even if it's possible to know the reason it failed


Jean-Michel
PS: I tried nbstat ( Windows XP doesn't have that command ) .


"Kurt" <(E-Mail Removed)> a écrit dans le message de news:
(E-Mail Removed)...
> You can use nbtstat -A and type the IP address which will return (at the
> bottom of the listing) the MAC address. You could write a little script

that
> tries every possible IP address in the subnet and outputs the results to a
> file. Not exactly what you're looking for, but maybe an alternative.

(Note:
> your computer would have to be in the same broadcast domain as the

computers
> you're checking).
>
> ...kurt
>
> "Jean-Michel Cafagna" <jmcafagna°AT°@hotmail.com> wrote in message
> news:428b34c9$0$22981$(E-Mail Removed)...
> > Hi all,
> >
> > I have a question for you,
> >
> > I'm looking for a way to have the IP address corresponding to a MAC

> address
> >
> > I've found this piece of code ( vbs was the original extension ) which

> gives
> > me the local IP address but I would like to enter a MAC address ( like
> > 00-01-02-03-04-05 ) and then I would like in return the corresponding IP
> > address of the remote computer.
> >
> > I'm not looking for code that gives me the MAC from an IP ( ping 1.1.1.1

> and
> > arp -a will gives the answer)
> >
> >
> >
> > strComputer = "."
> > Set objWMIService = GetObject("winmgmts:\\" & strComputer &

"\root\cimv2")
> > Set IPConfigSet = objWMIService.ExecQuery("Select IPAddress from
> > Win32_NetworkAdapterConfiguration where IPEnabled = TRUE")
> > For Each IPConfig In IPConfigSet
> > If Not IsNull(IPConfig.IPAddress) Then
> > For i = LBound(IPConfig.IPAddress) To UBound(IPConfig.IPAddress)
> > WScript.Echo IPConfig.IPAddress(i)
> > Next
> > End If
> > Next
> >
> >
> > Thanks for your help
> > J-Michel
> >
> >

>
>



 
Reply With Quote
 
Jean-Michel Cafagna
Guest
Posts: n/a
 
      19th May 2005
Thanks for you reply

but in the way you're leading me, how can I grep the info I need and not
all the rest of the output.

J-Michel

"Al Dykes" <(E-Mail Removed)> a écrit dans le message de news:
d6gg1u$m13$(E-Mail Removed)...
> In article <428b34c9$0$22981$(E-Mail Removed)>,
> Jean-Michel Cafagna <jmcafagna°AT°@hotmail.com> wrote:
> >Hi all,
> >
> >I have a question for you,
> >
> >I'm looking for a way to have the IP address corresponding to a MAC

address
> >
> >I've found this piece of code ( vbs was the original extension ) which

gives
> >me the local IP address but I would like to enter a MAC address ( like
> >00-01-02-03-04-05 ) and then I would like in return the corresponding IP
> >address of the remote computer.
> >
> >I'm not looking for code that gives me the MAC from an IP ( ping 1.1.1.1

and
> >arp -a will gives the answer)
> >
> >
> >
> >strComputer = "."
> >Set objWMIService = GetObject("winmgmts:\\" & strComputer &

"\root\cimv2")
> >Set IPConfigSet = objWMIService.ExecQuery("Select IPAddress from
> >Win32_NetworkAdapterConfiguration where IPEnabled = TRUE")
> >For Each IPConfig In IPConfigSet
> > If Not IsNull(IPConfig.IPAddress) Then
> > For i = LBound(IPConfig.IPAddress) To UBound(IPConfig.IPAddress)
> > WScript.Echo IPConfig.IPAddress(i)
> > Next
> > End If
> >Next
> >
> >
> >Thanks for your help
> >J-Michel
> >
> >

>
>
> If you ping an IP number and get a response then do an arp -a you'll
> find the MAC address, which could be grepped in a script.
>
> --
> a d y k e s @ p a n i x . c o m
>
> Don't blame me. I voted for Gore.



 
Reply With Quote
 
Al Dykes
Guest
Posts: n/a
 
      19th May 2005
In article <428ca584$0$22982$(E-Mail Removed)>,
Jean-Michel Cafagna <jmcafagna°AT°@hotmail.com> wrote:
>Thanks for you reply
>
>but in the way you're leading me, how can I grep the info I need and not
>all the rest of the output.
>
>J-Michel
>



A small matter of scripting. :-)

I have the unix toolkit on all my machines.


ping can be a PITA to script because it waits and may not time out if
the IP is unreachable, but I imagine that any other network operation
that returns a succeed/fail status on a IP number should populate the
local arp table. If the operation fails then for all practical
purposes the machine doesn't exist.

Look at arp-a and then it's a small matter of programming.


>"Al Dykes" <(E-Mail Removed)> a écrit dans le message de news:
>d6gg1u$m13$(E-Mail Removed)...
>> In article <428b34c9$0$22981$(E-Mail Removed)>,
>> Jean-Michel Cafagna <jmcafagna°AT°@hotmail.com> wrote:
>> >Hi all,
>> >
>> >I have a question for you,
>> >
>> >I'm looking for a way to have the IP address corresponding to a MAC

>address
>> >


--
a d y k e s @ p a n i x . c o m

Don't blame me. I voted for Gore.
 
Reply With Quote
 
Jean-Michel Cafagna
Guest
Posts: n/a
 
      20th May 2005
Yes,
has you said a small matter of scripting ;-) but the small

anyway I'm writing and learning VBScript code at the same time and I'm sure
I will find the way to success :-)
I have almost the work done but I stil have to write the worst part, finding
the informations collected and write it in a file ( ok writing in a file is
tricky).

J-Michel
"Al Dykes" <(E-Mail Removed)> a écrit dans le message de news:
d6i90h$8l$(E-Mail Removed)...
> In article <428ca584$0$22982$(E-Mail Removed)>,
> Jean-Michel Cafagna <jmcafagna°AT°@hotmail.com> wrote:
> >Thanks for you reply
> >
> >but in the way you're leading me, how can I grep the info I need and not
> >all the rest of the output.
> >
> >J-Michel
> >

>
>
> A small matter of scripting. :-)
>
> I have the unix toolkit on all my machines.
>
>
> ping can be a PITA to script because it waits and may not time out if
> the IP is unreachable, but I imagine that any other network operation
> that returns a succeed/fail status on a IP number should populate the
> local arp table. If the operation fails then for all practical
> purposes the machine doesn't exist.
>
> Look at arp-a and then it's a small matter of programming.
>
>
> >"Al Dykes" <(E-Mail Removed)> a écrit dans le message de news:
> >d6gg1u$m13$(E-Mail Removed)...
> >> In article <428b34c9$0$22981$(E-Mail Removed)>,
> >> Jean-Michel Cafagna <jmcafagna°AT°@hotmail.com> wrote:
> >> >Hi all,
> >> >
> >> >I have a question for you,
> >> >
> >> >I'm looking for a way to have the IP address corresponding to a MAC

> >address
> >> >

>
> --
> a d y k e s @ p a n i x . c o m
>
> Don't blame me. I voted for Gore.



 
Reply With Quote
 
Jean-Michel Cafagna
Guest
Posts: n/a
 
      24th May 2005
Finally I've finished the script but I still have to add more functionality
and certainly have a code more "Professionnal", if someone is intrested I
may send the script on the forum or to personnal email addresses.

thanks one more time for the ideas
J-Michel

"Jean-Michel Cafagna" <jmcafagna°AT°@hotmail.com> a écrit dans le message de
news: 428df9e7$0$8234$(E-Mail Removed)...
> Yes,
> has you said a small matter of scripting ;-) but the small
>
> anyway I'm writing and learning VBScript code at the same time and I'm

sure
> I will find the way to success :-)
> I have almost the work done but I stil have to write the worst part,

finding
> the informations collected and write it in a file ( ok writing in a file

is
> tricky).
>
> J-Michel
> "Al Dykes" <(E-Mail Removed)> a écrit dans le message de news:
> d6i90h$8l$(E-Mail Removed)...
> > In article <428ca584$0$22982$(E-Mail Removed)>,
> > Jean-Michel Cafagna <jmcafagna°AT°@hotmail.com> wrote:
> > >Thanks for you reply
> > >
> > >but in the way you're leading me, how can I grep the info I need and

not
> > >all the rest of the output.
> > >
> > >J-Michel
> > >

> >
> >
> > A small matter of scripting. :-)
> >
> > I have the unix toolkit on all my machines.
> >
> >
> > ping can be a PITA to script because it waits and may not time out if
> > the IP is unreachable, but I imagine that any other network operation
> > that returns a succeed/fail status on a IP number should populate the
> > local arp table. If the operation fails then for all practical
> > purposes the machine doesn't exist.
> >
> > Look at arp-a and then it's a small matter of programming.
> >
> >
> > >"Al Dykes" <(E-Mail Removed)> a écrit dans le message de news:
> > >d6gg1u$m13$(E-Mail Removed)...
> > >> In article <428b34c9$0$22981$(E-Mail Removed)>,
> > >> Jean-Michel Cafagna <jmcafagna°AT°@hotmail.com> wrote:
> > >> >Hi all,
> > >> >
> > >> >I have a question for you,
> > >> >
> > >> >I'm looking for a way to have the IP address corresponding to a MAC
> > >address
> > >> >

> >
> > --
> > a d y k e s @ p a n i x . c o m
> >
> > Don't blame me. I voted for Gore.

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Explorer: Address Violation at address xxxxxxxx Read of address xx =?Utf-8?B?UGFzY2Fs?= Windows XP General 3 9th Oct 2006 01:56 AM
IP Address in ipconfig differs from IP Address on IP address checking websites Dano Windows XP Networking 5 28th Apr 2006 09:11 PM
To:Address, I start to type address, saved address comes up I cli. =?Utf-8?B?ZW1waXJlc2luYw==?= Microsoft Outlook Discussion 1 17th Sep 2004 01:14 PM
Outlook 2003 -Duplicating account address in business contact address field Fran Microsoft Outlook Contacts 0 6th Dec 2003 08:51 PM
Clicking on web address lists current address and new address West Windows XP Internet Explorer 0 15th Aug 2003 08:06 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:10 PM.