From owner-freebsd-net Thu Jul 18 7:27:11 2002 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 AFAB137B400 for ; Thu, 18 Jul 2002 07:27:09 -0700 (PDT) Received: from hotmail.com (f44.law9.hotmail.com [64.4.9.44]) by mx1.FreeBSD.org (Postfix) with ESMTP id 79EA843E5E for ; Thu, 18 Jul 2002 07:27:09 -0700 (PDT) (envelope-from freebsdfan@hotmail.com) Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Thu, 18 Jul 2002 07:27:09 -0700 Received: from 68.4.57.222 by lw9fd.law9.hotmail.msn.com with HTTP; Thu, 18 Jul 2002 14:27:08 GMT X-Originating-IP: [68.4.57.222] From: "Chuck T." To: net@FreeBSD.ORG Subject: programatically list all local IP addresses ? Date: Thu, 18 Jul 2002 07:27:08 -0700 Mime-Version: 1.0 Content-Type: text/plain; format=flowed Message-ID: X-OriginalArrivalTime: 18 Jul 2002 14:27:09.0281 (UTC) FILETIME=[330D3D10:01C22E67] Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org I'm sure this is a FAQ, but I sure can't find the answer. I've tried the usually suggested gethostname()/gethostbyname() approach, but that only returns the *first* match in /etc/hosts. In one case that was 127.0.0.1. Clearly this was a case where /etc/host.conf gave priority to the host file. I don't want to call gethostent() because (if I understand the man page correctly) that would limit me entries /etc/hosts ignoring DNS. I guess I could do a gethostname()/gethostbyname() and then if I fail to find a usable (non-rfc1918) address gethosten(). Is there a better way? Also is listing 127.0.0.1 as the actual host name in addition to "localhost" in /etc/hosts considered to be proper ? _________________________________________________________________ Send and receive Hotmail on your mobile device: http://mobile.msn.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message