From owner-freebsd-net@FreeBSD.ORG Fri Aug 15 04:16:36 2003 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C169A37B401 for ; Fri, 15 Aug 2003 04:16:36 -0700 (PDT) Received: from raven.ravenbrook.com (raven.ravenbrook.com [193.82.131.18]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5984C43F3F for ; Fri, 15 Aug 2003 04:16:35 -0700 (PDT) (envelope-from nb@ravenbrook.com) Received: from thrush.ravenbrook.com (thrush.ravenbrook.com [193.112.141.249]) by raven.ravenbrook.com (8.12.6/8.12.6) with ESMTP id h7FBGVuL070153; Fri, 15 Aug 2003 12:16:31 +0100 (BST) (envelope-from nb@ravenbrook.com) Received: from thrush.ravenbrook.com (localhost [127.0.0.1]) by thrush.ravenbrook.com (8.12.9/8.12.9) with ESMTP id h7FBDvnH075603; Fri, 15 Aug 2003 12:13:57 +0100 (BST) (envelope-from nb@thrush.ravenbrook.com) From: Nick Barnes To: Lars Eggert In-Reply-To: Message from Lars Eggert of "Wed, 13 Aug 2003 08:43:51 PDT." <3F3A5CB7.5070006@isi.edu> Date: Fri, 15 Aug 2003 12:13:57 +0100 Message-ID: <75602.1060946037@thrush.ravenbrook.com> Sender: nb@ravenbrook.com cc: freebsd-net@freebsd.org Subject: Re: Translate MAC address to IP address X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Aug 2003 11:16:37 -0000 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