Date: Fri, 15 Aug 2003 12:13:57 +0100 From: Nick Barnes <Nick.Barnes@pobox.com> To: Lars Eggert <larse@ISI.EDU> Cc: freebsd-net@freebsd.org Subject: Re: Translate MAC address to IP address Message-ID: <75602.1060946037@thrush.ravenbrook.com> In-Reply-To: Message from Lars Eggert <larse@ISI.EDU> of "Wed, 13 Aug 2003 08:43:51 PDT." <3F3A5CB7.5070006@isi.edu>
next in thread | previous in thread | raw e-mail | index | archive | help
At 2003-08-13 15:43:51+0000, Lars Eggert writes: > This is a cryptographically signed message in MIME format. > > --------------ms070709090404010406080107 > Content-Type: text/plain; charset=us-ascii; format=flowed > Content-Transfer-Encoding: 7bit > > Nick Barnes wrote: > > > [-net seems to be the right forum for this.] > > > > I have some MAC addresses from a local Ethernet segment. I want to > > convert them into IP addresses. How can I do that programmatically? > > net/arping from port: Thanks for the reference. I had a look at arping. It works by sending a broadcast ping to the specified MAC address (not to the broadcast MAC). I note that FreeBSD machines do respond to such pings (unlike regular broadcast pings), but some machines do not (e.g. WinXPPro, NT4). Since asking the question, I have been rummaging around in user-space network code (e.g. in the sources for arp, ping, and ifconfig) and have written a couple of little utilities: - "ifget" lists IP addresses accessible on local subnets via active network interfaces (in fact I have two implementations of this, one written before I discovered getifaddrs() and one written after). This is all possible IP addresses (in the range defined by the netmask, for broadcast interfaces). It skips interfaces which are loopback, down, not running, not AF_INET, or not IFM_ACTIVE. - "pingall" sends a single ping packet to all such IP addresses and then exits. This causes an ARP exchange for any such address not currently in the local ARP table, so populates that table (including a lot of "incomplete" entries, for unassigned IP addresses). Next week I may spend the time to extend my "ethercount" program, using the "pingall" code and the guts of "arp -a", to report using IP addresses instead of MACs. I can provide sources on request any time; once these things are a bit more polished I will put them on the web. Nick B
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?75602.1060946037>