Skip to main content

MAC to IP address

More
16 years 9 months ago #24637 by saidfrh
MAC to IP address was created by saidfrh
Hi,
If I have the MAC address of a host, how can I find its IP address? We have Win XP on hosts and Win 2003 on the server.
Thanks.
More
16 years 9 months ago #24638 by S0lo
Replied by S0lo on topic Re: MAC to IP address
Do this on one of your hosts or preferably on your server:

[code:1]arp -a[/code:1]

This will display a list of cached IP to MAC mappings. Search for your target mac in the list. And take the corresponding IP.

If you can not find your MAC in the list. Then you need to some how make your local PC talk to that target PC inorder to cache its IP. You could right a small script to ping the whole subnet. Some thing like this:

[code:1]for /L %i in (1,1,254) do ping 192.168.1.%i -w 1 -n 1[/code:1]

Replace the 192.168.1. above with your subnetwork address. This will ping IPs 192.168.1.1 to 192.168.1.254. When it is done the MACs are cached. You can now do arp -a again and see if you can find your target MAC there.

Hope that helps and does not confuse.

Studying CCNP...

Ammar Muqaddas
Forum Moderator
www.firewall.cx
More
16 years 9 months ago #24648 by SteveP
Replied by SteveP on topic Re: MAC to IP address
Hi S0lo

It's amazing - I've been wanting to do exactly this for ages and have been researching but I was looking for a solution which was much more complicated (and less elegant!) than your automatic ping.

Is there any way to automate this further? What I mean is that the subnet address and number of usable hosts have to be specified in the "for" command. I know it's easy enough to get (and calculate) this information from ipconfig /all, but is there any way of having the script get the subnet address and number of usable hosts automatically?

I managed to get my own IP address from:

@echo off
REM myip.bat
REM script to return just the IP address of the current host.
REM Works on Windows 2000 / Windows XP

FOR /F "usebackq tokens=2 delims=[]" %%i in (`ping -n 1 %computername%`) do set myip=%%i
ECHO.
ECHO This computer's IP address is %MYIP%
echo.

but I haven't been able to find a way of getting the subnetwork address and number of usable hosts automatically.

Thanks for your (and anyone else's) time.
More
16 years 9 months ago #24651 by S0lo
Replied by S0lo on topic Re: MAC to IP address

FOR /F "usebackq tokens=2 delims=[]" %%i in (`ping -n 1 %computername%`) do set myip=%%i


Thats a nice peace too!! It's definitly not easy to get the IP range automatically. At least for me. To be onist, I usually do such scans with an automated tool. Something like Angry Scanner www.angryziber.com/w/Home

You just give it the start/end addresses and it scans them getting thier MACs and a bunch of other infos automaticaly.

Studying CCNP...

Ammar Muqaddas
Forum Moderator
www.firewall.cx
More
16 years 9 months ago #24656 by SteveP
Replied by SteveP on topic Re: MAC to IP address
Yes S0lo, I figured it wouldn't be easy, even if it's possible. I thought of ANDing the current IP address with the SNM (question for self: "Can I AND with batch?") which would give me the current Subnetwork address but then there would be a lot of maths and IF statements to get the number of usable hosts, depending upon whether it's a class A, B or C and then how many bits were borrowed ..... nightmare!

I don't think I'll persue this, but if anyone comes up with a solution or further comments, I'd be interested.
Time to create page: 0.129 seconds