Script extracting ip address from MAC wifi card


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script extracting ip address from MAC wifi card
# 1  
Old 10-30-2014
Script extracting ip address from MAC wifi card

Hi Everybody,

Goal:
From my backup box on my local network, knowing the Wifi MAC address of my laptop, I would like to dynamically identify which ip address is attributed to my laptop.
The aim is to store this ip address in a local variable and that this information is retrieved by another backup script

Problem:
Calling the command nmap, as root user I want to write a script that will extract the ip address from the MAC address of my laptop.

Question:
How would you do that and with which script language?
Shell, perl, python?


Example:
from the result of nmap and with the MAC address X1:X2:3X:X4:X5:Y6, I want to extract:
Code:
Laptop-Fred=192.168.0.10

Code:
# nmap 
Starting Nmap 6.45 ( Nmap - Free Security Scanner For Network Exploration & Security Audits. ) at 2014-10-30 07:05 CET
Nmap scan report for 192.168.0.1
Host is up (0.0047s latency).
MAC Address: XX:XF:0X:X1:XX:YY (Netgear)
Nmap scan report for 192.168.0.10
Host is up (0.074s latency).
MAC Address: X1:X2:3X:X4:X5:Y6 (Netgear)
Host is up.
Nmap done: 256 IP addresses (2 hosts up) scanned in 5.61 seconds

Many thanks for any input!
Keep up the good work.
Cheers,
Smilie

Last edited by Scrutinizer; 10-30-2014 at 05:57 AM.. Reason: code tags
freddie50
# 2  
Old 10-30-2014
Where do you get the string "Laptop-Fred"?
And do you want to extract the IP from the output of nmap?
Does the mac X1:X2:3X:X4:X5:Y6 corresponds to 192.168.0.10?

--ahamed
# 3  
Old 10-30-2014
Yes,
1. Absolutely I would like to extract the information from the output of nmap, unless you see another way?

2. Laptop-Fred would be a variable to store the ip address

3. X1:X2:3X:X4:X5:Y6 is in this example the MAC address of Laptop Fred Wifi card.

Thank you,
freddie50
# 4  
Old 10-30-2014
You didnt answer my 2nd and 3rd question correctly.

2. From where would I get the name "Laptop-Fred"?

3. Does the mac X1:X2:3X:X4:X5:Y6 corresponds to 192.168.0.10?

--ahamed
# 5  
Old 10-30-2014
I apology for being unclear,

2. Laptop-Fred was in my mind a shell variable, call it var_laptop_1 if this is better and this vari2ble would have to store the ip address 192.168.0.10 of the laptop we are trying to identify

3. From the result of nmap in this dhcp configuration the mac address X1:X2:3X:X4:X5:Y6 corresponds to 192.168.0.10

Thank you very much for your help,
freddie50
# 6  
Old 10-30-2014
There doesn't seem to be a relation between laptop-1 or laptop_fred and the MAC address given. So how should any command/program/script select 192.168.0.10 instead of 192.168.0.1 to place into your variable?

---------- Post updated at 11:58 ---------- Previous update was at 11:54 ----------

For a known MAC address, you could use sth like
Code:
LAPTOP_FRED=$(nmap|awk '/Nmap scan report/ {IP=$NF} /X1:X2:3X:X4:X5:Y6/ {print IP}' )

# 7  
Old 10-30-2014
Well, I think there is a relation:
The ip address associated to the MAC address
is the ip address 2 lines above the MAC address.
But how to extract this with a script?
Maybe should I first change the output of nmap?

Thank you so much for your help,
freddie50
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script who maps IP with MAC address

Hy every body, Unfortunately and without success, i want to write a bash script who maps a known IP addess to a known MAC address using iptables and for the FORWARD chain. Within the DHCP server, i have assigned a fixed IP address to all clients based on their MAC addresses of their... (11 Replies)
Discussion started by: hermouche
11 Replies

2. IP Networking

MAC Address - Four Interfaces with the same MAC Address

four interfaces with ifconfig all interfaces have the same mac. If is not set for unique. but it still works. what difference does it make to have all macs the same or different? (4 Replies)
Discussion started by: rrodgers
4 Replies

3. Linux

Kali cannot find WiFi card.

After installing the latest version of Kali on my Lenovo S21E laptop, I cannot access the internet. wlan0 does not show up in ifconfig and I cannot connect to the internet. If you need any other additional information, I will provide it. Thank you kindly. (8 Replies)
Discussion started by: Hotrod22
8 Replies

4. Hardware

HP notebook PC wifi card whitelist problem

I have hp dv6 and dv7 notebook pcs on which I want to upgrade the wifi cards but when I install the new cards and boot them, the they won't even boot to the bios and they both give me the same error: "104-Unsupported wireless network device detected. System Halted. Remove device and restart." When... (1 Reply)
Discussion started by: milhan
1 Replies

5. Ubuntu

Trouble with broadcomm card Wifi driver build

I'm having trouble getting my WIFI card to work. It's Device ID is :0c:00.0 0280: 14e4:4315 (rev 01). My OS is BT5. The card works with Lucid just fine. I've gone to the Hardware drivers to try and download it but when I try I always get this: SystemError: installArchives()failedI've gone to... (2 Replies)
Discussion started by: Mt3ng4
2 Replies

6. IP Networking

Tracing a MAC address to IP address: Solaris

Hi there I lost connectivity to one of our remote systems and when I checked the messages log I found the following: Aug 10 23:42:34 host xntpd: time reset (step) 1.681729 s Aug 16 13:20:51 host ip: WARNING: node "mac address" is using our IP address x.x.x.x on aggr1 Aug 16 13:20:51 host... (9 Replies)
Discussion started by: notreallyhere
9 Replies

7. Programming

Extracting video card properties

Hi everyone. I'm looking for a way to extract the video card properties (Name, Driver version, amount of vram). I've managed to deal with nVidia cards, but nothing came for ATI/AMD cards and other kind of chipsets. Can someone point a way to do this? Thanks. (4 Replies)
Discussion started by: JB007ROLV
4 Replies

8. Shell Programming and Scripting

script to compare two files of mac address

Hi I need to write a bash shell script. I have two separate text files. One file contains a list of MAC addresses taken from a network scan, the other contains a list of MAC addresses for our currently-managed devices. How can I compare these two files, and output a list of addresses that have... (6 Replies)
Discussion started by: borderblaster
6 Replies

9. IP Networking

How to Achive IP address through MAC(Ethernet) address

Hi sir, i want to make such programe which takes MAC(Ethernet) address of any host & give me its IP address....... but i'm nt getting that how i can pass the MAC address to Frame........ Please give me an idea for making such program... Thanks & regards Krishna (3 Replies)
Discussion started by: krishnacins
3 Replies

10. IP Networking

Mac address - what is line command to find and active new card

How do you find mac address and active new card. (1 Reply)
Discussion started by: wmetz
1 Replies
Login or Register to Ask a Question