Ubuntu下tftp和nfs的安装和配置

来源:互联网 发布:jsp javascript 编辑:程序博客网 时间:2024/05/16 01:39

一、TFTP

1、安装相关软件包:

sudo apt-get install tftp tftpd xinetd

2、建立配置文件
      在/etc/xinetd.d/下建立一个配置文件tftp
      sudo vi tftp
      输入以下内容:
      service tftp
      {

   socket_type = dgram
       protocol = udp
       wait = yes
       user = root
       server = /usr/sbin/in.tftpd
       server_args = -s /tftpboot
       disable = no
       per_source = 11
       cps = 100 2
       flags = IPv4

}
    保存退出

3、建立Ubuntu tftp服务文件目录(上传文件与下载文件的位置),并且更改其权限

  cd
      sudo mkdir /tftpboot
      sudo chmod 777 /tftpboot

4、重新启动服务
     sudo /etc/init.d/xinetd restart
     服务已经安装完成,下面可以对其进行一下测试。

 在tftpboot目录下有一个测试文件test.txt
     $tftp 127.0.0.1                      
    tftp> put test.txt
     Sent 1018 bytes in 0.0 seconds
    tftp> get test.txt
    Received 1018 bytes in 0.1 seconds
    tftp> quit

二、NFS

1、安装相关软件包:

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

2、配置(nfs允许挂载的目录及权限,在文件/etc/exports中进行定义)

sudo vi /etc/exports

添加:/nfs *(rw,sync,no_root_squash)

各字段含义如下:
          /nfs:要共享的目录
         * :允许所有的网段访问
        rw :读写权限
        sync:资料同步写入内在和硬盘
        no_root_squash:nfs客户端共享目录使用者权限

3、重启服务:
         sudo /etc/init.d/portmap restart                    <---重启portmap
         sudo /etc/init.d/nfs-kernel-server restart      <---重启nfs服务
         showmount -e                                              <---显示共享出的目录

4、挂载

 cd

 sudo mkdir nfsdir

 sudo chmod 777 nfsdir

 sudo mount -t nfs 127.0.0.1:/nfsdir /mnt

 其中,nfsdir是共享主机目录,mnt是挂载目录。

原创粉丝点击