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é 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=SINGLE
ifconfig_single=" inet 192.168.254.193 netmask 255.255.255.0"
ifconfig_single_alias0="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 needed
---
> # If there's exactly one link, find out interface name automagically.
174a175
> single_link_ifn=""
176,177c177,183
< [Aa][Uu][Tt][Oo])
< network_interfaces="`ifconfig -l`"
---
> [Ss][Ii][Nn][Gg][Ll][Ee])
> single_link_ifn="`ifconfig -l link`"
> if [ "${single_link_ifn}" != "${single_link_ifn% *}" ]; then
> echo -n 'Warning: more than one link found, '
> echo 'falling back to auto configuration.'
> single_link_ifn=""
> fi
178a185,192
> esac
>
> # Set up all the network interfaces, calling startup scripts if needed
> #
> case ${network_interfaces} in
> [Aa][Uu][Tt][Oo]|[Ss][Ii][Nn][Gg][Ll][Ee])
> network_interfaces="`ifconfig -l`"
> ;;
186,187c200,203
< if [ -r /etc/start_if.${ifn} ]; then
< . /etc/start_if.${ifn}
---
> [ "$ifn" = "$single_link_ifn" ] && ifns="single" || ifns=$ifn
>
> if [ -r /etc/start_if.${ifns} ]; then
> . /etc/start_if.${ifns}
193c209
< eval ifconfig_args=\$ifconfig_${ifn}
---
> eval ifconfig_args=\$ifconfig_${ifns}
214a231,232
> [ "$ifn" = "$single_link_ifn" ] && ifns="single" || ifns=$ifn
>
219c237
< eval ifconfig_args=\$ifconfig_${ifn}_alias${alias}
---
> eval ifconfig_args=\$ifconfig_${ifns}_alias${alias}
231c249
< eval ifconfig_args=\$ifconfig_${ifn}_ipx
---
> eval ifconfig_args=\$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>
