CentOS 6.2 x64下配置samba服务器

一、安装前准备
操作系统:CentOS6.2x64
samba_server_ip: 192.168.20.239
用户:root,alsww
目录及达到效果:/home/public:共享目录,root和alsww账户都完全控制;/home/alsww:受限目录, alsww用户只读,root用户可以完全控制。

1、使用Samba服务器需要防火墙开放以下端口
vi /etc/sysconfig/iptables   #配置防火墙端口
-A INPUT -m state --state NEW -m tcp -p tcp --dport 137 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 138 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 139 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 445 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 137 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 138 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 139 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 445 -j ACCEPT
/etc/init.d/iptables restart     #重启防火墙,使规则生效

2、关闭SELinux
vi /etc/selinux/config
#SELINUX=enforcing     #注释掉
#SELINUXTYPE=targeted  #注释掉
SELINUX=disabled  #增加

shutdown -r now重启系统。


二、安装Samba
1、检查Samba服务包是否已安装
   rpm -qa | grep samba
   samba-winbind-clients-3.5.4-68.el6.i686
   samba4-libs-4.0.0-23.alpha11.el6.i686
   samba-common-3.5.4-68.el6.i686
   samba-client-3.5.4-68.el6.i686
   说明samba已经安装,如果没有安装,运行下面命令安装
   yum install samba

2、配置samba
   chkconfig smb on  #设置 Samba开机自动启动
   service smb start      #启动Samba服务
   chkconfig nmb on   #设置Samba别名服务自动启动
   service  nmb start   #启动Samba别名服务
   /etc/init.d/smb restart  #重启
   /etc/init.d/smb stop    #停止
   /etc/init.d/nmb restart  #重启
   /etc/init.d/nmb stop   #停止
备份:cp /etc/samba/smb.conf  /etc/samba/smb.confbak
恢复:cp /etc/samba/smb.confbak  /etc/samba/smb.conf

vi /etc/samba/smb.conf

[global]
        netbios name = SAMBA_SERVER
        server string = Samba Server Version %v
        log file = /var/log/samba/log.%m
        max log size = 50
        hosts allow = 192.168.10., 192.168.20., 127.        ###允许10,20网段和本机访问
        cups options = raw
        security = users                                    ###设置密码访问
        workgroup = WORKGROUP

[homes]
        comment = Home Directories
        read only = No
        browseable = No

[printers]
        comment = All Printers
        path = /var/spool/samba
        printable = Yes
        browseable = No

[alsww]
        comment = alsww
        path = /home/alsww
        valid users = alsww,root
        read only = No
        public = no
        read list = alsww                                       ###只读账户
        write list = root                                       ###可写账户
[public]
        comment = public
        path = /home/public
        valid users = alsww,root
        read only = No
        public = no
        writable = yes
#        create mode = 0555                                       ###创建后不能删除文件

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/5350af4396d290aaa385ca7db5be1ace.html