#!/bin/sh - # # $NetBSD: netstart,v 1.33 1997/04/29 04:55:05 scottr Exp $ # from: @(#)netstart 8.1 (Berkeley) 7/23/93 if [ -f /etc/rc.conf ]; then . /etc/rc.conf fi # /etc/myname contains my symbolic name # hostname=`cat /etc/myname` hostname $hostname if [ -f /etc/defaultdomain ]; then domainname `cat /etc/defaultdomain` fi # enable, flush and install packet filter rules before configuring interfaces. 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 # 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 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