View Single Post

   
  #4 (permalink)  
Old 03-28-2008, 04:31 AM
Richard B. Gilbert
 
Posts: n/a
Default Re: Script for NIS update while using DHCP

H4mm3r wrote:
> On 17 mar, 16:23, "Richard B. Gilbert" <rgilber...@comcast.net> wrote:
>
>>H4mm3r wrote:
>>
>>>Hi all,

>>
>>>I have read that we need a script in order to set up correctly NIS
>>>environment while using DHCP client on Solaris.
>>>Any has a running script already available ?

>>
>>>Thanks in advance.

>>
>>Where did you read that?

>
>
> You can go to Solaris 10 documentation :
> http://docs.sun.com/app/docs/doc/816...min-570?a=view
> You'll read :
> If a DHCP client system is already running the Solaris OS, the NIS
> client is not automatically configured on that system when the DHCP
> server sends NIS information to the client.
> Tip -
>
> You can write a script that uses dhcpinfo and ypinit to automate NIS
> client configuration on DHCP client systems.
>
> It sounds weird to me especially considering that SUN is responsible
> for NIS.


As I read it, DHCP will send NIS server addresses but this is not
sufficient to configure NIS on the client.

Here's a script I have used in the past to setup NIS clients.

#! /bin/sh -v
#
# Set up an NIS client system. The domainname and the server's name and
# IP address are passed as parameters.
#
# We use a modified version of /etc/nsswitch.files for nsswitch.conf.
# The passwd and group lines have been modified by appending " nis" and
# the hosts line has been modified by appending " dns". We copy the
# desired nsswitch.conf file from floppy disk.
#
domainname {$1}
echo `domainname` > /etc/defaultdomain
echo {$2} >> /etc/inet/hosts
cp /floppy/noname/nsswitch.conf /etc/nsswitch.conf
#
# This bit matches the string contained in the second argument to this
# script in /etc/inet/hosts, extracts the second field, the hostname,
# and passes it via a pipe to ypinit.
#
nawk "/$2/ {print \$2}" /etc/inet/hosts | /usr/sbin/ypinit -c
# Start the yp daemon.
/usr/lib/netsvc/yp/ypstart
#
# Done! Now verify that it works. This should output a list of
# all the NIS maps together with the name of the server each came
# from; e.g.
# mail.aliases thcmp01
# netid.byname thcmp01
# mail.byaddr thcmp01
# . . .
#
ypwhich -m


Reply With Quote