Find the answer to your Linux question:
Results 1 to 6 of 6
Can somebody tell me how to resolve MAC address of the next hop, in the C program ? I have the IP address of next hop....
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Sep 2007
    Posts
    3

    resolving MAC address of the next hop


    Can somebody tell me how to resolve MAC address of the next hop, in the C program ? I have the IP address of next hop.

  2. #2
    Linux Enthusiast
    Join Date
    Apr 2004
    Location
    UK
    Posts
    682
    To the best of my knowledge, you can't easily get MAC addresses beyond your broadcast range, normally your default gateway.

    If you can tell us what you are trying to do, we may be able to suggest an alternate method.

    Let us know how you get on,

    Chris...
    To be good, you must first be bad. "Newbie" is a rank, not a slight.

  3. #3
    Just Joined!
    Join Date
    Sep 2007
    Posts
    3

    get MAC addresses

    Quote Originally Posted by kakariko81280 View Post
    To the best of my knowledge, you can't easily get MAC addresses beyond your broadcast range, normally your default gateway.

    If you can tell us what you are trying to do, we may be able to suggest an alternate method.

    Let us know how you get on,

    Chris...


    My next hop is directly connected with my machine, so that will be in my broadcast range. isn't it ?

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Enthusiast
    Join Date
    Apr 2004
    Location
    UK
    Posts
    682
    If it's directly connected then yes, it will be in your broadcast range and you should be able to look up the MAC address for it. Check by running "arp -a"

    The ARP cache is a list of IPs and MAC addresses stored in the kernel along with a few other details. You could probably access this directly but you'd need someone else's help there.

    A quick and dirty solution would be to read /proc/net/arp. It contains the information you need in a reasonably verbose format. You should be able to parse it for the information you need.

    Let us know how you get on,

    Chris...
    To be good, you must first be bad. "Newbie" is a rank, not a slight.

  6. #5
    Just Joined!
    Join Date
    Sep 2007
    Posts
    3

    resolving MAC

    I want to code whole process in C program i.e sending arp, getting MAC etc.
    I have Next hop IP address with me.
    Is there any system call which I can call in my program (user space)? or any alternative way in program.

    Thanks

  7. #6
    Just Joined!
    Join Date
    Oct 2005
    Posts
    10

    Resolving MAC address from C code

    Hi,

    Yes you can do this by invoking this instruction in your C program as given below code...

    system("arp -a IP-address");


    Regards
    Jyothi Vajja

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •