home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 11 / IOPROG_11.ISO / docs / nfs-ho~1 < prev    next >
Encoding:
Text File  |  1997-03-29  |  30.1 KB  |  659 lines

  1.   NFS HOWTO
  2.   Nicolai Langfeldt janl@math.uio.no
  3.   v0.5, 9 March 1997
  4.  
  5.   HOWTO set up NFS clients and servers.
  6.  
  7.   1.  Preamble
  8.  
  9.   1.1.  Legal stuff
  10.  
  11.   (C)opyright 1997 Nicolai Langfeldt and Alan Cox.  Do not modify
  12.   without amending copyright, distribute freely but retain copyright
  13.   message.
  14.  
  15.   1.2.  Other stuff
  16.  
  17.   This will never be a finished document, please send me mail about your
  18.   problems and successes, it can make this a better HOWTO.  Please send
  19.   money, comments and/or questions to janl@math.uio.no.  If you send E-
  20.   mail please make sure that the return address is correct and working,
  21.   I get a lot of E-mail and figuring out your e-mail address can be a
  22.   lot of work.  Please.
  23.  
  24.   If you want to translate this HOWTO please notify me so I can keep
  25.   track of what languages I have been published in :-).
  26.  
  27.   Curses and Thanks to Olaf Kirch who got me to write this and then gave
  28.   good suggestions for it :-)
  29.  
  30.   1.3.  Dedication
  31.  
  32.   This HOWTO is dedicated to Anne Line Norheim.  Though she will
  33.   probably never read it since she's not that kind of girl.
  34.  
  35.   2.  README.first
  36.  
  37.   NFS, the Network File System has two important characteristics:
  38.  
  39.   ╖  It makes sharing of files over a network possible.
  40.  
  41.   ╖  It opens a can of security risks that are well understood by
  42.      crackers, and easily exploited to get access (read, write and
  43.      delete) to all your files.
  44.  
  45.   I'll say something on both issues in this HOWTO.  Please make sure you
  46.   read the whole of this HOWTO, and you will be vulnerable to fewer
  47.   silly security risks.  Don't say I didn't warn you.  The passages
  48.   about security will at times be pretty technical and require some
  49.   knowledge about IP networking and the terms used.  If you don't
  50.   recognize the terms you can either go back and check the networking
  51.   HOWTO, wing it, or get a book about TCP/IP network administration to
  52.   familiarize yourself with TCP/IP.  That's a good idea anyway if you're
  53.   administrating UNIX/Linux machines.  A very good book on the subject
  54.   is TCP/IP Network Administration by Craig Hunt, published by O'Reilly
  55.   & Associates, Inc.  And after you've read it and understood it you'll
  56.   have higher value on the job market, you can't loose ;-)
  57.  
  58.   3.  Setting up a NFS server
  59.  
  60.   3.1.  Prerequisites
  61.  
  62.   Before you continue reading this HOWTO you will need to be able to
  63.   telnet back and forth between the machine you're using as server and
  64.   the client.  If that does not work you need to check the
  65.   networking/NET-2 HOWTO and set up networking properly.
  66.  
  67.   3.2.  Starting at the path
  68.  
  69.   Before we can do anything else we need a NFS server set up.  If you're
  70.   part of a department or university network there are likely numerous
  71.   NFS servers already set up.  If they will let you get access to them,
  72.   or indeed, if you're reading this HOWTO to get access to one of them
  73.   you obviously don't need to read this section and can just skip ahead
  74.   to the section on ``setting up a NFS client''
  75.  
  76.   If you need to set up a non-Linux box as server you will have to read
  77.   the system manual(s) to discover how to enable NFS serving and export
  78.   of file systems through NFS.  Keywords are: nfsd, system
  79.   administration tool, rc scripts, boot scripts, boot sequence,
  80.   /etc/exports, exportfs.  After you have figured all that out you can
  81.   continue reading the next section of this HOWTO.  Or read more of this
  82.   section since some of the things I will say are relevant no matter
  83.   what kind of machine you use as server.
  84.  
  85.   Those of you still reading will need to set up a number of programs.
  86.  
  87.   3.3.  The portmapper
  88.  
  89.   The portmapper on Linux is called either portmap or rpc.portmap.  The
  90.   man page on my system says it is a "DARPA port to RPC program number
  91.   mapper".  It is the first security holes you'll open reading this
  92.   HOWTO.  Description of how to close one of the holes is in the
  93.   ``security section''.  Which I, again, urge you to read.
  94.  
  95.   Start the portmapper.  It's either called portmap or rpc.portmap and
  96.   it should live in the /usr/sbin directory (on some machines it's
  97.   called rpcbind).  You can start it by hand now, but it will need to be
  98.   started every time you boot your machine so you need to make/edit the
  99.   rc scripts.  Your rc scripts are explained more closely in the init
  100.   man page, they usually reside in /etc/rc.d, /etc/init.d or
  101.   /etc/rc.d/init.d.  If there is a script called something like inet
  102.   it's probably the right script to edit.  But, what to write or do is
  103.   outside the scope of this HOWTO.  Start portmap, and check that it
  104.   lives by running ps aux.  It does?  Good.
  105.  
  106.   3.4.  Mountd and nfsd
  107.  
  108.   The next programs we need running are mountd and nfsd.  But first
  109.   we'll edit another file.  /etc/exports this time.  Say I want the file
  110.   system /mn/eris/local which lives on the machine eris to be available
  111.   to the machine called apollon.  Then I'd put this in /etc/exports on
  112.   eris:
  113.  
  114.   ______________________________________________________________________
  115.   /mn/eris/local  apollon(rw)
  116.   ______________________________________________________________________
  117.  
  118.   The above line gives apollon read/write access to /mn/eris/local.
  119.   Instead of rw it could say ro which means read only (if you put
  120.   nothing it defaults to read only).  There are other options you can
  121.   give it, and I will discuss some security related ones later.  They
  122.   are all enumerated in the exports man page which you should have read
  123.   at least once in your life.  There are also better ways than listing
  124.   all the hosts in the exports file.  You can for example use net groups
  125.   if you are running NIS (or NYS) (NIS was known as YP), and always
  126.   specify domain wild cards and IP-subnets as hosts that are allowed to
  127.   mount something.  But you should consider who can get access to the
  128.   server in unauthorized ways if you use such blanket authorizations.
  129.  
  130.   Note: This exports file is not the same syntax that other Unixes use.
  131.   Most other Unixes use a format with options separated by commas (,)
  132.   and host lists colon (:) separated.  There is a ``tiny example further
  133.   on, in the optimization section''.  Except for Solaris 2 which is
  134.   completely different.
  135.  
  136.   Now we're set to start mountd (or maybe it's called rpc.mountd and
  137.   then nfsd (which could be called rpc.nfsd).  They will both read the
  138.   exports file.
  139.  
  140.   If you edit /etc/exports you will have to make sure nfsd and mountd
  141.   knows that the files have changed.  On most Unix systems the command
  142.   exportfs -av achives this.  Except for Solaris 2 which is completely
  143.   different.  Many Linux distributions lack a exportfs program.  If
  144.   you're exportfs-less you can install this script on your machine:
  145.  
  146.   ______________________________________________________________________
  147.   #!/bin/sh
  148.   killall -HUP /usr/sbin/rpc.mountd
  149.   killall -HUP /usr/sbin/rpc.nfsd
  150.   echo re-exported file systems
  151.   ______________________________________________________________________
  152.  
  153.   Save it in, say, /usr/sbin/exportfs, and don't forget to chmod a+rx
  154.   it.  Now, whenever you change your exports file, you run exportfs
  155.   after, as root.
  156.  
  157.   Now you should check that mountd and nfsd are running properly.  First
  158.   with rpcinfo -p.  It should show something like this:
  159.  
  160.   ______________________________________________________________________
  161.      program vers proto   port
  162.       100000    2   tcp    111  portmapper
  163.       100000    2   udp    111  portmapper
  164.       100005    1   udp    745  mountd
  165.       100005    1   tcp    747  mountd
  166.       100003    2   udp   2049  nfs
  167.       100003    2   tcp   2049  nfs
  168.   ______________________________________________________________________
  169.  
  170.   As you see the portmapper has announced it's services, and so has
  171.   mountd and nfsd.
  172.  
  173.   If you get rpcinfo: can't contact portmapper: RPC: Remote system error
  174.   - Connection refused or something similar instead then the portmapper
  175.   isn't running.  Fix it.  If you get No remote programs registered.
  176.   then either the portmapper doesn't want to talk to you, or something
  177.   is broken.  Kill nfsd, mountd, and the portmapper and try the ignition
  178.   sequence again.
  179.  
  180.   After checking that the portmapper reports the services you can check
  181.   with ps too.  The portmapper will continue to report the services even
  182.   after the programs that extend them have crashed.  So a ps check can
  183.   be smart if something seems broken.
  184.  
  185.   Of course, you will need to modify your system rc files to start
  186.   mountd and nfsd as well as the portmapper when you boot.  It is very
  187.   likely that the scripts already exist on your machine, you just have
  188.   to uncomment the critical section or activate it for the correct init
  189.   run levels.
  190.  
  191.   Man pages you should be familiar with now: portmap, mountd, nfsd, and
  192.   exports.
  193.  
  194.   Well, if you did everything exactly like I said you should you're all
  195.   set to start on the NFS client.
  196.  
  197.   4.  Setting up a NFS client
  198.  
  199.   First you will need a kernel with the NFS file system either compiled
  200.   in or available as a module.  This is configured before you compile
  201.   the kernel.  If you have never compiled a kernel before you might need
  202.   to check the kernel HOWTO and figure it out.  If you're using a very
  203.   cool distribution (like Red Hat) and you've never fiddled with the
  204.   kernel or modules on it (and thus ruined it ;-), nfs is likely
  205.   automagicaly available to you.
  206.  
  207.   You can now, at a root prompt, enter a appropriate mount command and
  208.   the file system will appear.  Continuing the example in the previous
  209.   section we want to mount /mn/eris/local from eris.  This is done with
  210.   this command:
  211.  
  212.   ______________________________________________________________________
  213.   mount -o rsize=1024,wsize=1024 eris:/mn/eris/local /mnt
  214.   ______________________________________________________________________
  215.  
  216.   (We'll get back to the rsize and wsize options.)  The file system is
  217.   now available under /mnt and you can cd there, and ls in it, and look
  218.   at the individual files.  You will notice that it's not as fast as a
  219.   local file system, but a lot more convenient than ftp.  If, instead of
  220.   mounting the file system, mount produces a error message like mount:
  221.   eris:/mn/eris/local failed, reason given by server: Permission denied
  222.   then the exports file is wrong, or you forgot to run exportfs after
  223.   editing the exports file.  If it says mount clntudp_create: RPC:
  224.   Program not registered it means that nfsd or mountd is not running on
  225.   the server.
  226.  
  227.   To get rid of the file system you can say
  228.  
  229.   ______________________________________________________________________
  230.   umount /mnt
  231.   ______________________________________________________________________
  232.  
  233.   To make the system mount a nfs file system upon boot you edit
  234.   /etc/fstab in the normal manner.  For our example a line such as this
  235.   is required:
  236.  
  237.   ______________________________________________________________________
  238.   # device      mountpoint     fs-type     options              dump fsckorder
  239.   eris:/mn/eris/local  /mnt    nfs        rsize=1024,wsize=1024 0    0
  240.   ______________________________________________________________________
  241.  
  242.   That's all there is too it, almost.  Read on please.
  243.  
  244.   4.1.  Optimizing NFS
  245.  
  246.   Normally, if no rsize and wsize options are specified NFS will read
  247.   and write in chunks of 4096 or 8192 bytes.  But some combinations of
  248.   Linux kernels and network cards cannot handle this, and it might not
  249.   be optimal, anyway.  So we'll want to experiment and find a rsize and
  250.   wsize that works and is as fast as possible.  You can test the speed
  251.   of your options with some simple commands.  Given the mount command
  252.   above and that you have write access to the disk you can do this to
  253.   test the sequential write performance:
  254.  
  255.   ______________________________________________________________________
  256.   time dd if=/dev/zero of=/mnt/testfile bs=16k count=4096
  257.   ______________________________________________________________________
  258.  
  259.   This creates a 64Mb file of zeroed bytes.  Do it a couple (5-10?)  of
  260.   times and average the times.  It is the `elapsed' or `wall clock' time
  261.   that's most interesting in this connection.  Then you can test the
  262.   read performance by reading back the file:
  263.  
  264.   ______________________________________________________________________
  265.   time dd if=/mnt/testfile of=/dev/null bs=16k
  266.   ______________________________________________________________________
  267.  
  268.   do that a couple of times and average.  Then umount, and mount again
  269.   with a larger rsize and wsize.  They should be multiples of 1024, and
  270.   probably not larger as large as 16384 bytes, since large blocks slows
  271.   down random accesses.  Directly after mounting with a larger size cd
  272.   into the mounted file system and do things like ls, explore the fs a
  273.   bit to make sure everything is as it should.  If the rsize/wsize is
  274.   too large the symptoms are very odd and not 100% obvious.  A typical
  275.   symptom is incomplete file lists when doing 'ls' with no error
  276.   messages.  Or reading files failing mysteriously with no error
  277.   messages.  After establishing that the given rsize/wsize works you can
  278.   do the speed tests again.  Different server platforms are likely to
  279.   have different optimal sizes.  SunOS and Solaris is reputedly a lot
  280.   faster with 4096 byte blocks than with anything else.
  281.  
  282.   Newer Linux kernels (since 1.3 sometime) perform read ahead for rsizes
  283.   larger or equal to the machine page size.  On Intel cpus the page size
  284.   is 4096 bytes.  Read ahead will significantly increase the NFS read
  285.   performance.  So on a Intel machine you will want 4096 byte rsize if
  286.   at all possible.
  287.  
  288.   Remember to edit /etc/fstab to reflect the rsize/wsize you found.
  289.  
  290.   A trick to increase NFS write performance is to disable synchronous
  291.   writes on the server.  The NFS specification states that NFS write
  292.   requests shall not be considered finished before the data written is
  293.   on a non-volatile medium (normally the disk).  This restricts the
  294.   write performance somewhat, and asynchronous writes will speed NFS
  295.   writes up.  The Linux nfsd has never done synchronous writes since the
  296.   Linux file system implementation does not lend itself to this, but on
  297.   non-Linux servers you can increase the performance this way with this
  298.   in your exports file:
  299.  
  300.   ______________________________________________________________________
  301.   /dir    -async,access=linuxbox
  302.   ______________________________________________________________________
  303.  
  304.   or something similar.  Please refer to the exports man page on the
  305.   machine in question.
  306.  
  307.   4.2.  Other options
  308.  
  309.   There are some other options you should consider adding at once.  The
  310.   govern the way the NFS client handles a server crash.  There are two
  311.   distinct failure modes:
  312.  
  313.      soft
  314.         The NFS client will report and error to the process accessing a
  315.         file on a NFS mounted file system.  Some programs can handle
  316.         this with composure, most won't.  I cannot recommend using this
  317.         setting.
  318.  
  319.      hard
  320.         The program accessing a file on a NFS mounted file system will
  321.         hang when the server crashes.  The process cannot be interrupted
  322.         or killed unless you also specify intr.  When the NFS server is
  323.         back online the program will continue undisturbed from where it
  324.         were.  This is probably what you want.  I recommend using
  325.         hard,intr on all NFS mounted file systems.
  326.  
  327.   Picking up the previous example, assuming that you found 4096 bytes to
  328.   be optimal read/write sizes, this is now your fstab entry:
  329.  
  330.   ______________________________________________________________________
  331.   # device      mountpoint     fs-type    options                  dump fsckorder
  332.   eris:/mn/eris/local  /mnt    nfs        rsize=4096,wsize=4096,hard,intr 0 0
  333.   ______________________________________________________________________
  334.  
  335.   5.  Security and NFS
  336.  
  337.   I am by no means a computer security expert.  But I've been around the
  338.   block so I have a little advice for the security conscious.  But be
  339.   warned: This is by no means a complete list of NFS related problems
  340.   and if you think you're safe once you're read and implemented all this
  341.   I have a bridge I want to sell you.
  342.  
  343.   This section is probably of no concern if you are on a closed network
  344.   where you trust all the users, and no-one you don't trust can get
  345.   access to machines on the network. I.e., there should be no way to
  346.   dial into the network, and it should in no way be connected to other
  347.   networks where you don't trust everyone using it as well as the
  348.   security.  Do you think I sound paranoid?  I'm not at all paranoid.
  349.   This is just basic security advice.  And remember, the things I say
  350.   here is just the start of it.  A secure site needs a diligent and
  351.   knowledgeable admin that knows where to find information about current
  352.   and potential security problems.
  353.  
  354.   NFS has a basic problem in that the client, if not told otherwise,
  355.   will trust the NFS server and vice versa.  This can be bad.  That
  356.   means that if the server's root account is broken into it can be quite
  357.   easy to break into the client's root account as well.  And vice versa.
  358.   There are a couple of coping strategies for this, which we'll get back
  359.   to.
  360.  
  361.   Something you should read is the CERT advisories on NFS, most of the
  362.   text below deals with issues CERT has written advisories about.  See
  363.   ftp.cert.org/01-README for a up to date list of CERT advisories.  Here
  364.   are some NFS related advisories:
  365.  
  366.   ______________________________________________________________________
  367.   CA-91:21.SunOS.NFS.Jumbo.and.fsirand                            12/06/91
  368.        Vulnerabilities concerning Sun Microsystems, Inc. (Sun) Network
  369.        File System (NFS) and the fsirand program.  These vulnerabilities
  370.        affect SunOS versions 4.1.1, 4.1, and 4.0.3 on all architectures.
  371.        Patches are available for SunOS 4.1.1.  An initial patch for SunOS
  372.        4.1 NFS is also available. Sun will be providing complete patches
  373.        for SunOS 4.1 and SunOS 4.0.3 at a later date.
  374.  
  375.   CA-94:15.NFS.Vulnerabilities                                    12/19/94
  376.        This advisory describes security measures to guard against several
  377.        vulnerabilities in the Network File System (NFS). The advisory was
  378.        prompted by an increase in root compromises by intruders using tools
  379.        to exploit the vulnerabilities.
  380.  
  381.   CA-96.08.pcnfsd                                                 04/18/96
  382.        This advisory describes a vulnerability in the pcnfsd program (also
  383.        known as rpc.pcnfsd). A patch is included.
  384.   ______________________________________________________________________
  385.  
  386.   5.1.  Client Security
  387.  
  388.   On the client we can decide that we don't want to trust the server too
  389.   much a couple of ways with options to mount.  For example we can
  390.   forbid suid programs to work off the NFS file system with the nosuid
  391.   option.  This is a good idea and you should consider using this with
  392.   all NFS mounted disks.  It means that the server's root user cannot
  393.   make a suid-root program on the file system, log in to the client as a
  394.   normal user and then use the suid-root program to become root on the
  395.   client too.  We could also forbid execution of files on the mounted
  396.   file system altogether with the noexec option.  But this is more
  397.   likely to be impractical than nosuid since a file system is likely to
  398.   at least contain some scripts or programs that needs to be executed.
  399.   You enter these options in the options column, with the rsize and
  400.   wsize, separated by commas.
  401.  
  402.   5.2.  Server security: nfsd
  403.  
  404.   On the server we can decide that we don't want to trust the client's
  405.   root account.  We can do that by using the root_squash option in
  406.   exports:
  407.  
  408.   ______________________________________________________________________
  409.   /mn/eris/local apollon(rw,root_squash)
  410.   ______________________________________________________________________
  411.  
  412.   Now, if a user with UID 0 on the client attempts to access (read,
  413.   write, delete) the file system the server substitutes the UID of the
  414.   servers `nobody' account.  Which means that the root user on the
  415.   client can't access or change files that only root on the server can
  416.   access or change.  That's good, and you should probably use
  417.   root_squash on all the file systems you export.  "But the root user on
  418.   the client can still use 'su' to become any other user and access and
  419.   change that users files!" say you.  To which the answer is: Yes, and
  420.   that's the way it is, and has to be with Unix.  This has one important
  421.   implication: All important binaries and files should be owned by root,
  422.   and not bin or other non-root account, since the only account the
  423.   clients root user cannot access is the servers root account.  In the
  424.   nfsd man page there are several other squash options listed so that
  425.   you can decide to mistrust whomever you (don't) like on the clients.
  426.   You also have options to squash any UID and GID range you want to.
  427.   This is described in the Linux nfsd man page.
  428.  
  429.   Another important thing is to ensure that nfsd checks that all it's
  430.   requests comes from a privileged port.  If it accepts requests from
  431.   any old port on the client a user with no special privileges can run a
  432.   program that's is easy to obtain over the Internet. It talks nfs
  433.   protocol and will claim that the user is anyone the user wants to be.
  434.   Spooky.  The Linux nfsd does this check by default, on other OSes you
  435.   have to enable this check yourself.  This should be described in the
  436.   nfsd man page for the OS.
  437.  
  438.   Another thing.  Never export a file system to 'localhost' or
  439.   127.0.0.1.  Trust me.
  440.  
  441.   5.3.  Server security: the portmapper
  442.  
  443.   The basic portmapper, in combination with nfsd has a design problem
  444.   that makes it possible to get to files on NFS servers without any
  445.   privileges.  Fortunately the portmapper Linux uses is relatively
  446.   secure against this attack, and can be made more secure by configuring
  447.   up access lists in two files.
  448.  
  449.   First we edit /etc/hosts.deny.  It should contain the line
  450.  
  451.   ______________________________________________________________________
  452.   portmap: ALL
  453.   ______________________________________________________________________
  454.  
  455.   which will deny access to everyone.  That's a bit drastic perhaps, so
  456.   we open it again by editing /etc/hosts.allow.  But first we need to
  457.   figure out what to put in it.  It should basically list all machines
  458.   that should have access to your portmapper.  On a run of the mill
  459.   Linux system there are very few machines that need any access for any
  460.   reason.  The portmapper administrates nfsd, mountd, ypbind/ypserv,
  461.   pcnfsd, and 'r' services like ruptime and rusers.  Of these only nfsd,
  462.   mountd, ypbind/ypserv and perhaps pcnfsd are of any consequence.  All
  463.   machines that needs to access services on your machine should be
  464.   allowed to do that.  Let's say that your machines address is
  465.   129.240.223.254 and that it lives on the subnet 129.240.223.0 should
  466.   have access to it (those are terms introduced by the networking HOWTO,
  467.   go back and refresh your memory if you need to).  Then we write
  468.  
  469.   ______________________________________________________________________
  470.   portmap: 129.240.223.0/255.255.255.0
  471.   ______________________________________________________________________
  472.  
  473.   in hosts.allow.  This is the same as the network address you give to
  474.   route and the subnet mask you give to ifconfig.  For the device eth0
  475.   on this machine ifconfig should show
  476.  
  477.   ______________________________________________________________________
  478.   eth0      Link encap:10Mbps Ethernet  HWaddr 00:60:8C:96:D5:56
  479.             inet addr:129.240.223.254  Bcast:129.240.223.255  Mask:255.255.255.0
  480.             UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
  481.             RX packets:360315 errors:0 dropped:0 overruns:0
  482.             TX packets:179274 errors:0 dropped:0 overruns:0
  483.             Interrupt:10 Base address:0x320
  484.   ______________________________________________________________________
  485.  
  486.   and netstat -rn should show
  487.  
  488.   ______________________________________________________________________
  489.   Kernel routing table
  490.   Destination     Gateway         Genmask         Flags Metric Ref Use    Iface
  491.   129.240.223.0   0.0.0.0         255.255.255.0   U     0      0   174412 eth0
  492.   ______________________________________________________________________
  493.  
  494.   (Network address in first column).
  495.  
  496.   The hosts.deny and hosts.allow files are described in the manual pages
  497.   of the same names.
  498.  
  499.   IMPORTANT: Do not put anything but IP NUMBERS in the portmap lines of
  500.   these files.  Host name lookups can indirectly cause portmap activity
  501.   which will trigger host name lookups which can indirectly cause
  502.   portmap activity which will trigger...
  503.  
  504.   The above things should make your server tighter.  The only remaining
  505.   problem (Yeah, right!) is someone breaking root (or boot MS-DOS) on a
  506.   trusted machine and using that privilege to send requests from a
  507.   secure port as any user they want to be.
  508.  
  509.   5.4.  NFS and firewalls
  510.  
  511.   It's a very good idea to firewall the nfs and portmap ports in your
  512.   router or firewall.  The nfsd operates at port 2049, both udp and tcp
  513.   protocols.  The portmapper at port 111, tcp and udp, and mountd at
  514.   port 745 and and 747, tcp and udp.  Normally.  You should check the
  515.   ports with the rpcinfo -p command.
  516.  
  517.   If on the other hand you want NFS to go through a firewall there are
  518.   options for newer nfsds and mountds to make them use a specific
  519.   (nonstandard) port which can be open in the firewall.
  520.  
  521.   5.5.  Summary
  522.  
  523.   If you use the hosts.allow/deny, root_squash, nosuid and privileged
  524.   port features in the portmapper/nfs software you avoid many of the
  525.   presently known bugs in nfs and can almost feel secure about that at
  526.   least. But still, after all that: When an intruder has access to your
  527.   network, s/he can make strange commands appear in your .forward or
  528.   mailbox file when /home or /var/spool/mail are mounted over NFS. For
  529.   the same reason, you should never access your PGP private key over
  530.   nfs.  Or at least you should know the risk involved.  And now you know
  531.   a bit of it.
  532.  
  533.   NFS and the portmapper makes up a complex subsystem and therefore it's
  534.   not totally unlikely that new bugs will be discovered, either in the
  535.   basic design or the implementation we use.  There might even be holes
  536.   known now, which someone is abusing.  But that's life.  To keep
  537.   abreast of things like this you should at least read the newsgroups
  538.   comp.os.linux.announce and comp.security.announce at a absolute
  539.   minimum.
  540.  
  541.   6.  FAQs
  542.  
  543.   This is the FAQ section.  Most of it was written by Alan Cox.
  544.  
  545.   1. When I try to mount a file system I get
  546.  
  547.          can't register with portmap: system error on send
  548.  
  549.   You are probably using a Caldera system.  There is a bug in the rc
  550.   scripts.  Please contact Caldera to obtain a fix.
  551.  
  552.   2. Why can't I execute a file after copying it to the NFS server?
  553.  
  554.      The reason is that nfsd caches open file handles for performance
  555.      reasons (remember, it runs in user space). While nfsd has a file
  556.      open (as is the case after writing to it), the kernel won't allow
  557.      you to execute it. Nfsds newer than  spring 95 release open files
  558.      after a few seconds, older ones would cling to them for days.
  559.  
  560.   3. My NFS files are all read only
  561.  
  562.      The Linux NFS server defaults to read only. RTFM the ``exports''
  563.      and nfsd manual pages. You will need to alter /etc/exports.
  564.  
  565.   4. I mount from a linux nfs server and while ls works I can't read or
  566.      write files.
  567.  
  568.      On older versions of Linux you must mount a NFS servers with
  569.      rsize=1024,wsize=1024.
  570.  
  571.   5. I mount from a Linux NFS server with a block size of between
  572.      3500-4000 and it crashes the Linux box regularly
  573.  
  574.      Basically don't do it then.
  575.  
  576.   6. Can Linux do NFS over TCP
  577.  
  578.      No, not at present.
  579.   7. I get loads of strange errors trying to mount a machine from a
  580.      Linux box.
  581.  
  582.      Make sure your users are in 8 groups or less. Older servers require
  583.      this.
  584.  
  585.   8. When I reboot my machine it sometimes hangs when trying to unmount
  586.      a hung NFS server.
  587.  
  588.      Do not unmount NFS servers when rebooting or halting, just ignore
  589.      them, it will not hurt anything if you don't unmount them.  The
  590.      command is umount -avt nonfs.
  591.  
  592.   9. Linux NFS clients are very slow when writing to Sun & BSD systems
  593.  
  594.      NFS writes are normally synchronous (you can disable this if you
  595.      don't mind risking losing data). Worse still BSD derived kernels
  596.      tend to be unable to work in small blocks. Thus when you write 4K
  597.      of data from a Linux box in the 1K packets it uses BSD does this
  598.  
  599.                read 4K page
  600.                alter 1K
  601.                write 4K back to physical disk
  602.                read 4K page
  603.                alter 1K
  604.                write 4K page back to physical disk
  605.                etc..
  606.  
  607.   Better systems don't have this problem. The Linux client is however
  608.   quite slow anyway.
  609.  
  610.   10.
  611.      I've heard NFS is not secure is this true?
  612.  
  613.      Yes, totally. Running NFS in an uncontrolled environment is rather
  614.      like leaving your front door open, painting `On holiday' on your
  615.      house and posting maps to every known criminal...  In a fairly
  616.      secure environment or when you can recover data from stupid misuse
  617.      its pretty much OK.  The worst someone can easily do is alter all
  618.      the files on an NFS mounted disk and/or crash the machine. So long
  619.      as you don't mount your system files writable you should be vaguely
  620.      safe.
  621.  
  622.   11.
  623.      Why do we use NFS at all then?
  624.  
  625.      Because it's the only uniformly supported file sharing protocol for
  626.      Unix.  And because it works, mostly.
  627.  
  628.   12.
  629.      How do I stop things hanging when a server goes down
  630.  
  631.      There are three main NFS behaviors on server down:
  632.  
  633.      soft
  634.         Your NFS client will report an error to the process concerned if
  635.         an NFS server doesn't answer after a few retries.  If you want
  636.         to use this you should check that your software handles it
  637.         gracefully.  I would not recommend using this setting.
  638.  
  639.      hard
  640.         Your NFS client will try forever unless killed off.  Operations
  641.         will be restarted when the NFS server recovers or reboots.
  642.  
  643.      hard,intr
  644.         As hard but Ctrl-C will interrupt a hung process. In a few cases
  645.         - notably nfs mounted /usr/spool/mail disks this doesn't help as
  646.         the shell will be ignoring Ctrl-C when it checks you have
  647.         mail...  I recommend this setting for all NFS mounts, including
  648.         the mail spool.
  649.  
  650.   7.  PC-NFS
  651.  
  652.   Some things are best left undocumented :-) But you definitely want to
  653.   run pcnfsd, if you want to run PC-NFS.  Good luck.
  654.  
  655.   I know, that's not exactly friendly, but I'm not familiar with PC NFS.
  656.   If you are please contact me so we can maybe get in something about
  657.   PC-NFS here.
  658.  
  659.