Solved

MAC address of a Remote machine given the IP address in Linux

Posted on 2007-03-18
7
2,433 Views
Last Modified: 2008-02-01
I would like to get the MAC address of a Remote machine given the IP address using C in an Redhat Linux vers 2.6 environment.
0
Comment
Question by:DaveAlmeida
7 Comments
 
LVL 1

Accepted Solution

by:
crackrocksteady earned 43 total points
ID: 18745619
Is the remote machine and the Redhat box going to be on the same broadcast domain? If not I don't see how you are going to arp for that mac address over the network...

Only thing I can think of is that you could use snmp and walk the iftable OID (1.3.6.1.2.1.2.2). That table has an entry called physical address that would have the mac address for that interface.

I'm sure there is a C library to easily do snmp gets.

0
 
LVL 12

Assisted Solution

by:ibu1
ibu1 earned 41 total points
ID: 18746375
/sbin/arp -a 192.168.1.1   (ip of remote machine)
0
 
LVL 14

Assisted Solution

by:pablouruguay
pablouruguay earned 41 total points
ID: 18746700
0
 

Author Comment

by:DaveAlmeida
ID: 18750532
The remote Machine Is not restricted to a Linux PC. It is most certainly within the same sub-net as the DHCP server for the interface is running on the local Linux device. The actual configuration is a point-point connection over USB between a PC host and a Linux Device. The user space application needs to set up a raw socket connection without knowing A Priori what the MAC address of the Remote Machine. The use of raw sockets is to demonstrate/dispute the performance gain of using raw sockets vs normal sockets when streaming UDP packets.  

In one of the solutions proposed, will not opening a socket connection to the USB network IFACE requesting all packets (ETH_P_ALL) and subsequently calling the driver with the ioctl call SIOCGIFHWADDR return the MAC address of the local USB device?

How can i accomplish this  short of isssuing an ARP command and examining the routing table afterwards?

Are there any libraries available used by packet sniffers/capture utilities that would could possibly do the trick?

It has been suggested to me that Issuing an ICMP request ove a connectionless socket and monitoring the resulting echo might be a solution. However I don't see how it could provide access to the Ethernet frame of the echo response.

0
 
LVL 14

Expert Comment

by:pablouruguay
ID: 18750606
sorry, not for me.. i give a solution about your question How to obtein a ip address from MAC.  now is another question more more more complex than the fist...


maybe anyone can help you... maybe iun linux programming
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Even if you have implemented a Mobile Device Management solution company wide, it is a good idea to make sure you are taking into account all of the major risks to your electronic protected health information (ePHI).
Don’t let your business fall victim to the coming apocalypse – use our Survival Guide for the Fax Apocalypse to identify the risks and signs of zombie fax activities at your business.
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now