From owner-freebsd-bugs Tue Sep 3 8: 0:24 2002 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C7DC737B400 for ; Tue, 3 Sep 2002 08:00:08 -0700 (PDT) Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 927F543E81 for ; Tue, 3 Sep 2002 08:00:07 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.4/8.12.4) with ESMTP id g83F07JU031990 for ; Tue, 3 Sep 2002 08:00:07 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.4/8.12.4/Submit) id g83F07w5031989; Tue, 3 Sep 2002 08:00:07 -0700 (PDT) Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id BA16637B405 for ; Tue, 3 Sep 2002 07:58:14 -0700 (PDT) Received: from home2.amigo.net (billing.amigo.net [209.94.67.250]) by mx1.FreeBSD.org (Postfix) with ESMTP id B535B43E6A for ; Tue, 3 Sep 2002 07:58:13 -0700 (PDT) (envelope-from randy@home2.amigo.net) Received: from home2.amigo.net (localhost [127.0.0.1]) by home2.amigo.net (8.12.3/8.12.3) with ESMTP id g83ExMWX004724 for ; Tue, 3 Sep 2002 08:59:22 -0600 (MDT) (envelope-from randy@home2.amigo.net) Received: (from root@localhost) by home2.amigo.net (8.12.3/8.12.3/Submit) id g83ExMEu004723; Tue, 3 Sep 2002 08:59:22 -0600 (MDT) Message-Id: <200209031459.g83ExMEu004723@home2.amigo.net> Date: Tue, 3 Sep 2002 08:59:22 -0600 (MDT) From: Randy Smith Reply-To: Randy Smith To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: misc/42373: Update to rc scripts to make interface aliases easier for large sites Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 42373 >Category: misc >Synopsis: Update to rc scripts to make interface aliases easier for large sites >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Tue Sep 03 08:00:06 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Randy Smith >Release: FreeBSD 4.6.2-RELEASE i386 >Organization: Amigo.Net >Environment: System: FreeBSD home2.amigo.net 4.6.2-RELEASE FreeBSD 4.6.2-RELEASE #2: Mon Aug 19 15:47:37 MDT 2002 root@builder.amigo.net:/usr/obj/usr/src/sys/STANDARD i386 >Description: Currently, FreeBSD supports adding aliases to an interface at boot time through rc.network. rc.network reads the aliases from variables named ifconfig__alias where is the interface name and is an integer starting at 0. Multiple aliases are possible be incrementing N for each alias. Example: ifconfig_fxp0_alias0="inet 192.168.1.1 netmask 0xffffffff" ifconfig_fxp0_alias1="inet 192.168.1.2 netmask 0xffffffff" ... The problem is in how rc.network processes these variables. It simply counts up from 0 and when it gets to a variable that doesn't exist, it stops. This makes it difficult to temporarily remove an alias from the start up because simply commenting out the variable disables all of the aliases on that interface that follow. This can be worked around by renumbering the aliases but that can be impracticle. >How-To-Repeat: >Fix: I propose a new script called rc.alias that is run from rc.network reads a config file for each interface which contains the alias information. This will require two additional variable in rc.conf: alias_prefix and alias_interfaces. The alias config files are named $alias_prefix.. alias_interfaces contains a list of interfaces to configure or 'auto' which causes the script to look for config files and create the aliases automatically. 'auto' should be the default. Example: Variables in /etc/rc.conf alias_prefix="/etc/ip_aliases" # Alias files are $alias_prefix.interface alias_interfaces="auto" # Interfaces to look for aliases on or 'auto' #alias_interfaces="ed1 lp0" # Interfaces to look for aliases on or 'auto' Each line in the config files contains the alias information as it would be passed to ifconfig. Note that the tag 'alias' is not included in the command. Blank lines and lines starting with # are skipped. The following example creates aliases for 192.168.1.1, .2, .4, and .5. Example: Alias config file inet 192.168.1.1 netmask 255.255.255.255 # The line below is skipped inet 192.168.1.2 netmask 255.255.255.255 #inet 192.168.1.3 netmask 255.255.255.255 inet 192.168.1.4 netmask 255.255.255.255 inet 192.168.1.5 netmask 255.255.255.255 # Other stuff rc.alias is included below. As stated above, it should be run from rc.network either before or after the existing system. (On my system, aliasing starts at line 214.) As far as I can tell, it should not make a difference. rc.alias can be added to STABLE without problems as both systems can be used concurrently. Using both systems concurrently , however, can cause confusion and should be discouraged. #!/bin/sh # Copyright (c) 2002 Randy Smith # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # Suck in config if [ -r /etc/defaults/rc.conf ]; then . /etc/defaults/rc.conf source_rc_confs fi case ${alias_interfaces} in [Aa][Uu][Tt][Oo]) # Find alias files if [ X != X$alias_prefix ] then ifaces=`ls /etc/ip_aliases.* | awk -F. -- '/\.([:alnum:]*)/ { print $2 }'` fi ;; *) ifaces=$alias_interfaces ;; esac for iface in $ifaces do ip_aliases="/etc/ip_aliases.$iface" if [ -r $ip_aliases ] then while read alias do case $alias in \#*|'') ;; *) ifconfig ${iface} ${alias} alias ;; esac done < $ip_aliases else echo "Can't find ${ip_aliases}" fi done >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message