Diff for /wikisrc/tutorials/how_to_set_up_nfs_and_nis.mdwn between versions 1.2 and 1.7

version 1.2, 2012/02/05 07:14:36 version 1.7, 2020/09/09 14:28:56
Line 15  NIS (Network Information Service) is a d Line 15  NIS (Network Information Service) is a d
   
 We will need NIS (or another directory service) to make sure the NFS user ids/group ids are the same on the server as on all clients. Otherwise, bad things will happen, as you can probably imagine (especially in our example of mounting /home over NFS). Note that using NIS with NFS is not mandatory, you can also keep the server and client's passwd in synch.   We will need NIS (or another directory service) to make sure the NFS user ids/group ids are the same on the server as on all clients. Otherwise, bad things will happen, as you can probably imagine (especially in our example of mounting /home over NFS). Note that using NIS with NFS is not mandatory, you can also keep the server and client's passwd in synch. 
   
 NIS used to be called the `Yellow Pages', or YP for short. Because of trademarks it had to be renamed, but the programs are all still prefixed with `yp'.   NIS used to be called the "Yellow Pages", or YP for short. Because of trademarks it had to be renamed, but the programs are all still prefixed with `yp`. 
   
       
   
Line 41  If you want to get funky and boot from N Line 41  If you want to get funky and boot from N
   
 The first thing we should do is decide on a NIS domain name. This has nothing to do with your machine's Internet domain name. It is just a unique name that is used to identify machines in the same NIS block.   The first thing we should do is decide on a NIS domain name. This has nothing to do with your machine's Internet domain name. It is just a unique name that is used to identify machines in the same NIS block. 
   
 The domainname is set (as root) using the [domainname(1)](http://netbsd.gw.com/cgi-bin/man-cgi?domainname+1+NetBSD-current) program, or can be set in the /etc/mydomain file.     The domainname is set (as root) using the [[!template id=man name="domainname" section="1"]] program, or can be set in the /etc/mydomain file.   
 Alternatively, in most BSD systems, it can be set in /etc/rc.conf under the variable `domainname'.   Alternatively, in most BSD systems, it can be set in /etc/rc.conf under the variable `domainname`. 
           
   
  root@earth# domainname planets   root@earth# domainname planets
Line 57  After this, we must initialise all files Line 57  After this, we must initialise all files
 The -m means we are creating a master server. On more complex networks, you can even want slave servers. The tool will ask you for a list of YP servers to bind to.     The -m means we are creating a master server. On more complex networks, you can even want slave servers. The tool will ask you for a list of YP servers to bind to.   
 Since we're only using one server, just press RETURN (make sure your own server's internal address is in the list).   Since we're only using one server, just press RETURN (make sure your own server's internal address is in the list). 
   
 Before we run `make' in /var/yp, as the tool says, we must enable the NIS deamons: rpcbind, ypserv and ypbind (in that order). After that, we can run `make' in /var/yp.   Before we run `make` in /var/yp, as the tool says, we must enable the NIS daemons: rpcbind, ypserv and ypbind (in that order). After that, we can run `make` in /var/yp. 
   
 To test if your setup is working, try yptest. It should spew out the passwd file among others, so don't panic ;)   To test if your setup is working, try yptest. It should spew out the passwd file among others, so don't panic ;) 
   
