xref: /titanic_41/usr/src/cmd/svc/milestone/net-netmask (revision eb82ff87b34e625264561b2d267577cf9821dab0)
1#!/sbin/sh
2#
3# CDDL HEADER START
4#
5# The contents of this file are subject to the terms of the
6# Common Development and Distribution License (the "License").
7# You may not use this file except in compliance with the License.
8#
9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10# or http://www.opensolaris.org/os/licensing.
11# See the License for the specific language governing permissions
12# and limitations under the License.
13#
14# When distributing Covered Code, include this CDDL HEADER in each
15# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16# If applicable, add the following below this CDDL HEADER, with the
17# fields enclosed by brackets "[]" replaced with your own identifying
18# information: Portions Copyright [yyyy] [name of copyright owner]
19#
20# CDDL HEADER END
21#
22#
23# Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
24# Use is subject to license terms.
25#
26
27#
28# Reset netmask and broadcast address whenever new information is
29# availabe from NIS.
30#
31
32. /lib/svc/share/smf_include.sh
33
34#
35# In a shared-IP zone we need this service to be up, but all of the
36# work it tries to do is irrelevant (and will actually lead to the
37# service failing if we try to do it), so just bail out.
38# In the global zone and exclusive-IP zones we proceed.
39#
40smf_configure_ip || exit $SMF_EXIT_OK
41
42#
43# wait_nis
44# Wait up to 5 seconds for ypbind to obtain a binding.
45#
46wait_nis ()
47{
48	for i in 1 2 3 4 5; do
49		server=`/usr/bin/ypwhich 2>/dev/null`
50		[ $? -eq 0 -a -n "$server" ] && return 0 || sleep 1
51	done
52	return 1
53}
54
55#
56# Reset the netmask and broadcast address for our network interfaces.
57# Since this may result in a name service lookup, we want to now wait
58# for NIS to come up if we previously started it.
59#
60domain=`/usr/bin/domainname 2>/dev/null`
61
62[ -z "$domain" ] || [ ! -d /var/yp/binding/$domain ] || wait_nis || \
63    echo "WARNING: Timed out waiting for NIS to come up" >& 2
64
65#
66# Re-set the netmask and broadcast addr for all IP interfaces.  This
67# ifconfig is run here, after waiting for name services, so that
68# "netmask +" will find the netmask if it lives in a NIS map. The 'D'
69# in -auD tells ifconfig NOT to mess with the interface if it is
70# under DHCP control
71#
72/usr/sbin/ifconfig -auD4 netmask + broadcast +
73
74# Uncomment these lines to print complete network interface configuration
75# echo "network interface configuration:"
76# /usr/sbin/ifconfig -a
77