From owner-freebsd-hackers Mon Nov 18 20:21:43 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6075C37B401 for ; Mon, 18 Nov 2002 20:21:41 -0800 (PST) Received: from cfcl.com (cpe-24-221-172-174.ca.sprintbbd.net [24.221.172.174]) by mx1.FreeBSD.org (Postfix) with ESMTP id 97D0643E88 for ; Mon, 18 Nov 2002 20:21:40 -0800 (PST) (envelope-from rdm@cfcl.com) Received: from [192.168.254.205] ([192.168.254.205]) by cfcl.com (8.12.6/8.11.1) with ESMTP id gAJ4M8he034180 for ; Mon, 18 Nov 2002 20:22:08 -0800 (PST) (envelope-from rdm@cfcl.com) Mime-Version: 1.0 Message-Id: X-Mailer: Eudora for Macintosh! Date: Mon, 18 Nov 2002 20:20:31 -0800 To: hackers@FreeBSD.ORG From: Rich Morin Subject: Re: auto-definition of a single network interface Content-Type: text/plain; charset="iso-8859-1" ; format="flowed" Content-Transfer-Encoding: quoted-printable Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Ren=E9 Scharfe has developed an alternative way of performing this function. It's a LOT smaller than my version, yet it seems to cover all the bases. To use his version, you put: network_interfaces=3DSINGLE ifconfig_single=3D" inet 192.168.254.193 netmask 255.255.255.0" ifconfig_single_alias0=3D"inet 192.168.254.199 netmask 255.255.255.255" ... into your rc.conf file. No additional script is needed and the changes to rc.network are quite modest (18 lines): 173c173 < # Set up all the network interfaces, calling startup scripts if need= ed --- > # If there's exactly one link, find out interface name automagicall= y. 174a175 > single_link_ifn=3D"" 176,177c177,183 < [Aa][Uu][Tt][Oo]) < network_interfaces=3D"`ifconfig -l`" --- > [Ss][Ii][Nn][Gg][Ll][Ee]) > single_link_ifn=3D"`ifconfig -l link`" > if [ "${single_link_ifn}" !=3D "${single_link_ifn% *}" ]; t= hen > echo -n 'Warning: more than one link found, ' > echo 'falling back to auto configuration.' > single_link_ifn=3D"" > fi 178a185,192 > esac > > # Set up all the network interfaces, calling startup scripts if nee= ded > # > case ${network_interfaces} in > [Aa][Uu][Tt][Oo]|[Ss][Ii][Nn][Gg][Ll][Ee]) > network_interfaces=3D"`ifconfig -l`" > ;; 186,187c200,203 < if [ -r /etc/start_if.${ifn} ]; then < . /etc/start_if.${ifn} --- > [ "$ifn" =3D "$single_link_ifn" ] && ifns=3D"single" || ifn= s=3D$ifn > > if [ -r /etc/start_if.${ifns} ]; then > . /etc/start_if.${ifns} 193c209 < eval ifconfig_args=3D\$ifconfig_${ifn} --- > eval ifconfig_args=3D\$ifconfig_${ifns} 214a231,232 > [ "$ifn" =3D "$single_link_ifn" ] && ifns=3D"single" || ifn= s=3D$ifn > 219c237 < eval ifconfig_args=3D\$ifconfig_${ifn}_alias${alias} --- > eval ifconfig_args=3D\$ifconfig_${ifns}_alias${alia= s} 231c249 < eval ifconfig_args=3D\$ifconfig_${ifn}_ipx --- > eval ifconfig_args=3D\$ifconfig_${ifns}_ipx -- email: rdm@cfcl.com; phone: +1 650-873-7841 http://www.cfcl.com/rdm - my home page, resume, etc. http://www.cfcl.com/Meta - The FreeBSD Browser, Meta Project, etc. http://www.ptf.com/dossier - Prime Time Freeware's DOSSIER series http://www.ptf.com/tdc - Prime Time Freeware's Darwin Collection To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message