Resolving MAC address

Peter Heerboth pheerboth at apple.com
Thu Mar 24 15:11:38 PST 2005


One thing you can try if you want to avoid needing super user 
privileges is to send a small UDP packet to the given IP, which will 
force the kernel to ARP for the address if it is not already present.  
Then you can check the routing table through sysctl() by passing in 
{CTL_NET, PF_ROUTE, 0, AF_INET,NET_RT_FLAGS,RTF_LLINFO} for the name 
parameter and searching through the route message list.  All sending 
the UDP packet will do is force the kernel to arp, it doesn't actually 
matter if the other side is filtering or not.

On Mar 23, 2005, at 7:58 PM, Olivier Nicole wrote:

>>> ? (10.0.0.1) at 00:e0:29:ad:5a:aa on em0 [ethernet]
>>>
>>> will do the trick, but it is a bit too heavy for the purpose, I'd
>>> prefer a solution that only send an ARP request.
>>>
>>
>> If you just want to avoid the DNS lookup, you can use arp -an.
>> Its much faster :)
>
> Thanks. Off course I use arp -n to avoid DNS resolution.
>
> But what i really want to avoid is sending any IP/ICMP packet when the
> ARP resolution is all I need. (And some people even filter out the
> ICMP echo request packets (Windows XP firewall), so I have to wait for
> the time out).
>
> Olivier
> _______________________________________________
> freebsd-net at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-net
> To unsubscribe, send any mail to "freebsd-net-unsubscribe at freebsd.org"



More information about the freebsd-net mailing list