5、SAMBA服务一:参数详解

①:SAMBA服务一:参数详解

②:SAMBA服务二:配置实例

一、SAMBA简介

  • samba指SMB(Server Message Block,服务器信息块)协议在网络上的计算机之间远程共享Linux文件和打印服务;

  • samba协议是建立在NetBIOSsom(Network Basic Input/Output System,网路基本输入/输出系统)协议之上应用协议,基于TCP 138和139两个端口的服务;

  • Samba的核心是smbd 和 nmbd两个守护进程,在服务启动时,持续运行。smba 和 nmbd使用的信息全部保存在/etc/samba/smb.conf文件中

  • smba进程的作用是为使用该软件包资源的客户机与Linux服务器进行协商,nabd进程作用是让客户端能浏览Linux服务器的共享资源

  

二、Samba服务区安装和配置

5.2.1:安装Samba服务器软件包

samba-common-4.8.3-4.el7.noarch     # 存放服务器和客户端通用的工具和宏文件的软件包,该软件包必须安装在服务器和客户端

samba-common-libs-4.8.3-4.el7.x86_64

samba-4.8.3-4.el7.x86_64           # samba服务主程序软件包,必须安装在服务器端

samba-client-libs-4.8.3-4.el7.x86_64      # samba客户端软件包,该软件必须安装在客户端

samba-common-tools-4.8.3-4.el7.x86_64

samba-libs-4.8.3-4.el7.x86_64        # samba库

  [root@C1 ~]#yum -y -q install samba 

5.2.2:/etc/samba/smb.conf文件详解

  • samba服务器的主配置文件是/etc/samba/smb.conf文件,该配置文件由Global Settings(全局设置) 和 Share Definitions (共享定义)两部分组成

  • 在/etc/samba/smb.conf文件中,以#开头的是注释行,语句不执行;以;开头的是参数示例,这样的语句不被执行
#======================= Global Settings =====================================
//第一部分:设置全局参数内容
[global]
# ----------------------- Network Related Options -------------------------
//设置网络关系选项
        workgroup = MYGROUP
        server string = Samba Server Version %v

;       netbios name = MYSERVER

;       interfaces = lo eth0 192.168.12.2/24 192.168.13.2/24 
;       hosts allow = 127. 192.168.12. 192.168.13.

# --------------------------- Logging Options -----------------------------
//设置服务器日志选项
        # logs split per machine
        log file = /var/log/samba/log.%m
        # max 50KB per log file, then rotate
        max log size = 50

# ----------------------- Standalone Server Options ------------------------
//设置标准服务器选项

        security = share
        passdb backend = tdbsam

# ----------------------- Domain Members Options ------------------------
//设置域成员选项
;       security = domain
;       passdb backend = tdbsam
;       realm = MY_REALM
;       password server = <NT-Server-Name>

# ----------------------- Domain Controller Options ------------------------
//设置域控制器选项
;       security = user
;       passdb backend = tdbsam

;       domain master = yes 
;       domain logons = yes

        # the login script name depends on the machine name
;       logon script = %m.bat
        # the login script name depends on the unix user used
;       logon script = %u.bat
;       logon path = \%LProfiles\%u
        # disables profiles support by specifing an empty path
;       logon path =          

;       add user script = /usr/sbin/useradd "%u" -n -g users
;       add group script = /usr/sbin/groupadd "%g"
;       add machine script = /usr/sbin/useradd -n -c "Workstation (%u)" -M -d /nohome -s /bin/false "%u"
;       delete user script = /usr/sbin/userdel "%u"
;       delete user from group script = /usr/sbin/userdel "%u" "%g"
;       delete group script = /usr/sbin/groupdel "%g"

# ----------------------- Browser Control Options ----------------------------
//设置浏览器选项
;       local master = no
;       os level = 33
;       preferred master = yes


#----------------------------- Name Resolution -------------------------------
//设置名称解析

;       wins support = yes
;       wins server = w.x.y.z
;       wins proxy = yes

;       dns proxy = yes


# --------------------------- Printing Options -----------------------------
//设置打印机选项
        load printers = yes
        cups options = raw

;       printcap name = /etc/printcap
        #obtain list of printers automatically on SystemV
;       printcap name = lpstat
;       printing = cups

# --------------------------- Filesystem Options ---------------------------
//设置文件系统选项

;       map archive = no
;       map hidden = no
;       map read only = no
;       map system = no
;       store dos attributes = yes

#============================ Share Definitions ==============================
//第二部分:设置文件共享和打印共享资源

//文家共享
[homes]
        comment = Home Directories
        browseable = no
        writable = yes
;       valid users = %S
;       valid users = MYDOMAIN\%S

//打印共享
[printers]
        comment = All Printers
        path = /var/spool/samba
        browseable = no
        guest ok = no
        writable = no
        printable = yes

//文件共享
;       [netlogon]
;       comment = Network Logon Service
;       path = /var/lib/samba/netlogon
;       guest ok = yes
;       writable = no
;       share modes = no


//文件共享
;       [Profiles]
;       path = /var/lib/samba/profiles
;       browseable = no
;       guest ok = yes

//文件共享
;       [public]
;       comment = Public Stuff
;       path = /home/samba
;       public = yes
;       writable = yes
;       printable = no
;       write list = +staff

        [public]
        comment = Public Stuff
        path = /var/xuan/public
        public = yes
        writable = no
        printable = no

下面分别从变量、全局参数设置和共享定义设置三方面了解/etc/samba/smb.conf文件

  1.变量

①客户端变量

-----------------------------------------------------------------------------

%a | 客户端的体系结构(例如Samba,NT,Win98,或者Unknown)

%I | 客户端的IP地址(例如:192.168.220.100)

%m | 客户端的NetBios名

%M | 客户端的DNS名

------------------------------------------------------------------------------

②用户变量

------------------------------------------------------------------------------

%g  %u的基本组

%G  %U的基本组

%H  %u的Home目录

%u 当前的unix用户名

%U  被请求的客户端用户名(不总是被samba使用)

------------------------------------------------------------------------------

③共享变量

------------------------------------------------------------------------------

%p  如果和%p不同,automounter的路径对应共享的根目录

%P  当前共享的根目录

%S  但前共享的名称

-------------------------------------------------------------------------------

④服务器变量

-------------------------------------------------------------------------------

%d  当前服务器进程的ID

%h  Samba服务器的DNS主机名

%L  Samba服务器的netbios名

%N  Home目录服务器,来自automount的映射

%v  samba版本

-------------------------------------------------------------------------------

⑤其他变量

-------------------------------------------------------------------------------

%R  经过协商的SMB协议

%T  当前的日期和时间

 

⑥参考图片

  2.全局参数设置

 

原文地址:https://www.cnblogs.com/-xuan/p/10542002.html