Chinaunix首页 | 论坛 | 博客
  • 博客访问: 130492
  • 博文数量: 43
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 175
  • 用 户 组: 普通用户
  • 注册时间: 2015-04-10 12:33
文章存档

2016年(9)

2015年(34)

我的朋友

分类: LINUX

2015-11-25 14:12:09

 

CenOS 7 安装配置Samba服务

 7988人阅读 评论(1)  举报
 分类:
 
Linux操作(6) 

参考

实现windows 7与centos 7的文件夹共享,本人的是windows7系统下安装的centos7 虚拟机,桥接模式

不知是不是因为VM的原因,共享文件夹不可用,所以迫不得已使用samba共享,以下是具体步骤,个人验证可用

1、编辑C:\Windows\System32\drivers\etc\hosts

   

  1. # Copyright (c) 1993-2009 Microsoft Corp.  
  2. #  
  3. # This is a sample HOSTS file used by Microsoft TCP/IP for Windows.  
  4. #  
  5. # This file contains the mappings of IP addresses to host names. Each  
  6. # entry should be kept on an individual line. The IP address should  
  7. # be placed in the first column followed by the corresponding host name.  
  8. # The IP address and the host name should be separated by at least one  
  9. # space.  
  10. #  
  11. # Additionally, comments (such as these) may be inserted on individual  
  12. # lines or following the machine name denoted by a '#' symbol.  
  13. #  
  14. # For example:  
  15. #  
  16. #      102.54.94.97     rhino.acme.com          # source server  
  17. #       38.25.63.10     x.acme.com              # x client host  
  18.   
  19. # localhost name resolution is handled within DNS itself.  
  20. #   127.0.0.1       localhost  
  21. #   ::1             localhost  
  22.   
  23. 127.0.0.1 genuine.microsoft.com  
  24. 127.0.0.1 mpa.one.microsoft.com  
  25. 127.0.0.1 sls.microsoft.com  
  26. 192.168.10.187 localhost.localdomain centos  
  27. #ip地址是centos的ip,localhost.localdomain表示centos的hostname,最后一个参数centos表示centos的别名,即可以通过\\centos访问centos的共享文件夹  


直接打开hosts文件是无法修改的,有两种解决方法:

一是以管理员权限打开记事本程序,然后在记事本程序里打开hosts文件,二是把hosts文件拷贝出来修改后再进行覆盖


安装samba服务相关包


yum install samba samba-client samba-common


查看相关包
~#: rpm -qa| grep samba
samba-common-4.1.1-37.el7_0.x86_64
samba-4.1.1-37.el7_0.x86_64
samba-libs-4.1.1-37.el7_0.x86_64
samba-client-4.1.1-37.el7_0.x86_64




修改smb.conf,最好先备份原文件,以防修改不正确导致smb无法执行

vi /etc/samba/smb.conf


  1. [global]  
  2. workgroup = WORKGROUP  
  3. server string = Samba Server %v  
  4. netbios name = centos  
  5. security = user  
  6. map to guest = bad user  
  7. dns proxy = no  
  8. #============================ Share Definitions ==============================   
  9. [Anonymous]  
  10. path = /samba/anonymous  
  11. browsable =yes  
  12. writable = yes  
  13. guest ok = yes  
  14. read only = no   




执行以下命令,启动samba服务

mkdir -p /samba/anonymous
systemctl enable smb.service
systemctl enable nmb.service
systemctl restart smb.service
systemctl restart nmb.service


3、 跳过防火墙

 一种方法是关闭防火墙

 systemctl stop firewalld.service

setenforce 0

二方法是添加规则

firewall-cmd --permanent --zone=public --add-service=samba


firewall-cmd --reload



4 输入\\centos 即可看到共享文件了,so happy~




#ip地址是centos的ip,localhost.localdomain表示centos的hostname,最后一个参数centos表示centos的别名,即可以通过\\centos访问centos的共享文件夹
阅读(1272) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~