Ubuntu 启动NFS Server

安装: 

#sudo apt-get install nfs-common
#sudo apt-get install nfs-kernel-server

修改/etc/exports文件,加入如下几行: 

格式: [共享目录]      [主机名或IP](参数,参数)   
/home/armnfs    192.168.1.6(rw)

这样解释一下:armnfs是我在home下新建的目录,用来存放目标文件系统的,也就是共享目录。共享给谁呢?就是后面那个IP地址了。它拥有的权限是 可读可写。  启动NFS: 

#/etc/init.d/nfs-kernel-server start
另外两个有用的参数是stop,restart


客户端挂载NFS服务器上的共享文件夹: 

#mount [server IP]:/[share dir]  [local mount poin]

例如: 
#mount 192.168.1.5:/home/armnfs  /mnt/arm

就可以在客户机上通过访问/mnt/arm访问服务器上的文件夹了。 

2)配置/etc/hosts.deny

                                      $ sudo gedit /etc/hosts.deny

(禁止任何host(主机)能和你的NFS服务器进行NFS连接),加入:

### NFS DAEMONS

portmap:ALL

lockd:ALL

mountd:ALL

rquotad:ALL

statd:ALL

3)配 置/etc/hosts.allow

                                     $ sudo gedit /etc/hosts.allow

允许那些你想要的主机和你的NFS服务器建立连接。下列步骤将允许任何IP地址以192.168.1开头的主机(连接到NFS服务器上),也可以指定特定的IP地址。

### NFS DAEMONS

portmap: 192.168.1.

lockd: 192.168.1.

rquotad: 192.168.1.

mountd: 192.168.1.

statd: 192.168.1.

起用保护机制

    上面设置了只要在192.168.1.*这个网段的所有IP地址用户都可以访问共享目录,但我只想让一个IP地址访问,比如 192.168.1.101那么就可以这样设置了。

可以通过设定/etc/hosts.deny和/etc/hosts.allow文件来限制网络服务的存取权限。

***/etc/hosts.deny***

portmap:ALL

lockd:ALL

mountd:ALL

rquotad:ALL

statd:ALL

***/etc/hosts.allow***

portmap:192.168.1.101

lockd:192.168.1.101

mountd:192.168.1.101

rquotad:192.168.1.101

statd:192.168.1.101

            同时使用这两个文件就会使得只有ip为192.168.1.101的机器使用NFS服务。你的target board的ip地址设定为192.168.1.101,这样就可以了。

    /etc/hosts.deny 和 /etc/hosts.allow 设置对portmap的访问. 采用这两个配置文件有点类似"mask"的意思. 现在/etc/hosts.deny中禁止所有用户对portmap的访问. 再在/etc/hosts.allow 中允许某些用户对portmap的访问。

posted @ 2014-05-19 20:18  jeffkuang  阅读(195)  评论(0)    收藏  举报