xref: /titanic_54/usr/src/cmd/svc/milestone/net-init (revision a59fa5080460d7eeec3f3ec829d3e29c83c86f2f)
17c478bd9Sstevel@tonic-gate#!/sbin/sh
27c478bd9Sstevel@tonic-gate#
37c478bd9Sstevel@tonic-gate# CDDL HEADER START
47c478bd9Sstevel@tonic-gate#
57c478bd9Sstevel@tonic-gate# The contents of this file are subject to the terms of the
67c478bd9Sstevel@tonic-gate# Common Development and Distribution License, Version 1.0 only
77c478bd9Sstevel@tonic-gate# (the "License").  You may not use this file except in compliance
87c478bd9Sstevel@tonic-gate# with the License.
97c478bd9Sstevel@tonic-gate#
107c478bd9Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
117c478bd9Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing.
127c478bd9Sstevel@tonic-gate# See the License for the specific language governing permissions
137c478bd9Sstevel@tonic-gate# and limitations under the License.
147c478bd9Sstevel@tonic-gate#
157c478bd9Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each
167c478bd9Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
177c478bd9Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the
187c478bd9Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying
197c478bd9Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner]
207c478bd9Sstevel@tonic-gate#
217c478bd9Sstevel@tonic-gate# CDDL HEADER END
227c478bd9Sstevel@tonic-gate#
237c478bd9Sstevel@tonic-gate#
24*a59fa508Sjl138328# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
257c478bd9Sstevel@tonic-gate# Use is subject to license terms.
267c478bd9Sstevel@tonic-gate#
277c478bd9Sstevel@tonic-gate# ident	"%Z%%M%	%I%	%E% SMI"
287c478bd9Sstevel@tonic-gate#
297c478bd9Sstevel@tonic-gate# This is the second phase of TCP/IP configuration.  The first part is
307c478bd9Sstevel@tonic-gate# run by the /lib/svc/method/net-physical script (the svc:/network/physical
317c478bd9Sstevel@tonic-gate# service) and includes configuring the interfaces and setting the machine's
327c478bd9Sstevel@tonic-gate# hostname.  This script (the svc:/network/initial service), does all
337c478bd9Sstevel@tonic-gate# configuration that can be done before name services are started. This
347c478bd9Sstevel@tonic-gate# includes configuring IP routing, and setting any tunable parameters.
357c478bd9Sstevel@tonic-gate# The third part, run by the /lib/svc/method/net-svc script (the
367c478bd9Sstevel@tonic-gate# svc:/network/service service), does all configuration that may require
377c478bd9Sstevel@tonic-gate# name services.  This includes a final re-configuration of the interfaces.
387c478bd9Sstevel@tonic-gate#
397c478bd9Sstevel@tonic-gate
407c478bd9Sstevel@tonic-gate. /lib/svc/share/smf_include.sh
417c478bd9Sstevel@tonic-gate
427c478bd9Sstevel@tonic-gatecase "$1" in
437c478bd9Sstevel@tonic-gate'start')
447c478bd9Sstevel@tonic-gate	#
457c478bd9Sstevel@tonic-gate	# In a zone we need this service to be up, but all of the work
467c478bd9Sstevel@tonic-gate	# it tries to do is irrelevant (and will actually lead to the service
477c478bd9Sstevel@tonic-gate	# failing if we try to do it), so just bail out.
487c478bd9Sstevel@tonic-gate	#
497c478bd9Sstevel@tonic-gate	if [ `/sbin/zonename` != "global" ]; then
507c478bd9Sstevel@tonic-gate		exit 0
517c478bd9Sstevel@tonic-gate	fi
527c478bd9Sstevel@tonic-gate	;; # Fall through -- rest of script is the initialization code
537c478bd9Sstevel@tonic-gate
547c478bd9Sstevel@tonic-gate'stop')
557c478bd9Sstevel@tonic-gate	if [ `/sbin/zonename` != "global" ]; then
567c478bd9Sstevel@tonic-gate		exit 0
577c478bd9Sstevel@tonic-gate	fi
587c478bd9Sstevel@tonic-gate	#
597c478bd9Sstevel@tonic-gate	# If we were routing dynamically, we will note this with
607c478bd9Sstevel@tonic-gate	# the .dynamic_routing file, so that we can leave the routes
617c478bd9Sstevel@tonic-gate	# in place without thinking they're static route entries
627c478bd9Sstevel@tonic-gate	# when we come back into states 2 or 3.
637c478bd9Sstevel@tonic-gate	#
647c478bd9Sstevel@tonic-gate	if /usr/bin/pgrep -x -u 0 'in.routed|in.rdisc' >/dev/null 2>&1; then
657c478bd9Sstevel@tonic-gate		/usr/bin/pkill -z `/sbin/zonename` -x -u 0 'in.routed|in.rdisc'
667c478bd9Sstevel@tonic-gate		> /etc/.dynamic_routing
677c478bd9Sstevel@tonic-gate	fi
687c478bd9Sstevel@tonic-gate	/usr/bin/pkill -z `/sbin/zonename` -x -u 0 'in.ndpd|in.ripngd'
697c478bd9Sstevel@tonic-gate	exit 0
707c478bd9Sstevel@tonic-gate	;;
717c478bd9Sstevel@tonic-gate
727c478bd9Sstevel@tonic-gate*)
737c478bd9Sstevel@tonic-gate	echo "Usage: $0 { start | stop }"
747c478bd9Sstevel@tonic-gate	exit 1
757c478bd9Sstevel@tonic-gate	;;
767c478bd9Sstevel@tonic-gateesac
777c478bd9Sstevel@tonic-gate
787c478bd9Sstevel@tonic-gate# Configure IPv6 Default Address Selection.
797c478bd9Sstevel@tonic-gateif [ -f /etc/inet/ipaddrsel.conf ]; then
807c478bd9Sstevel@tonic-gate	/usr/sbin/ipaddrsel -f /etc/inet/ipaddrsel.conf
817c478bd9Sstevel@tonic-gatefi
827c478bd9Sstevel@tonic-gate
837c478bd9Sstevel@tonic-gate/usr/sbin/ifconfig -a6u >/etc/svc/volatile/ifconfig.$$
847c478bd9Sstevel@tonic-gatenumv6ifs=`/usr/bin/grep -c inet6 /etc/svc/volatile/ifconfig.$$`
857c478bd9Sstevel@tonic-gateif  [ $numv6ifs -gt 1 ]; then
867c478bd9Sstevel@tonic-gate	#
877c478bd9Sstevel@tonic-gate	# Add a static route for multicast packets out of a link-local
887c478bd9Sstevel@tonic-gate	# interface, although would like to specify multicast interface using
897c478bd9Sstevel@tonic-gate	# an interface name!
907c478bd9Sstevel@tonic-gate	#
917c478bd9Sstevel@tonic-gate	set -- `/usr/bin/awk '
927c478bd9Sstevel@tonic-gate		/inet6 fe80:/ {
937c478bd9Sstevel@tonic-gate			print substr($2, 1, index($2, "/") - 1)
947c478bd9Sstevel@tonic-gate		}' /etc/svc/volatile/ifconfig.$$`
957c478bd9Sstevel@tonic-gate
967c478bd9Sstevel@tonic-gate	if [ -n "$1" ]; then
977c478bd9Sstevel@tonic-gate		echo "Setting default IPv6 interface for multicast:" \
987c478bd9Sstevel@tonic-gate		    "add net ff00::/8: gateway $1"
997c478bd9Sstevel@tonic-gate		/usr/sbin/route -n add -interface -inet6 "ff00::/8" "$1" \
1007c478bd9Sstevel@tonic-gate		    >/dev/null
1017c478bd9Sstevel@tonic-gate	fi
1027c478bd9Sstevel@tonic-gatefi
1037c478bd9Sstevel@tonic-gate/usr/bin/rm -f /etc/svc/volatile/ifconfig.$$
1047c478bd9Sstevel@tonic-gate
1057c478bd9Sstevel@tonic-gate#
1067c478bd9Sstevel@tonic-gate# Now that /usr is mounted, see if in.mpathd needs to be started by firing it
1077c478bd9Sstevel@tonic-gate# up in "adopt" mode; if there are no interfaces it needs to manage, it will
1087c478bd9Sstevel@tonic-gate# automatically exit.  Note that it may already be running if we're not
1097c478bd9Sstevel@tonic-gate# executing as part of system boot.
1107c478bd9Sstevel@tonic-gate#
1117c478bd9Sstevel@tonic-gate/usr/bin/pgrep -x -u 0 in.mpathd >/dev/null 2>&1 || /usr/lib/inet/in.mpathd -a
1127c478bd9Sstevel@tonic-gate
1137c478bd9Sstevel@tonic-gate#
1147c478bd9Sstevel@tonic-gate# Pass to the kernel the list of supported IPsec protocols and algorithms.
1157c478bd9Sstevel@tonic-gate# This will not cause IPsec to be loaded.
1167c478bd9Sstevel@tonic-gate#
1177c478bd9Sstevel@tonic-gate/usr/sbin/ipsecalgs -s
1187c478bd9Sstevel@tonic-gate
1197c478bd9Sstevel@tonic-gate#
1207c478bd9Sstevel@tonic-gate# Initialize IPsec only if ipsecinit.conf exists.  Otherwise, save the
1217c478bd9Sstevel@tonic-gate# kernel memory that'll be consumed if IPsec is loaded.  See below for more
1227c478bd9Sstevel@tonic-gate# IPsec-related commands.
1237c478bd9Sstevel@tonic-gate#
1247c478bd9Sstevel@tonic-gateif [ -f /etc/inet/ipsecinit.conf ] ; then
1257c478bd9Sstevel@tonic-gate	/usr/sbin/ipsecconf -qa /etc/inet/ipsecinit.conf
1267c478bd9Sstevel@tonic-gatefi
1277c478bd9Sstevel@tonic-gate
1287c478bd9Sstevel@tonic-gate#
1297c478bd9Sstevel@tonic-gate# Set the RFC 1948 entropy, regardless of if I'm using it or not.  If present,
1307c478bd9Sstevel@tonic-gate# use the encrypted root password as a source of entropy.  Otherwise,
1317c478bd9Sstevel@tonic-gate# just use the pre-set (and hopefully difficult to guess) entropy that
1327c478bd9Sstevel@tonic-gate# tcp used when it loaded.
1337c478bd9Sstevel@tonic-gate#
1347c478bd9Sstevel@tonic-gateencr=`/usr/bin/awk -F: '/^root:/ {print $2}' /etc/shadow`
1357c478bd9Sstevel@tonic-gate[ -z "$encr" ] || /usr/sbin/ndd -set /dev/tcp tcp_1948_phrase $encr
1367c478bd9Sstevel@tonic-gateunset encr
1377c478bd9Sstevel@tonic-gate
1387c478bd9Sstevel@tonic-gate#
1397c478bd9Sstevel@tonic-gate# Get values for TCP_STRONG_ISS, ACCEPT6TO4RELAY and RELAY6TO4ADDR.
1407c478bd9Sstevel@tonic-gate#
1417c478bd9Sstevel@tonic-gate[ -f /etc/default/inetinit ] && . /etc/default/inetinit
1427c478bd9Sstevel@tonic-gate
1437c478bd9Sstevel@tonic-gate#
1447c478bd9Sstevel@tonic-gate# Set TCP ISS generation.  By default the ISS generation is
1457c478bd9Sstevel@tonic-gate# time + random()-delta.  This might not be strong enough for some users.
1467c478bd9Sstevel@tonic-gate# See /etc/default/inetinit for settings and further info on TCP_STRONG_ISS.
1477c478bd9Sstevel@tonic-gate# If not set, use TCP's internal default setting.
1487c478bd9Sstevel@tonic-gate#
1497c478bd9Sstevel@tonic-gateif [ $TCP_STRONG_ISS ]; then
1507c478bd9Sstevel@tonic-gate	/usr/sbin/ndd -set /dev/tcp tcp_strong_iss $TCP_STRONG_ISS
1517c478bd9Sstevel@tonic-gatefi
1527c478bd9Sstevel@tonic-gate
1537c478bd9Sstevel@tonic-gate#
1547c478bd9Sstevel@tonic-gate# Configure default IPv4 routers using the local "/etc/defaultrouter"
1557c478bd9Sstevel@tonic-gate# configuration file.  The file can contain the hostnames or IP
1567c478bd9Sstevel@tonic-gate# addresses of one or more default routers.  If hostnames are used,
1577c478bd9Sstevel@tonic-gate# each hostname must also be listed in the local "/etc/hosts" file
1587c478bd9Sstevel@tonic-gate# because NIS and NIS+ are not running at the time that this script is
1597c478bd9Sstevel@tonic-gate# run.  Each router name or address is listed on a single line by
1607c478bd9Sstevel@tonic-gate# itself in the file.  Anything else on that line after the router's
1617c478bd9Sstevel@tonic-gate# name or address is ignored.  Lines that begin with "#" are
1627c478bd9Sstevel@tonic-gate# considered comments and ignored.
1637c478bd9Sstevel@tonic-gate#
1647c478bd9Sstevel@tonic-gate# The default routes listed in the "/etc/defaultrouter" file will
1657c478bd9Sstevel@tonic-gate# replace those added by the kernel during diskless booting.  An
1667c478bd9Sstevel@tonic-gate# empty "/etc/defaultrouter" file will cause the default route
1677c478bd9Sstevel@tonic-gate# added by the kernel to be deleted.
1687c478bd9Sstevel@tonic-gate#
1697c478bd9Sstevel@tonic-gate# Note that the default router file is ignored if we received routes
1707c478bd9Sstevel@tonic-gate# from a DHCP server.  Our policy is to always trust DHCP over local
1717c478bd9Sstevel@tonic-gate# administration.
1727c478bd9Sstevel@tonic-gate#
1737c478bd9Sstevel@tonic-gatesmf_netstrategy
1747c478bd9Sstevel@tonic-gate
1757c478bd9Sstevel@tonic-gateif [ "$_INIT_NET_STRATEGY" = "dhcp" ] && [ -n "`/sbin/dhcpinfo Router`" ]; then
1767c478bd9Sstevel@tonic-gate	defrouters=`/sbin/dhcpinfo Router`
1777c478bd9Sstevel@tonic-gateelif [ -f /etc/defaultrouter ]; then
1787c478bd9Sstevel@tonic-gate	defrouters=`/usr/bin/grep -v \^\# /etc/defaultrouter | \
1797c478bd9Sstevel@tonic-gate	    /usr/bin/awk '{print $1}'`
1807c478bd9Sstevel@tonic-gate	if [ -n "$defrouters" ]; then
1817c478bd9Sstevel@tonic-gate		#
1827c478bd9Sstevel@tonic-gate		# We want the default router(s) listed in /etc/defaultrouter
1837c478bd9Sstevel@tonic-gate		# to replace the one added from the BOOTPARAMS WHOAMI response
1847c478bd9Sstevel@tonic-gate		# but we must avoid flushing the last route between the running
1857c478bd9Sstevel@tonic-gate		# system and its /usr file system.
1867c478bd9Sstevel@tonic-gate		#
1877c478bd9Sstevel@tonic-gate
1887c478bd9Sstevel@tonic-gate		# First, remember the original route.
1897c478bd9Sstevel@tonic-gate		shift $#
1907c478bd9Sstevel@tonic-gate		set -- `/usr/bin/netstat -rn -f inet | /usr/bin/grep '^default'`
1917c478bd9Sstevel@tonic-gate		route_IP="$2"
1927c478bd9Sstevel@tonic-gate
1937c478bd9Sstevel@tonic-gate		#
1947c478bd9Sstevel@tonic-gate		# Next, add those from /etc/defaultrouter.  While doing this,
1957c478bd9Sstevel@tonic-gate		# if one of the routes we add is for the route previously
1967c478bd9Sstevel@tonic-gate		# added as a result of the BOOTPARAMS response, we will see
1977c478bd9Sstevel@tonic-gate		# a message of the form:
1987c478bd9Sstevel@tonic-gate		#	"add net default: gateway a.b.c.d: entry exists"
1997c478bd9Sstevel@tonic-gate		#
2007c478bd9Sstevel@tonic-gate		do_delete=yes
2017c478bd9Sstevel@tonic-gate		for router in $defrouters; do
2027c478bd9Sstevel@tonic-gate			set -- `/usr/sbin/route -n add default -gateway $router`
2037c478bd9Sstevel@tonic-gate			[ $? -ne 0 -a "x$5" = "x$route_IP:" ] && do_delete=no
2047c478bd9Sstevel@tonic-gate		done
2057c478bd9Sstevel@tonic-gate
2067c478bd9Sstevel@tonic-gate		#
2077c478bd9Sstevel@tonic-gate		# Finally, delete the original default route unless it was
2087c478bd9Sstevel@tonic-gate		# also listed in the defaultrouter file.
2097c478bd9Sstevel@tonic-gate		#
2107c478bd9Sstevel@tonic-gate		if [ -n "$route_IP" -a $do_delete = yes ]; then
2117c478bd9Sstevel@tonic-gate			/usr/sbin/route -n delete default -gateway $route_IP \
2127c478bd9Sstevel@tonic-gate			    >/dev/null
2137c478bd9Sstevel@tonic-gate		fi
2147c478bd9Sstevel@tonic-gate	else
2157c478bd9Sstevel@tonic-gate		/usr/sbin/route -fn > /dev/null
2167c478bd9Sstevel@tonic-gate	fi
2177c478bd9Sstevel@tonic-gateelse
2187c478bd9Sstevel@tonic-gate	defrouters=
2197c478bd9Sstevel@tonic-gatefi
2207c478bd9Sstevel@tonic-gate
2217c478bd9Sstevel@tonic-gate#
2227c478bd9Sstevel@tonic-gate# Use routeadm(1M) to configure forwarding and launch routing daemons for
2237c478bd9Sstevel@tonic-gate# IPv4 and IPv6 based on preset values.  These settings only apply to the
2247c478bd9Sstevel@tonic-gate# global zone.  For IPv4 dynamic routing, the system will default to
2257c478bd9Sstevel@tonic-gate# disabled if a default route was previously added via BOOTP, DHCP, or
2267c478bd9Sstevel@tonic-gate# the /etc/defaultrouter file.  routeadm also starts in.ndpd.
2277c478bd9Sstevel@tonic-gate#
2287c478bd9Sstevel@tonic-gateif [ ! -f /etc/.dynamic_routing ] && [ -z "$defrouters" ]; then
2297c478bd9Sstevel@tonic-gate	#
2307c478bd9Sstevel@tonic-gate	# No default routes were setup by "route" command above.
2317c478bd9Sstevel@tonic-gate	# Check the kernel routing table for any other default
2327c478bd9Sstevel@tonic-gate	# routes.
2337c478bd9Sstevel@tonic-gate	#
2347c478bd9Sstevel@tonic-gate	/usr/bin/netstat -rn -f inet | \
2357c478bd9Sstevel@tonic-gate	    /usr/bin/grep default >/dev/null 2>&1 && defrouters=yes
2367c478bd9Sstevel@tonic-gatefi
2377c478bd9Sstevel@tonic-gate[ -f /etc/.dynamic_routing ] && /usr/bin/rm -f /etc/.dynamic_routing
2387c478bd9Sstevel@tonic-gateif [ -z "$defrouters" ]; then
2397c478bd9Sstevel@tonic-gate	routeadmstr="-e ipv4-routing"
2407c478bd9Sstevel@tonic-gateelse
2417c478bd9Sstevel@tonic-gate	routeadmstr="-d ipv4-routing"
2427c478bd9Sstevel@tonic-gatefi
2437c478bd9Sstevel@tonic-gate#
2447c478bd9Sstevel@tonic-gate# The -b option used here tells routeadm that the ipv4-routing
2457c478bd9Sstevel@tonic-gate# option in $routeadmstr is the boot-time default.  The
2467c478bd9Sstevel@tonic-gate# boot-time default is used if the administrator has not
2477c478bd9Sstevel@tonic-gate# explicitly enabled or disabled ipv4-routing using the -e or
2487c478bd9Sstevel@tonic-gate# -d routeadm option.
2497c478bd9Sstevel@tonic-gate#
2507c478bd9Sstevel@tonic-gate/usr/sbin/routeadm -u -b $routeadmstr
2517c478bd9Sstevel@tonic-gate
2527c478bd9Sstevel@tonic-gate#
2537c478bd9Sstevel@tonic-gate# In spite of global policy, there may be a need for IPsec because of
2547c478bd9Sstevel@tonic-gate# per-socket policy or tunnelled policy.  With that in mind, check for manual
2557c478bd9Sstevel@tonic-gate# keys in /etc/inet/secret/ipseckeys, or check for IKE configuration in
2567c478bd9Sstevel@tonic-gate# /etc/inet/ike/config.  Either of these will also load and initialize IPsec,
2577c478bd9Sstevel@tonic-gate# thereby consuming kernel memory.
2587c478bd9Sstevel@tonic-gate#
2597c478bd9Sstevel@tonic-gate
2607c478bd9Sstevel@tonic-gateif [ -f /etc/inet/secret/ipseckeys ] ; then
2617c478bd9Sstevel@tonic-gate	/usr/sbin/ipseckey -f /etc/inet/secret/ipseckeys
2627c478bd9Sstevel@tonic-gatefi
2637c478bd9Sstevel@tonic-gate
2647c478bd9Sstevel@tonic-gateif [ -f /etc/inet/ike/config ] ; then
2657c478bd9Sstevel@tonic-gate	/usr/lib/inet/in.iked
2667c478bd9Sstevel@tonic-gatefi
2677c478bd9Sstevel@tonic-gate
2687c478bd9Sstevel@tonic-gate#
2697c478bd9Sstevel@tonic-gate# Configure tunnels which were deferred by /lib/svc/method/net-physical
2707c478bd9Sstevel@tonic-gate# (the svc:/network/physical service) since it depends on the tunnel endpoints
2717c478bd9Sstevel@tonic-gate# being reachable i.e. routing must be running.
2727c478bd9Sstevel@tonic-gate#
2737c478bd9Sstevel@tonic-gate# WARNING: you may wish to turn OFF forwarding if you haven't already, because
2747c478bd9Sstevel@tonic-gate# of various possible security vulnerabilities when configuring tunnels for
2757c478bd9Sstevel@tonic-gate# Virtual Private Network (VPN) construction.
2767c478bd9Sstevel@tonic-gate#
2777c478bd9Sstevel@tonic-gate# Also, if names are used in the /etc/hostname.ip.tun* file, those names
2787c478bd9Sstevel@tonic-gate# have to be in either DNS (and DNS is used) or in /etc/hosts, because this
2797c478bd9Sstevel@tonic-gate# file is executed before NIS or NIS+ is started.
2807c478bd9Sstevel@tonic-gate#
2817c478bd9Sstevel@tonic-gate
2827c478bd9Sstevel@tonic-gate#
2837c478bd9Sstevel@tonic-gate# IPv4 tunnels
2847c478bd9Sstevel@tonic-gate# The second component of the name must be either "ip" or "ip6".
2857c478bd9Sstevel@tonic-gate#
2867c478bd9Sstevel@tonic-gateinterface_names="`/usr/bin/ls /etc/hostname.ip*.*[0-9] 2>/dev/null | \
2877c478bd9Sstevel@tonic-gate    /usr/bin/grep '/etc/hostname\.ip6\{0,1\}\.'`"
2887c478bd9Sstevel@tonic-gateif [ -n "$interface_names" ]; then
2897c478bd9Sstevel@tonic-gate	(
2907c478bd9Sstevel@tonic-gate		echo "configuring IPv4 tunnels:\c"
2917c478bd9Sstevel@tonic-gate		# Extract the part after the first '.'
2927c478bd9Sstevel@tonic-gate		set -- `for intr in $interface_names; do \
2937c478bd9Sstevel@tonic-gate		    /usr/bin/expr //$intr : '[^.]*\.\(.*\)$'; done`
2947c478bd9Sstevel@tonic-gate		while [ $# -ge 1 ]; do
2957c478bd9Sstevel@tonic-gate			# Skip empty files
2967c478bd9Sstevel@tonic-gate			if [ ! -s /etc/hostname\.$1 ]; then
2977c478bd9Sstevel@tonic-gate				shift
2987c478bd9Sstevel@tonic-gate				continue
2997c478bd9Sstevel@tonic-gate			fi
3007c478bd9Sstevel@tonic-gate			/usr/sbin/ifconfig $1 plumb
3017c478bd9Sstevel@tonic-gate			while read ifcmds; do
3027c478bd9Sstevel@tonic-gate				if [ -n "$ifcmds" ]; then
3037c478bd9Sstevel@tonic-gate					/usr/sbin/ifconfig $1 inet $ifcmds
3047c478bd9Sstevel@tonic-gate				fi
3057c478bd9Sstevel@tonic-gate			done </etc/hostname\.$1 >/dev/null
3067c478bd9Sstevel@tonic-gate			echo " $1\c"
3077c478bd9Sstevel@tonic-gate			shift
3087c478bd9Sstevel@tonic-gate		done
3097c478bd9Sstevel@tonic-gate		echo "."
3107c478bd9Sstevel@tonic-gate	)
3117c478bd9Sstevel@tonic-gatefi
3127c478bd9Sstevel@tonic-gate
3137c478bd9Sstevel@tonic-gate#
3147c478bd9Sstevel@tonic-gate# IPv6 Tunnels
3157c478bd9Sstevel@tonic-gate# The second component of the name must be either "ip" or "ip6".
3167c478bd9Sstevel@tonic-gate#
3177c478bd9Sstevel@tonic-gateinterface_names="`/usr/bin/ls /etc/hostname6.ip*.*[0-9] 2>/dev/null | \
3187c478bd9Sstevel@tonic-gate    /usr/bin/grep '/etc/hostname6\.ip6\{0,1\}\.'`"
3197c478bd9Sstevel@tonic-gateif [ -n "$interface_names" ]; then
3207c478bd9Sstevel@tonic-gate	(
3217c478bd9Sstevel@tonic-gate		echo "configuring IPv6 tunnels:\c"
3227c478bd9Sstevel@tonic-gate		# Extract the part after the first '.'
3237c478bd9Sstevel@tonic-gate		set -- `for intr in $interface_names; do \
3247c478bd9Sstevel@tonic-gate		    /usr/bin/expr //$intr : '[^.]*\.\(.*\)$'; done`
3257c478bd9Sstevel@tonic-gate		while [ $# -ge 1 ]; do
3267c478bd9Sstevel@tonic-gate			# Skip empty files
3277c478bd9Sstevel@tonic-gate			if [ ! -s /etc/hostname6\.$1 ]; then
3287c478bd9Sstevel@tonic-gate				shift
3297c478bd9Sstevel@tonic-gate				continue
3307c478bd9Sstevel@tonic-gate			fi
3317c478bd9Sstevel@tonic-gate			/usr/sbin/ifconfig $1 inet6 plumb
3327c478bd9Sstevel@tonic-gate			while read ifcmds; do
3337c478bd9Sstevel@tonic-gate				if [ -n "$ifcmds" ]; then
3347c478bd9Sstevel@tonic-gate					/usr/sbin/ifconfig $1 inet6 $ifcmds
3357c478bd9Sstevel@tonic-gate				fi
3367c478bd9Sstevel@tonic-gate			done </etc/hostname6\.$1 > /dev/null
3377c478bd9Sstevel@tonic-gate			echo " $1\c"
3387c478bd9Sstevel@tonic-gate			shift
3397c478bd9Sstevel@tonic-gate		done
3407c478bd9Sstevel@tonic-gate		echo "."
3417c478bd9Sstevel@tonic-gate	)
3427c478bd9Sstevel@tonic-gatefi
3437c478bd9Sstevel@tonic-gate
3447c478bd9Sstevel@tonic-gate#
3457c478bd9Sstevel@tonic-gate# Set 6to4 Relay Router communication support policy and, if applicable,
3467c478bd9Sstevel@tonic-gate# the destination Relay Router IPv4 address.  See /etc/default/inetinit for
3477c478bd9Sstevel@tonic-gate# setting and further info on ACCEPT6TO4RELAY and RELAY6TO4ADDR.
3487c478bd9Sstevel@tonic-gate# If ACCEPT6TO4RELAY=NO, the default value in the kernel will
3497c478bd9Sstevel@tonic-gate# be used.
3507c478bd9Sstevel@tonic-gate#
3517c478bd9Sstevel@tonic-gateACCEPT6TO4RELAY=`echo "$ACCEPT6TO4RELAY" | /usr/bin/tr '[A-Z]' '[a-z]'`
3527c478bd9Sstevel@tonic-gateif [ "$ACCEPT6TO4RELAY" = yes ]; then
3537c478bd9Sstevel@tonic-gate        if [ "$RELAY6TO4ADDR" ]; then
3547c478bd9Sstevel@tonic-gate                /usr/sbin/6to4relay -e -a $RELAY6TO4ADDR
3557c478bd9Sstevel@tonic-gate        else
3567c478bd9Sstevel@tonic-gate                /usr/sbin/6to4relay -e
3577c478bd9Sstevel@tonic-gate        fi
3587c478bd9Sstevel@tonic-gatefi
3597c478bd9Sstevel@tonic-gate
360*a59fa508Sjl138328#
361*a59fa508Sjl138328# Read /etc/inet/static_routes and add each route.
362*a59fa508Sjl138328#
363*a59fa508Sjl138328if [ -f /etc/inet/static_routes ]; then
364*a59fa508Sjl138328	echo "Adding persistent routes:"
365*a59fa508Sjl138328	/usr/bin/egrep -v "^(#|$)" /etc/inet/static_routes | while read line; do
366*a59fa508Sjl138328		/usr/sbin/route add $line
367*a59fa508Sjl138328	done
368*a59fa508Sjl138328fi
369*a59fa508Sjl138328
3707c478bd9Sstevel@tonic-gate# Clear exit status.
3717c478bd9Sstevel@tonic-gateexit 0
372