NetBSD/etc/netstart

107 lines
2.9 KiB
Plaintext
Raw Normal View History

1993-03-21 12:45:37 +03:00
#!/bin/sh -
#
1997-03-10 12:34:59 +03:00
# $NetBSD: netstart,v 1.30 1997/03/10 09:42:24 mycroft Exp $
1997-02-15 13:02:07 +03:00
# from: @(#)netstart 8.1 (Berkeley) 7/23/93
1993-03-21 12:45:37 +03:00
# /etc/myname contains my symbolic name
1993-03-21 12:45:37 +03:00
#
hostname=`cat /etc/myname`
1993-03-21 12:45:37 +03:00
hostname $hostname
if [ -f /etc/defaultdomain ]; then
domainname `cat /etc/defaultdomain`
fi
1993-03-21 12:45:37 +03:00
# install and enable packet filter rules before configuring interfaces.
1997-03-10 12:34:59 +03:00
if [ "$ipfilter" != NO ] && [ -f /etc/ipf.conf ]; then
echo 'installing packet filter rules ... '
1997-01-28 09:33:36 +03:00
ipf -f /etc/ipf.conf
fi
# configure all of the interfaces which we know about.
# do this by reading /etc/hostname.* files, where * is the name
# of a given interface.
#
# these files are formatted like the following, but with no # at the
# beginning of the line
#
# addr_family hostname netmask broadcast_addr options
# dest dest_addr
#
# addr_family is the address family of the interface, generally inet
# hostname is the host name that belongs to the interface, in /etc/hosts.
# netmask is the network mask for the interface.
# broadcast_addr is the broadcast address for the interface
# options are misc. options to ifconfig for the interface.
#
# dest is simply the string "dest" (no quotes, though) if the interface
# has a "destination" (i.e. it's a point-to-point link, like SLIP).
# dest_addr is the hostname of the other end of the link, in /etc/hosts
#
# the only required contents of the file are the addr_family field
# and the hostname.
1993-03-21 12:45:37 +03:00
(
tmp="$IFS"
IFS="$IFS."
set -- `echo /etc/hostname*`
IFS=$tmp
unset tmp
while [ $# -ge 2 ] ; do
shift # get rid of "hostname"
(
read af name mask bcaddr extras
read dt dtaddr
if [ ! -n "$name" ]; then
echo "/etc/hostname.$1: invalid network configuration file"
exit
fi
cmd="ifconfig $1 $af $name "
1997-03-10 12:34:59 +03:00
if [ "$dt" = dest ]; then cmd="$cmd $dtaddr"; fi
if [ -n "$mask" ]; then cmd="$cmd netmask $mask"; fi
1997-03-10 12:34:59 +03:00
if [ -n "$bcaddr" ] && [ "$bcaddr" != NONE ]; then
cmd="$cmd broadcast $bcaddr";
fi
cmd="$cmd $extras"
$cmd
) < /etc/hostname.$1
shift
done
)
1993-03-21 12:45:37 +03:00
# set the address for the loopback interface
ifconfig lo0 inet localhost
# use loopback, not the wire
route add $hostname localhost
# /etc/mygate, if it exists, contains the name of my gateway host
# that name must be in /etc/hosts.
if [ -f /etc/mygate ]; then
route add default `cat /etc/mygate`
fi
# /etc/ifaliases, if it exists, contains the names of additional IP
# addresses for each interface. It is formatted as a series of lines
# that contain
# address interface netmask
if [ -f /etc/ifaliases ]; then
(
while read addr int net; do
1997-03-10 12:34:59 +03:00
if [ ! -n "$net" ]; then
ifconfig $int inet alias $addr
else
ifconfig $int inet alias $addr netmask $net
fi
route add $addr localhost
done
) < /etc/ifaliases
fi
if [ -s /etc/netstart.local ]; then
. /etc/netstart.local
fi