Solved

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

Posted on 2007-03-18
7
2,453 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
This article is a collection of issues that people face from time to time and possible solutions to those issues. I hope you enjoy reading it.
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Suggested Courses
Course of the Month3 days, 22 hours left to enroll

630 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