Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 18 Nov 2002 20:20:31 -0800
From:      Rich Morin <rdm@cfcl.com>
To:        hackers@FreeBSD.ORG
Subject:   Re: auto-definition of a single network interface
Message-ID:  <p05200f20b9fd8c66ad17@[192.168.254.205]>

next in thread | raw e-mail | index | archive | help
Ren=E9 Scharfe <l.s.r@web.de> 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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?p05200f20b9fd8c66ad17>