xref: /illumos-gate/usr/src/cmd/svc/milestone/net-init (revision e11c3f44f531fdff80941ce57c065d2ae861cefc)
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
66927f468Sdp# Common Development and Distribution License (the "License").
76927f468Sdp# You may not use this file except in compliance with the License.
87c478bd9Sstevel@tonic-gate#
97c478bd9Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate# See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate# and limitations under the License.
137c478bd9Sstevel@tonic-gate#
147c478bd9Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate#
207c478bd9Sstevel@tonic-gate# CDDL HEADER END
217c478bd9Sstevel@tonic-gate#
227c478bd9Sstevel@tonic-gate#
23*e11c3f44Smeem# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate# Use is subject to license terms.
257c478bd9Sstevel@tonic-gate#
267c478bd9Sstevel@tonic-gate# This is the second phase of TCP/IP configuration.  The first part is
27a192e900Samaguire# run by the svc:/network/physical service and includes configuring the
28a192e900Samaguire# interfaces and setting the machine's hostname.  The svc:/network/initial
29a192e900Samaguire# service does all configuration that can be done before name services are
30a192e900Samaguire# started, bar configuring IP routing (this is carried out by the
31a192e900Samaguire# svc:/network/routing-setup service).  The final part, run by the
32a192e900Samaguire# svc:/network/service service,  does all configuration that may require
33a192e900Samaguire# name services.  This includes a final re-configuration of the
34a192e900Samaguire# interfaces.
357c478bd9Sstevel@tonic-gate#
367c478bd9Sstevel@tonic-gate
377c478bd9Sstevel@tonic-gate. /lib/svc/share/smf_include.sh
387c478bd9Sstevel@tonic-gate
397c478bd9Sstevel@tonic-gate#
40f4b3ec61Sdh155122# In a shared-IP zone we need this service to be up, but all of the work
417c478bd9Sstevel@tonic-gate# it tries to do is irrelevant (and will actually lead to the service
427c478bd9Sstevel@tonic-gate# failing if we try to do it), so just bail out.
43f4b3ec61Sdh155122# In the global zone and exclusive-IP zones we proceed.
447c478bd9Sstevel@tonic-gate#
45f4b3ec61Sdh155122smf_configure_ip || exit $SMF_EXIT_OK
466927f468Sdp
477c478bd9Sstevel@tonic-gate# Configure IPv6 Default Address Selection.
487c478bd9Sstevel@tonic-gateif [ -f /etc/inet/ipaddrsel.conf ]; then
497c478bd9Sstevel@tonic-gate	/usr/sbin/ipaddrsel -f /etc/inet/ipaddrsel.conf
507c478bd9Sstevel@tonic-gatefi
517c478bd9Sstevel@tonic-gate
527c478bd9Sstevel@tonic-gate#
53*e11c3f44Smeem# If explicit IPMP groups are being used, in.mpathd will already be started.
54*e11c3f44Smeem# However, if TRACK_INTERFACES_ONLY_WITH_GROUPS=no and no explicit IPMP
55*e11c3f44Smeem# groups have been configured, then it still needs to be started.  So, fire
56*e11c3f44Smeem# it up in "adopt" mode; if there are no interfaces it needs to manage, it
57*e11c3f44Smeem# will automatically exit.
587c478bd9Sstevel@tonic-gate#
59f4b3ec61Sdh155122/usr/bin/pgrep -x -u 0 -z `smf_zonename` in.mpathd >/dev/null 2>&1 || \
60f4b3ec61Sdh155122    /usr/lib/inet/in.mpathd -a
617c478bd9Sstevel@tonic-gate
627c478bd9Sstevel@tonic-gate#
637c478bd9Sstevel@tonic-gate# Set the RFC 1948 entropy, regardless of if I'm using it or not.  If present,
647c478bd9Sstevel@tonic-gate# use the encrypted root password as a source of entropy.  Otherwise,
657c478bd9Sstevel@tonic-gate# just use the pre-set (and hopefully difficult to guess) entropy that
667c478bd9Sstevel@tonic-gate# tcp used when it loaded.
677c478bd9Sstevel@tonic-gate#
687c478bd9Sstevel@tonic-gateencr=`/usr/bin/awk -F: '/^root:/ {print $2}' /etc/shadow`
697c478bd9Sstevel@tonic-gate[ -z "$encr" ] || /usr/sbin/ndd -set /dev/tcp tcp_1948_phrase $encr
707c478bd9Sstevel@tonic-gateunset encr
717c478bd9Sstevel@tonic-gate
727c478bd9Sstevel@tonic-gate#
737c478bd9Sstevel@tonic-gate# Get values for TCP_STRONG_ISS, ACCEPT6TO4RELAY and RELAY6TO4ADDR.
747c478bd9Sstevel@tonic-gate#
757c478bd9Sstevel@tonic-gate[ -f /etc/default/inetinit ] && . /etc/default/inetinit
767c478bd9Sstevel@tonic-gate
77db5ca0bdSsangeeta# Set the SDP system Policy.  This needs to happen after basic
78db5ca0bdSsangeeta# networking is up but before any networking services that might
79db5ca0bdSsangeeta# want to use SDP are enabled
80db5ca0bdSsangeetaif [ -f /usr/sbin/sdpadm -a -f /etc/sdp.conf ]; then
81db5ca0bdSsangeeta	. /etc/sdp.conf
82db5ca0bdSsangeeta	if [ "$sysenable" = "1" ]; then
83db5ca0bdSsangeeta		/usr/sbin/sdpadm enable
84db5ca0bdSsangeeta	fi
85db5ca0bdSsangeetafi
86db5ca0bdSsangeeta
877c478bd9Sstevel@tonic-gate#
887c478bd9Sstevel@tonic-gate# Set TCP ISS generation.  By default the ISS generation is
897c478bd9Sstevel@tonic-gate# time + random()-delta.  This might not be strong enough for some users.
907c478bd9Sstevel@tonic-gate# See /etc/default/inetinit for settings and further info on TCP_STRONG_ISS.
917c478bd9Sstevel@tonic-gate# If not set, use TCP's internal default setting.
927c478bd9Sstevel@tonic-gate#
937c478bd9Sstevel@tonic-gateif [ $TCP_STRONG_ISS ]; then
947c478bd9Sstevel@tonic-gate	/usr/sbin/ndd -set /dev/tcp tcp_strong_iss $TCP_STRONG_ISS
957c478bd9Sstevel@tonic-gatefi
967c478bd9Sstevel@tonic-gate
977c478bd9Sstevel@tonic-gate#
987c478bd9Sstevel@tonic-gate# Configure tunnels which were deferred by /lib/svc/method/net-physical
997c478bd9Sstevel@tonic-gate# (the svc:/network/physical service) since it depends on the tunnel endpoints
1007c478bd9Sstevel@tonic-gate# being reachable i.e. routing must be running.
1017c478bd9Sstevel@tonic-gate#
1027c478bd9Sstevel@tonic-gate# WARNING: you may wish to turn OFF forwarding if you haven't already, because
1037c478bd9Sstevel@tonic-gate# of various possible security vulnerabilities when configuring tunnels for
1047c478bd9Sstevel@tonic-gate# Virtual Private Network (VPN) construction.
1057c478bd9Sstevel@tonic-gate#
1067c478bd9Sstevel@tonic-gate# Also, if names are used in the /etc/hostname.ip.tun* file, those names
1077c478bd9Sstevel@tonic-gate# have to be in either DNS (and DNS is used) or in /etc/hosts, because this
1087c478bd9Sstevel@tonic-gate# file is executed before NIS or NIS+ is started.
1097c478bd9Sstevel@tonic-gate#
1107c478bd9Sstevel@tonic-gate
1117c478bd9Sstevel@tonic-gate#
1127c478bd9Sstevel@tonic-gate# IPv4 tunnels
1137c478bd9Sstevel@tonic-gate# The second component of the name must be either "ip" or "ip6".
1147c478bd9Sstevel@tonic-gate#
1157c478bd9Sstevel@tonic-gateinterface_names="`/usr/bin/ls /etc/hostname.ip*.*[0-9] 2>/dev/null | \
1167c478bd9Sstevel@tonic-gate    /usr/bin/grep '/etc/hostname\.ip6\{0,1\}\.'`"
1177c478bd9Sstevel@tonic-gateif [ -n "$interface_names" ]; then
1187c478bd9Sstevel@tonic-gate	(
1197c478bd9Sstevel@tonic-gate		echo "configuring IPv4 tunnels:\c"
1207c478bd9Sstevel@tonic-gate		# Extract the part after the first '.'
1217c478bd9Sstevel@tonic-gate		set -- `for intr in $interface_names; do \
1227c478bd9Sstevel@tonic-gate		    /usr/bin/expr //$intr : '[^.]*\.\(.*\)$'; done`
1237c478bd9Sstevel@tonic-gate		while [ $# -ge 1 ]; do
1247c478bd9Sstevel@tonic-gate			# Skip empty files
1257c478bd9Sstevel@tonic-gate			if [ ! -s /etc/hostname\.$1 ]; then
1267c478bd9Sstevel@tonic-gate				shift
1277c478bd9Sstevel@tonic-gate				continue
1287c478bd9Sstevel@tonic-gate			fi
1297c478bd9Sstevel@tonic-gate			/usr/sbin/ifconfig $1 plumb
1307c478bd9Sstevel@tonic-gate			while read ifcmds; do
1317c478bd9Sstevel@tonic-gate				if [ -n "$ifcmds" ]; then
1327c478bd9Sstevel@tonic-gate					/usr/sbin/ifconfig $1 inet $ifcmds
1337c478bd9Sstevel@tonic-gate				fi
1347c478bd9Sstevel@tonic-gate			done </etc/hostname\.$1 >/dev/null
1357c478bd9Sstevel@tonic-gate			echo " $1\c"
1367c478bd9Sstevel@tonic-gate			shift
1377c478bd9Sstevel@tonic-gate		done
1387c478bd9Sstevel@tonic-gate		echo "."
1397c478bd9Sstevel@tonic-gate	)
1407c478bd9Sstevel@tonic-gatefi
1417c478bd9Sstevel@tonic-gate
1427c478bd9Sstevel@tonic-gate#
1437c478bd9Sstevel@tonic-gate# IPv6 Tunnels
1447c478bd9Sstevel@tonic-gate# The second component of the name must be either "ip" or "ip6".
1457c478bd9Sstevel@tonic-gate#
1467c478bd9Sstevel@tonic-gateinterface_names="`/usr/bin/ls /etc/hostname6.ip*.*[0-9] 2>/dev/null | \
1477c478bd9Sstevel@tonic-gate    /usr/bin/grep '/etc/hostname6\.ip6\{0,1\}\.'`"
1487c478bd9Sstevel@tonic-gateif [ -n "$interface_names" ]; then
1497c478bd9Sstevel@tonic-gate	(
1507c478bd9Sstevel@tonic-gate		echo "configuring IPv6 tunnels:\c"
1517c478bd9Sstevel@tonic-gate		# Extract the part after the first '.'
1527c478bd9Sstevel@tonic-gate		set -- `for intr in $interface_names; do \
1537c478bd9Sstevel@tonic-gate		    /usr/bin/expr //$intr : '[^.]*\.\(.*\)$'; done`
1547c478bd9Sstevel@tonic-gate		while [ $# -ge 1 ]; do
1557c478bd9Sstevel@tonic-gate			# Skip empty files
1567c478bd9Sstevel@tonic-gate			if [ ! -s /etc/hostname6\.$1 ]; then
1577c478bd9Sstevel@tonic-gate				shift
1587c478bd9Sstevel@tonic-gate				continue
1597c478bd9Sstevel@tonic-gate			fi
1607c478bd9Sstevel@tonic-gate			/usr/sbin/ifconfig $1 inet6 plumb
1617c478bd9Sstevel@tonic-gate			while read ifcmds; do
1627c478bd9Sstevel@tonic-gate				if [ -n "$ifcmds" ]; then
1637c478bd9Sstevel@tonic-gate					/usr/sbin/ifconfig $1 inet6 $ifcmds
1647c478bd9Sstevel@tonic-gate				fi
1657c478bd9Sstevel@tonic-gate			done </etc/hostname6\.$1 > /dev/null
1667c478bd9Sstevel@tonic-gate			echo " $1\c"
1677c478bd9Sstevel@tonic-gate			shift
1687c478bd9Sstevel@tonic-gate		done
1697c478bd9Sstevel@tonic-gate		echo "."
1707c478bd9Sstevel@tonic-gate	)
1717c478bd9Sstevel@tonic-gatefi
1727c478bd9Sstevel@tonic-gate
1737c478bd9Sstevel@tonic-gate# Clear exit status.
1746927f468Sdpexit $SMF_EXIT_OK
175