nfs的基本用法

xiaoxiao2021-02-28  76

#######nfs####

1.启用服务

yum install nfs-utils -y    ##安装服务 systemctl enable nfs-server systemctl start nfs-server    ##启动服务 systemctl start firewalld    ##开启火墙,并进行策略配置 firewall-cmd --permanent --add-service=nfs firewall-cmd --permanent --add-service=rpc-bind firewall-cmd --permanent --add-service=mountd firewall-cmd --reload        ##刷新火墙策略 [root@localhost ~]# firewall-cmd --list-all public (default, active)   interfaces: eth0 eth1   sources:   services: dhcpv6-client mountd nfs rpc-bind ssh   ports:   masquerade: no   forward-ports:   icmp-blocks:   rich rules: 服务端测试结果: showmount -e 172.25.254.106 Export list for 172.25.254.106:

2.共享目录

mkdir /public               ##建立共享目录 chmod 777 /public

vim /etc/exports             ##编辑配置文件,格式如下

共享的系统目录    共享方式 /public        *(sync)            ##该目录共享给所有人,且数据同步 /public        172.25.6.0/24(sync)    ##该目录共享给172.25.6.0/24网段 /public        *.example.com(sync)    ##共享给example.com域的所有主机 /public        172.25.6.11(ro,sync) 172.25.6.250(rw,sync)    ##共享给11是只读,250是读写 /public        *(sync,no_root_squash)    ##客户端使用root挂载,执行操作身份为root

/public        *(sync,anonuid=1001,anongid=1000) #对共享目录执行操作以1001为uid,1000为gid

测试结果:

3.保护nfs的证书认证

在server端
[root@server6 ~]# yum install sssd krb5-workstation authconfig-gtk -y [root@server6 ~]# authconfig-gtk   ##编辑配置

开启kerberos认证,得到ldap用户

[root@server6 ~]# wget http://172.25.254.254/pub/keytabs/server6.keytab -O /etc/krb5.keytab        ##获得证书 [root@server6 ~]# ktutil    ##测试证书下载是否正确 ktutil:  rkt /etc/krb5.keytab

ktutil:  list

[root@server6 ~]# systemctl restart nfs-secure-server [root@server6 ~]# systemctl enable nfs-secure-server [root@server6 ~]# mkdir /public [root@server6 ~]# touch /public/hello{1..2} [root@server6 ~]# vim /etc/exports        ##编辑nfs配置文件 [root@server6 ~]# exportfs -rv            ##使配置生效

exporting *:/public

在desktop端
[root@desktop6 ~]# yum install sssd krb5-workstation authconfig-gtk -y [root@desktop6 ~]# authconfig-gtk [root@desktop6 ~]# wget http://172.25.254.254/pub/keytabs/desktop6.keytab -O /etc/krb5.keytab [root@desktop6 ~]# ktutil ktutil:  rkt /etc/krb5.keytab ktutil:  list [root@desktop6 ~]# systemctl restart nfs-secure [root@desktop6 ~]# systemctl enable nfs-secure
转载请注明原文地址: https://www.6miu.com/read-94807.html

最新回复(0)