先运行下面命令查看smb服务是否启动
systemctl status smb.service
如果是运行状态可以用testparm查看配置状态
➜ ~ testparm
Load smb config files from /etc/samba/smb.conf
Processing section "[homes]"
Processing section "[printers]"
Processing section "[print$]"
Processing section "[mysmb]"
Loaded services file OK.
Server role: ROLE_STANDALONE
如果没有问题下一步可以用smbclient测试本地连接,没有密码直接回车
➜ ~ smbclient //127.0.0.1/mysmb
Enter SAMBA\root's password:
Anonymous login successful
Try "help" to get a list of possible commands.
smb: \>
如果能正常访问那应该就是防火墙的问题了,直接使用firwall-cmd将端口139和445允许通过,然后重启防火墙服务
➜ ~ firewall-cmd --zone=public --add-port=139/tcp --permanent
success
➜ ~ firewall-cmd --zone=public --add-port=445/tcp --permanent
success
➜ ~ systemctl restart firewalld
【附上配置文件:】
[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
[share]
comment = This is a share directory
path = /home/
writable = yes
public = yes