Solved

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

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
paypal ipn status 4 61
ip igmp join-group 8 43
Windows 7 Internet issue 14 54
Netgear modem router default firmware 11 33
When it comes to security, there are always trade-offs between security and convenience/ease of administration. This article examines some of the main pros and cons of using key authentication vs password authentication for hosting an SFTP server.
When you try to share a printer , you may receive one of the following error messages. Error message when you use the Add Printer Wizard to share a printer: Windows could not share your printer. Operation could not be completed (Error 0x000006…
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…
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…

828 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