#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# This script configures IP routing.
#
# In a shared-IP zone we need this service to be up, but all of the work
# it tries to do is irrelevant (and will actually lead to the service
# failing if we try to do it), so just bail out.
# In the global zone and exclusive-IP zones we proceed.
#
smf_configure_ip || exit $SMF_EXIT_OK
#
# If routing.conf file is in place, and has not already been read in
# by previous invokation of routeadm, legacy configuration is upgraded
# by this call to "routeadm -u". This call is also needed when
# which need to be applied. Finally, routeadm starts in.ndpd by
# enabling the ndp service (in.ndpd), which is required for IPv6 address
# autoconfiguration. It would be nice if we could do this in
# point in boot, we cannot.
#
#
# Are we routing dynamically? routeadm(1M) reports this in the
# "current" values of ipv4/6-routing - if either are true, we are running
# routing daemons (or at least they are enabled to run).
#
dynamic_routing_test=`/sbin/routeadm -p | \
if [ -n "$dynamic_routing_test" ]; then
dynamic_routing="true"
fi
#
# Configure default IPv4 routers using the local "/etc/defaultrouter"
# configuration file. The file can contain the hostnames or IP
# addresses of one or more default routers. If hostnames are used,
# because NIS is not running at the time that this script is
# run. Each router name or address is listed on a single line by
# itself in the file. Anything else on that line after the router's
# name or address is ignored. Lines that begin with "#" are
# considered comments and ignored.
#
# The default routes listed in the "/etc/defaultrouter" file will
# replace those added by the kernel during diskless booting. An
# empty "/etc/defaultrouter" file will cause the default route
# added by the kernel to be deleted.
#
# Note that the default router file is ignored if we received routes
# from a DHCP server. Our policy is to always trust DHCP over local
# administration.
#
if [ "$_INIT_NET_STRATEGY" = "dhcp" ] && \
elif [ -f /etc/defaultrouter ]; then
defrouters=`/usr/bin/grep -v \^\# /etc/defaultrouter | \
if [ -n "$defrouters" ]; then
#
# We want the default router(s) listed in
# /etc/defaultrouter to replace the one added from the
# BOOTPARAMS WHOAMI response but we must avoid flushing
# the last route between the running system and its
# /usr file system.
#
# First, remember the original route.
shift $#
route_IP="$2"
#
# Next, add those from /etc/defaultrouter. While doing
# this, if one of the routes we add is for the route
# previously added as a result of the BOOTPARAMS
# response, we will see a message of the form:
# "add net default: gateway a.b.c.d: entry exists"
#
res=$?
set -- $route_added
done
#
# Finally, delete the original default route unless it
# was also listed in the defaultrouter file.
#
fi
else
fi
else
fi
#
# Use routeadm(1M) to configure forwarding and launch routing daemons
# for IPv4 and IPv6 based on preset values. These settings only apply
# to the global zone. For IPv4 dynamic routing, the system will default
# to disabled if a default route was previously added via BOOTP, DHCP,
# or the /etc/defaultrouter file. routeadm also starts in.ndpd.
#
#
# No default routes were setup by "route" command above.
# Check the kernel routing table for any other default
# routes.
#
fi
#
# The routeadm/ipv4-routing-set property is true if the administrator
# has run "routeadm -e/-d ipv4-routing". If not, we revert to the
# appropriate defaults. We no longer run "routeadm -u" on every boot
# however, as persistent daemon state is now controlled by SMF.
#
if [ -z "$defrouters" ]; then
#
# Set default value for ipv4-routing to enabled. If routeadm -e/-d
# has not yet been run by the administrator, we apply this default.
# The -b option is project-private and informs routeadm not
# to treat the enable as administrator-driven.
#
if [ "$ipv4_routing_set" = "false" ]; then
fi
else
#
# Default router(s) have been found, so ipv4-routing default value
# should be disabled. If routaedm -e/d has not yet been run by
# the administrator, we apply this default. The -b option is
# project-private and informs routeadm not to treat the disable as
# administrator-driven.
#
if [ "$ipv4_routing_set" = "false" ]; then
fi
fi
#
# See if static routes were created by install. If so, they were created
#
echo "Installing persistent routes"
else
fi
fi
#
# Read /etc/inet/static_routes and add each route.
#
echo "Adding persistent routes:"
done
fi
# Clear exit status.
exit $SMF_EXIT_OK