Line 78  Then just run  Line 78  Then just run 
     # /etc/rc.d/yppasswdd start      # /etc/rc.d/yppasswdd start
           
   
 [rpc.yppasswdd(8)](http://netbsd.gw.com/cgi-bin/man-cgi?rpc.yppasswdd+8+NetBSD-current) must be running on the NIS master server to allow users to change information in the password file.     [[!template id=man name="rpc.yppasswdd" section="8"]] must be running on the NIS master server to allow users to change information in the password file.   
 [ypserv(8)](http://netbsd.gw.com/cgi-bin/man-cgi?ypserv+8+NetBSD-current) provides information from NIS maps to the NIS clients on the network.     [[!template id=man name="ypserv" section="8"]] provides information from NIS maps to the NIS clients on the network.   
 [ypbind(8)](http://netbsd.gw.com/cgi-bin/man-cgi?ypbind+8+NetBSD-current) finds the server for a particular NIS domain and stores information about it in a ``binding file_._  [[!template id=man name="ypbind" section="8"]] finds the server for a particular NIS domain and stores information about it in a "binding file".
   
 After that, you can use ypinit:   After that, you can use ypinit: 
           
Line 89  After that, you can use ypinit:  Line 89  After that, you can use ypinit: 
   
 Then, add your NIS server's address to the list. To test if everything is working, use yptest on the client as well. **Note that ypbind will HANG if it can't find the server!**  Then, add your NIS server's address to the list. To test if everything is working, use yptest on the client as well. **Note that ypbind will HANG if it can't find the server!**
   
 If everything is working, you are ready to go! Just edit /etc/nsswitch.conf and put in some `nis' keywords. For example:   If everything is working, you are ready to go! Just edit /etc/nsswitch.conf and put in some `nis` keywords. For example: 
           
      passwd:            files nis       passwd:            files nis
           
   
 would first look up usernames/passwords/uids in /etc/passwd, and if it can't find it, it would look it up using NIS. Right after changing this file, you should be able to log in on your system using a username which is only in /etc/passwd on the server. That's all there is to it.   would first look up usernames/passwords/uids in /etc/passwd, and if it can't find it, it would look it up using NIS. Right after changing this file, you should be able to log in on your system using a username which is only in /etc/passwd on the server. That's all there is to it. 
   
 #  The deamons   #  The daemons 
   
 What are all those daemons for? Well, here's a quick rundown:   What are all those daemons for? Well, here's a quick rundown: 
   
Line 114  Setting up NFS is a piece of cake. Just  Line 114  Setting up NFS is a piece of cake. Just 
      /home              -network 192.168.0.0 -mask 255.255.0.0 -maproot=root       /home              -network 192.168.0.0 -mask 255.255.0.0 -maproot=root
           
   
 This exports /home only on the LAN 192.168.x.x. The maproot line is needed, because otherwise the client's root will not have superuser access. Now, start the mount daemon and the NFS deamons (mountd and nfsd) as root on your server, in that order. For that type:   This exports /home only on the LAN 192.168.x.x. The maproot line is needed, because otherwise the client's root will not have superuser access. Now, start the mount daemon and the NFS daemons (mountd and nfsd) as root on your server, in that order. For that type: 
           
      root@mars# /etc/rc.d/rpcbind start       root@mars# /etc/rc.d/rpcbind onestart
      root@mars# /etc/rc.d/mountd start       root@mars# /etc/rc.d/mountd onestart
      root@mars# /etc/rc.d/nfsd start       root@mars# /etc/rc.d/nfsd onestart
      root@mars# /etc/rc.d/nfslocking start       root@mars# /etc/rc.d/nfslocking onestart
           
   
 If you wish to start the NFS server on boot, add following lines to your /etc/rc.conf   If you wish to start the NFS server on boot, add following lines to your /etc/rc.conf 
Line 143  Voila, you're done. Just add all NFS vol Line 143  Voila, you're done. Just add all NFS vol
   
 and have them mounted at system startup.   and have them mounted at system startup. 
   
 NOTE: I had much trouble with NFS which was caused by UDP packet fragmentation. This made all writes extremely slow (and other outgoing network traffic as well!) while reads were at an acceptable speed. To solve this, I added the (undocumented?) `tcp' option to fstab to mount NFS over TCP. You'll probably also need to add   NOTE: I had much trouble with NFS which was caused by UDP packet fragmentation. This made all writes extremely slow (and other outgoing network traffic as well!) while reads were at an acceptable speed. To solve this, I added the (undocumented?) `tcp` option to fstab to mount NFS over TCP. You'll probably also need to add 
           
     nfsd_flags='-t'      nfsd_flags='-t'
           
Line 196  In my /etc/hosts.allow I have my LAN hos Line 196  In my /etc/hosts.allow I have my LAN hos
   
 #  See also   #  See also 
   
   * [mount_nfs(8)](http://netbsd.gw.com/cgi-bin/man-cgi?mount_nfs+8+NetBSD-current) manpage     * [[!template id=man name="mount_nfs" section="8"]] manpage 
   
   

Removed from v.1.2  
changed lines
  Added in v.1.7


CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb