当前位置:   article > 正文

Samba文件共享服务器_smb地址

smb地址

Samba 服务基础

Samba是一个让不同系统之间通信的软件
Samba是基于客户机/服务器型的协议
SMB协议 (Server Message Block 服务消息块)
CIFS协议(Common Internet File System 通用互联网文件系统

Samba软件包的构成

服务端软件 samba
客户端软件 samba-client
用于提供服务端和客户端程序的公共组件 samba-common

Samba服务的程序组件

smbd:为客户机提供服务器中共享资源的访问
nmbd:提供基于NetBIOS协议的主机名称解析

[root@localhost ~]# netstat -antup | grep mb
tcp        0      0 0.0.0.0:445             0.0.0.0:*               LISTEN      11421/smbd          
tcp        0      0 0.0.0.0:139             0.0.0.0:*               LISTEN      11421/smbd          
tcp6       0      0 :::445                  :::*                    LISTEN      11421/smbd          
tcp6       0      0 :::139                  :::*                    LISTEN      11421/smbd          
udp        0      0 192.168.122.255:137     0.0.0.0:*                          11433/nmbd          
udp        0      0 192.168.122.1:137       0.0.0.0:*                         11433/nmbd          
udp        0      0 192.168.137.255:137     0.0.0.0:*                          11433/nmbd          
udp        0      0 192.168.137.135:137     0.0.0.0:*                          11433/nmbd          
udp        0      0 0.0.0.0:137             0.0.0.0:*                           11433/nmbd          
udp        0      0 192.168.122.255:138     0.0.0.0:*                          11433/nmbd          
udp        0      0 192.168.122.1:138       0.0.0.0:*                           11433/nmbd          
udp        0      0 192.168.137.255:138     0.0.0.0:*                         11433/nmbd          
udp        0      0 192.168.137.135:138     0.0.0.0:*                         11433/nmbd          
udp        0      0 0.0.0.0:138             0.0.0.0:*                           11433/nmbd 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15

smbd 监听 TCP协议的 139端口(SMB)协议,445端口( CIFS协议 )
nmbd 监听 UDP协议的 137-138端口(NetBIOS协议)

Samba主要的配置文件

/etc/samba/smb.conf

#vim /etc/samba/smb.conf
# See smb.conf.example for a more detailed config file or
#read the smb.conf manpage.
#Run 'testparm' to verify the config is correct after
#you modified it.

[global]          #环境变量、全局设置  
    workgroup = SAMBA  #工作组
    security = user   #安全级别

    passdb backend = tdbsam

    printing = cups
    printcap name = cups
    load printers = yes
    cups options = raw
    
	[homes]           # 用户家目录共享相关设置
    comment = Home Directories
    valid users = %S, %D%w%S
    browseable = No
    read only = No
    inherit acls = Yes

	[printers]         # 共享打印机相关配置
    comment = All Printers
    path = /var/tmp
    printable = Yes
    create mask = 0600
    browseable = No
    
	[print$]      #共享打印机设备相关配置
    comment = Printer Drivers
    path = /var/lib/samba/drivers
    write list = @printadmin root
    force group = @printadmin
    create mask = 0664
    directory mask = 0775
    
	[my share]       #自定义的共享名
    comment = share   # 对该共享的说明
    path = /tmp/share    # 该共享目录在服务器中的绝对路径
    browseable = yes	# 在“网上邻居”中是否可见
    read only = yes   #是否为只读
    valid users = zzq , root #允许访问该共享资源的用户
    write list = zzq   #可以在共享目录下进行写入操作的用户
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46

安装并使用samba服务

安装

#yum install -y samba
  • 1

配置

vim /etc/samba/smb.conf
GG
o
[my share]
    comment = share
    path = /tmp/share
    browseable = yes
    writable = yes
    read only = yes
    valid users = zzq , root
    write list = zzq
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

用testparm 可以检查smb.conf配置文件的内部正确性

用法
testparm [-s] [-h] [-L servername] [configfilename] [hostname hostIP]

[root@localhost samba]# testparm -s -h /etc/samba/smb.conf
Load smb config files from /etc/samba/smb.conf
Loaded services file OK.
Server role: ROLE_STANDALONE
......
  • 1
  • 2
  • 3
  • 4
  • 5

Global parameters

[global]
printcap name = cups
security = USER
workgroup = SAMBA
idmap config * : backend = tdb
cups options = raw

添加samba共享用户

#pdbedit -a zzq
new password:
retype new password:
Unix username:        zzq
..........
  • 1
  • 2
  • 3
  • 4
  • 5

关闭防火墙、selinux

#systemctl stop firewalld
#systemctl disable firewalld
#setenforce 0
  • 1
  • 2
  • 3

开启Samba服务

#systemctl start smb
#systemctl start nmb
  • 1
  • 2

客户机访问Samba服务器共享资源

windows 访问smb服务器

打开资源管理器
地址栏输入\ \smb服务器IP
输入对应的用户名和密码
在这里插入图片描述

在这里插入图片描述

Linux 访问SMB服务器共享资源

访问需要安装Samba-client客户端
执行smbclient -L 目标IP 可以查看能访问内容
在这里插入图片描述
访问smb服务器的格式 smbclient 目标地址/目录 -U 用户%密码
进入smb界面输入问号可以查看可使用的命令
在这里插入图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/菜鸟追梦旅行/article/detail/184135
推荐阅读
相关标签
  

闽ICP备14008679号