Hot Downloads

Welcome, Guest
Username: Password: Remember me

TOPIC: MAC to IP address

MAC to IP address 8 years 11 months ago #24637

  • saidfrh
  • saidfrh's Avatar
  • Offline
  • Distinguished Member
  • Posts: 92
  • Karma: 0
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.
The administrator has disabled public write access.

Re: MAC to IP address 8 years 11 months ago #24638

  • S0lo
  • S0lo's Avatar
  • Offline
  • Moderator
  • Posts: 1577
  • Thank you received: 7
  • Karma: 3
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
The administrator has disabled public write access.

Re: MAC to IP address 8 years 11 months ago #24648

  • SteveP
  • SteveP's Avatar
  • Offline
  • Distinguished Member
  • Posts: 161
  • Karma: 0
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.
The administrator has disabled public write access.

Re: MAC to IP address 8 years 11 months ago #24651

  • S0lo
  • S0lo's Avatar
  • Offline
  • Moderator
  • Posts: 1577
  • Thank you received: 7
  • Karma: 3
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
The administrator has disabled public write access.

Re: MAC to IP address 8 years 11 months ago #24656

  • SteveP
  • SteveP's Avatar
  • Offline
  • Distinguished Member
  • Posts: 161
  • Karma: 0
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.
The administrator has disabled public write access.
Time to create page: 0.080 seconds

CCENT/CCNA

Cisco Routers

  • SSL WebVPN
  • Securing Routers
  • Policy Based Routing
  • Router on-a-Stick

VPN Security

  • Understand DMVPN
  • GRE/IPSec Configuration
  • Site-to-Site IPSec VPN
  • IPSec Modes

Cisco Help

  • VPN Client Windows 8
  • VPN Client Windows 7
  • CCP Display Problem
  • Cisco Support App.

Windows 2012

  • New Features
  • Licensing
  • Hyper-V / VDI
  • Install Hyper-V

Linux

  • File Permissions
  • Webmin
  • Groups - Users
  • Samba Setup