1993-03-21 12:45:37 +03:00
|
|
|
#!/bin/sh -
|
|
|
|
#
|
2000-02-13 10:47:26 +03:00
|
|
|
# $NetBSD: netstart,v 1.74 2000/02/13 07:47:26 itojun 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
|
|
|
|
1997-08-29 14:09:38 +04:00
|
|
|
if [ -f /etc/rc.subr ]; then
|
|
|
|
. /etc/rc.subr
|
1997-08-29 06:24:04 +04:00
|
|
|
else
|
1997-08-29 14:09:38 +04:00
|
|
|
echo "Can't read /etc/rc.subr; aborting."
|
1997-08-29 06:24:04 +04:00
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
|
1997-04-29 08:55:05 +04:00
|
|
|
if [ -f /etc/rc.conf ]; then
|
|
|
|
. /etc/rc.conf
|
|
|
|
fi
|
|
|
|
|
1998-05-11 22:59:23 +04:00
|
|
|
# If $hostname is set, use it for my Internet name, otherwise use /etc/myname
|
1997-08-28 22:18:17 +04:00
|
|
|
if [ -z "$hostname" -a -f /etc/myname ]; then
|
1997-05-12 15:26:10 +04:00
|
|
|
hostname=`cat /etc/myname`
|
|
|
|
fi
|
1997-08-28 22:18:17 +04:00
|
|
|
if [ -n "$hostname" ]; then
|
|
|
|
echo "hostname: $hostname"
|
|
|
|
hostname $hostname
|
|
|
|
fi
|
1997-05-12 15:26:10 +04:00
|
|
|
|
1998-05-11 22:59:23 +04:00
|
|
|
# Check $domainname first, then /etc/defaultdomain, for NIS/YP domain name
|
1997-05-12 15:26:10 +04:00
|
|
|
if [ -z "$domainname" -a -f /etc/defaultdomain ]; then
|
|
|
|
domainname=`cat /etc/defaultdomain`
|
|
|
|
fi
|
|
|
|
if [ -n "$domainname" ]; then
|
|
|
|
echo "domainname: $domainname"
|
|
|
|
domainname $domainname
|
1993-04-02 17:11:42 +04:00
|
|
|
fi
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1997-07-22 22:41:08 +04:00
|
|
|
# Flush all routes just to make sure it is clean
|
1998-01-26 15:02:43 +03:00
|
|
|
if checkyesno flushroutes; then
|
2000-01-26 10:01:53 +03:00
|
|
|
route -n flush
|
1997-07-22 22:41:08 +04:00
|
|
|
fi
|
|
|
|
|
1997-05-13 03:40:50 +04:00
|
|
|
# Enable, flush and install packet filter rules before configuring interfaces.
|
1997-08-29 06:24:04 +04:00
|
|
|
if checkyesno ipfilter; then
|
|
|
|
if [ -f /etc/ipf.conf ]; then
|
|
|
|
echo 'installing packet filter rules ... '
|
|
|
|
ipf -E -Fa -f /etc/ipf.conf
|
|
|
|
else
|
1998-11-25 06:54:27 +03:00
|
|
|
echo
|
|
|
|
echo "WARNING: /etc/ipf.conf not readable " \
|
1997-08-29 06:24:04 +04:00
|
|
|
"ipfilter not started."
|
|
|
|
# abort the boot rather than risk a security problem
|
|
|
|
exit 1;
|
|
|
|
fi
|
1997-01-05 15:01:54 +03:00
|
|
|
fi
|
|
|
|
|
1997-08-04 10:09:49 +04:00
|
|
|
# Set the address for the first loopback interface, so that the auto-route
|
|
|
|
# from a newly configured interface's address to lo0 works correctly.
|
1997-09-26 11:44:07 +04:00
|
|
|
#
|
|
|
|
# NOTE: obscure networking problems may occur if lo0 isn't configured...
|
|
|
|
#
|
1997-09-07 13:47:31 +04:00
|
|
|
ifconfig lo0 inet 127.0.0.1
|
1997-08-04 10:09:49 +04:00
|
|
|
|
1997-04-01 23:36:17 +04:00
|
|
|
# Configure all of the network interfaces listed in $net_interfaces;
|
1997-09-08 06:43:26 +04:00
|
|
|
# if $auto_ifconfig is YES, grab all interfaces from ifconfig.
|
1997-04-01 23:36:17 +04:00
|
|
|
# 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.
|
1993-04-02 11:59:12 +04:00
|
|
|
#
|
1997-04-01 23:36:17 +04:00
|
|
|
# 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.
|
2000-02-11 11:09:56 +03:00
|
|
|
#
|
|
|
|
# Note that /etc/ifconfig.xxN takes multiple lines. The following
|
|
|
|
# configuration is possible:
|
|
|
|
# inet 10.1.1.1 netmask 0xffffff00
|
|
|
|
# inet 10.1.1.2 netmask 0xffffff00 alias
|
|
|
|
# inet6 fec0::1 prefixlen 64 alias
|
|
|
|
#
|
1997-04-01 23:36:17 +04:00
|
|
|
if [ "$net_interfaces" != NO ]; then
|
1997-08-29 06:24:04 +04:00
|
|
|
if checkyesno auto_ifconfig; then
|
1997-04-01 23:36:17 +04:00
|
|
|
tmp="`ifconfig -l`"
|
|
|
|
else
|
|
|
|
tmp="$net_interfaces"
|
|
|
|
fi
|
1997-05-12 15:26:10 +04:00
|
|
|
echo -n 'configuring network interfaces:'
|
|
|
|
for int in $tmp; do
|
|
|
|
eval `echo 'args=$ifconfig_'$int`
|
|
|
|
if [ -n "$args" ]; then
|
|
|
|
echo -n " $int"
|
|
|
|
ifconfig $int $args
|
|
|
|
elif [ -f /etc/ifconfig.$int ]; then
|
|
|
|
echo -n " $int"
|
1997-04-01 23:36:17 +04:00
|
|
|
(while read args; do
|
1999-11-08 12:29:24 +03:00
|
|
|
if [ -n "`eval echo '$args'`" ] ; then
|
|
|
|
ifconfig $int $args
|
|
|
|
fi
|
1997-05-12 15:26:10 +04:00
|
|
|
done) < /etc/ifconfig.$int
|
1997-05-17 18:12:24 +04:00
|
|
|
else
|
1998-01-26 15:02:43 +03:00
|
|
|
if ! checkyesno auto_ifconfig; then
|
1997-05-17 18:12:24 +04:00
|
|
|
echo
|
1997-08-29 06:24:04 +04:00
|
|
|
echo "WARNING: /etc/ifconfig.$int missing " \
|
|
|
|
"and ifconfig_$int not set; " \
|
|
|
|
"interface $int not configured."
|
1997-05-17 18:12:24 +04:00
|
|
|
fi
|
1997-05-12 15:26:10 +04:00
|
|
|
continue
|
|
|
|
fi
|
1997-05-23 01:41:09 +04:00
|
|
|
configured_interfaces="$configured_interfaces $int"
|
1997-04-01 23:36:17 +04:00
|
|
|
done
|
1997-05-12 15:26:10 +04:00
|
|
|
echo '.'
|
1997-04-01 23:36:17 +04:00
|
|
|
fi
|
1993-04-02 11:59:12 +04:00
|
|
|
|
1997-05-12 15:26:10 +04:00
|
|
|
# Check $defaultroute, then /etc/mygate, for the name of my gateway host.
|
|
|
|
# That name must be in /etc/hosts.
|
|
|
|
if [ -z "$defaultroute" -a -f /etc/mygate ]; then
|
|
|
|
defaultroute=`cat /etc/mygate`
|
|
|
|
fi
|
|
|
|
if [ -n "$defaultroute" ]; then
|
|
|
|
route add default $defaultroute
|
1993-04-02 11:59:12 +04:00
|
|
|
fi
|
1995-12-17 21:31:09 +03:00
|
|
|
|
1997-05-12 15:26:10 +04:00
|
|
|
# Check if each configured interface xxN has an $ifaliases_xxN variable
|
|
|
|
# associated, then configure additional IP addresses for that interface.
|
|
|
|
# The variable contains a list of "address netmask" pairs, with "netmask"
|
|
|
|
# set to "-" if the interface default netmask is to be used.
|
1999-11-29 04:40:33 +03:00
|
|
|
#
|
2000-02-11 11:09:56 +03:00
|
|
|
# Note that $ifaliases_xxN works only with certain configurations and
|
|
|
|
# considered not recommended. Use /etc/ifconfig.xxN if possible.
|
1997-05-12 15:26:10 +04:00
|
|
|
#
|
|
|
|
if [ -n "$configured_interfaces" ]; then
|
|
|
|
echo 'adding interface aliases:';
|
1997-11-17 20:45:28 +03:00
|
|
|
done_aliases_message=yes
|
1997-05-12 15:26:10 +04:00
|
|
|
fi
|
|
|
|
for int in $configured_interfaces; do
|
|
|
|
eval `echo 'args=$ifaliases_'$int`
|
|
|
|
if [ -n "$args" ]; then
|
|
|
|
set -- $args
|
|
|
|
while [ $# -ge 2 ]; do
|
|
|
|
addr=$1 ; net=$2 ; shift 2
|
|
|
|
if [ "$net" = "-" ]; then
|
|
|
|
ifconfig $int inet alias $addr
|
|
|
|
else
|
|
|
|
ifconfig $int inet alias $addr netmask $net
|
|
|
|
fi
|
1997-05-13 03:40:50 +04:00
|
|
|
# Use loopback, not the wire
|
1997-09-07 13:47:31 +04:00
|
|
|
route add $addr 127.0.0.1
|
1997-05-12 15:26:10 +04:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
1995-12-17 21:31:09 +03:00
|
|
|
# /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
|
1997-01-05 15:01:54 +03:00
|
|
|
# address interface netmask
|
1999-11-29 04:40:33 +03:00
|
|
|
#
|
2000-02-11 11:09:56 +03:00
|
|
|
# Note that /etc/ifaliases works only with certain cases only and considered
|
|
|
|
# not recommended. Use /etc/ifconfig.xxN instead.
|
1999-11-29 04:40:33 +03:00
|
|
|
#
|
1995-12-17 21:31:09 +03:00
|
|
|
if [ -f /etc/ifaliases ]; then
|
|
|
|
(
|
1997-11-17 20:45:28 +03:00
|
|
|
if [ "$done_aliases_message" != yes ]; then
|
|
|
|
echo 'adding interface aliases:';
|
|
|
|
fi
|
1997-01-05 15:01:54 +03:00
|
|
|
while read addr int net; do
|
1997-05-12 15:26:10 +04:00
|
|
|
if [ -z "$net" ]; then
|
1997-01-05 15:01:54 +03:00
|
|
|
ifconfig $int inet alias $addr
|
|
|
|
else
|
|
|
|
ifconfig $int inet alias $addr netmask $net
|
|
|
|
fi
|
1997-05-12 15:26:10 +04:00
|
|
|
# use loopback, not the wire
|
1997-09-07 13:47:31 +04:00
|
|
|
route add $addr 127.0.0.1
|
1997-01-05 15:01:54 +03:00
|
|
|
done
|
|
|
|
) < /etc/ifaliases
|
|
|
|
fi
|
1995-12-17 21:31:09 +03:00
|
|
|
|
1997-11-17 20:45:28 +03:00
|
|
|
# /etc/ppp/peers and $ppp_peers contain boot configuration information
|
|
|
|
# for pppd. each value in $ppp_peers that has a file in /etc/ppp/peers
|
|
|
|
# of the same name, will be run as `pppd <peer>'.
|
|
|
|
if [ -n "$ppp_peers" ]; then
|
1999-03-03 02:10:17 +03:00
|
|
|
# pppd is in /usr - need to ensure it is mounted
|
|
|
|
mount /usr >/dev/null 2>&1
|
1997-11-17 20:45:28 +03:00
|
|
|
set -- $ppp_peers
|
|
|
|
echo -n "starting pppd:"
|
|
|
|
while [ $# -ge 1 ]; do
|
|
|
|
peer=$1; shift
|
|
|
|
if [ -f /etc/ppp/peers/$peer ]; then
|
|
|
|
pppd call $peer
|
|
|
|
echo -n " $peer"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
echo "."
|
|
|
|
fi
|
|
|
|
|
1999-03-24 22:03:10 +03:00
|
|
|
if checkyesno dhclient; then
|
1999-05-29 01:01:42 +04:00
|
|
|
echo -n "starting dhcp client...";
|
|
|
|
dhclient $dhclient_flags
|
1999-03-24 22:03:10 +03:00
|
|
|
fi
|
|
|
|
|
1999-07-03 07:29:29 +04:00
|
|
|
# IPv6
|
|
|
|
# Note that manual configuration can be done in the above, using ifconfig.
|
1999-12-20 18:51:14 +03:00
|
|
|
if ifconfig lo0 inet6 >/dev/null 2>&1; then
|
1999-12-20 18:12:23 +03:00
|
|
|
# We have IPv6 support in kernel.
|
|
|
|
|
1999-12-09 17:18:07 +03:00
|
|
|
# disallow scoped unicast dest without outgoing scope identifiers.
|
|
|
|
route add -inet6 fe80:: -prefixlen 10 ::1 -reject
|
|
|
|
route add -inet6 fc80:: -prefixlen 10 ::1 -reject
|
|
|
|
|
|
|
|
# disallow "internal" addresses to appear on the wire.
|
|
|
|
route add -inet6 ::ffff:0.0.0.0 -prefixlen 96 ::1 -reject
|
|
|
|
route add -inet6 ::0.0.0.0 -prefixlen 96 ::1 -reject
|
|
|
|
|
2000-02-05 20:02:42 +03:00
|
|
|
sysctl -w net.inet6.ip6.forwarding=0 >/dev/null
|
|
|
|
sysctl -w net.inet6.ip6.accept_rtadv=0 >/dev/null
|
|
|
|
|
|
|
|
# backward compatibility
|
|
|
|
if test "x$ip6mode" = "x" -a "x$ip6forwarding" != "x"; then
|
|
|
|
echo 'WARNING: please migrate to newer rc.conf' \
|
|
|
|
'(use ip6mode, not ip6forwarding)'
|
|
|
|
if checkyesno ip6forwarding; then
|
|
|
|
ip6mode=router
|
1999-07-03 07:29:29 +04:00
|
|
|
else
|
2000-02-05 20:02:42 +03:00
|
|
|
if checkyesno rtsol; then
|
|
|
|
ip6mode=autohost
|
|
|
|
else
|
|
|
|
ip6mode=host
|
|
|
|
fi
|
1999-07-03 07:29:29 +04:00
|
|
|
fi
|
2000-02-05 20:02:42 +03:00
|
|
|
fi
|
|
|
|
|
|
|
|
case $ip6mode in
|
|
|
|
router) echo 'IPv6 mode: router'
|
|
|
|
sysctl -w net.inet6.ip6.forwarding=1 >/dev/null
|
|
|
|
;;
|
|
|
|
autohost)
|
|
|
|
echo 'IPv6 mode: autoconfigured host'
|
|
|
|
sysctl -w net.inet6.ip6.accept_rtadv=1 >/dev/null
|
2000-02-13 10:47:26 +03:00
|
|
|
if test "x$ip6defaultif" != "x"; then
|
|
|
|
ndp -I $ip6defaultif
|
|
|
|
fi
|
2000-02-05 20:02:42 +03:00
|
|
|
;;
|
|
|
|
host) echo 'IPv6 mode: host'
|
2000-02-13 10:47:26 +03:00
|
|
|
if test "x$ip6defaultif" != "x"; then
|
|
|
|
ndp -I $ip6defaultif
|
|
|
|
fi
|
2000-02-05 20:02:42 +03:00
|
|
|
;;
|
|
|
|
*) echo 'WARNING: invalid value in ip6mode'
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
if checkyesno rtsol; then
|
|
|
|
if test "x$ip6mode" = "xautohost"; then
|
|
|
|
echo 'Sending router solicitation...'
|
1999-07-03 07:29:29 +04:00
|
|
|
rtsol $rtsol_flags
|
2000-02-05 20:02:42 +03:00
|
|
|
else
|
|
|
|
echo
|
|
|
|
logger -s "WARNING: ip6mode must be set to autohost" \
|
|
|
|
"to use rtsol."
|
1999-07-03 07:29:29 +04:00
|
|
|
fi
|
|
|
|
fi
|
1999-12-20 18:12:23 +03:00
|
|
|
|
1999-07-03 07:29:29 +04:00
|
|
|
# wait till DAD is completed.
|
1999-12-20 18:12:23 +03:00
|
|
|
# always invoke it in case if are configured manually by ifconfig
|
|
|
|
dadcount=`sysctl -n net.inet6.ip6.dad_count 2>/dev/null`
|
1999-07-03 07:29:29 +04:00
|
|
|
sleep $dadcount
|
|
|
|
sleep 1
|
|
|
|
fi
|
|
|
|
|
1997-01-05 15:01:54 +03:00
|
|
|
if [ -s /etc/netstart.local ]; then
|
|
|
|
. /etc/netstart.local
|
1995-12-17 21:31:09 +03:00
|
|
|
fi
|