Solved

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

Posted on 2007-03-18
7
2,442 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ASA Troubleshooting: Easy way to determine an interface's next hop 18 71
Cisco Access point 6 87
Macbook Sierra OS OpenVPN issue 13 80
IPv6 NAT to IPv4 27 48
#Citrix #Citrix Netscaler #HTTP Compression #Load Balance
If you're not part of the solution, you're part of the problem.   Tips on how to secure IoT devices, even the dumbest ones, so they can't be used as part of a DDoS botnet.  Use PRTG Network Monitor as one of the building blocks, to detect unusual…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
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.

786 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