net-routing-setup revision 2b24ab6b3865caeede9eeb9db6b83e1d89dcd1ea
# 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. # See the License for the specific language governing permissions # and limitations under the License. # When distributing Covered Code, include this CDDL HEADER in each # 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] # Copyright 2009 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # 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. # 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). nawk '/^ipv[46]-routing [.]*/ { print $2 }' | /usr/bin/grep "current=enabled"` # configuration file. The file can contain the hostnames or IP # addresses of one or more default routers. If hostnames are used, # each hostname must also be listed in the local "/etc/hosts" file # because NIS and NIS+ are 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. # replace those added by the kernel during diskless booting. An # 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 # We want the default router(s) listed in # BOOTPARAMS WHOAMI response but we must avoid flushing # the last route between the running system and its # First, remember the original route. # 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" # Finally, delete the original default route unless it # was also listed in the defaultrouter file. # 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, # No default routes were setup by "route" command above. # Check the kernel routing table for any other default # 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. # 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. # 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 echo "Adding persistent routes:"