NetBSD/etc/netstart

96 lines
2.8 KiB
Plaintext
Raw Normal View History

1993-03-21 12:45:37 +03:00
#!/bin/sh -
#
# $NetBSD: netstart,v 1.32 1997/04/01 19:36:19 perry 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
# enable, flush and install 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 ... '
ipf -E -Fa -f /etc/ipf.conf
fi
# Configure all of the network interfaces listed in $net_interfaces;
# if $net_interfaces is DEFAULT, grab all interfaces from ifconfig.
# In the following, "xxN" stands in for interface names, like "le0".
# For any interfaces that has an $ifconfig_xxN variable associated,
# we do "ifconfig xxN $ifconfig_xxN".
# If there is no such variable, we take the contents of the file
# /etc/ifconfig.xxN, and run "ifconfig xxN" repeatedly, using each
# line of the file as the arguments for a seperate "ifconfig" invocation.
#
# In order to configure an interface reasonably, you at the very least
# need to specify "[addr_family] [hostname]" (as in "inet my.domain.org"),
# and probably a netmask (as in "netmask 0xffffffe0"). You will
# frequently need to specify a media type, as in "media UTP", for
# interface cards with multiple media connections that do not autoconfigure.
# see the ifconfig manual page for details.
if [ "$net_interfaces" != NO ]; then
if [ "$net_interfaces" = DEFAULT ]; then
tmp="`ifconfig -l`"
else
tmp="$net_interfaces"
fi
echo -n "configuring network interfaces:"
for i in $tmp; do
eval `echo 'args=$ifconfig_'$i`
if [ ! -z "$args" ]; then
echo -n " $i"
ifconfig $i $args
elif [ -f /etc/ifconfig.$i ]; then
echo -n " $i"
(while read args; do
ifconfig $i $args
done) < /etc/ifconfig.$i
elif [ "$net_interfaces" != DEFAULT ]; then
echo
echo -n "/etc/ifconfig.$i missing"
echo -n "& ifconfig_$i not set"
echo "; interface $i can't be configured"
fi
done
echo "."
fi
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