我已经按照教程这里以及在 Ubuntu 16.04.4 上设置 samba 共享的其他几个地方。但无论我怎么尝试,我都无法从我的任何一台 Windows 计算机(8.1 和 10)看到这些共享。我尝试将映射的网络驱动器添加到路径,在文件资源管理器中直接浏览它,但没有任何效果。
下面是我在 Ubuntu 上检查时使用的几个命令的输出:
media@media-pc:~$ testparm
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
WARNING: The "syslog" option is deprecated
Processing section "[printers]"
Processing section "[print$]"
Processing section "[4TBshare]"
Processing section "[sambashare]"
Loaded services file OK.
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definitions
# Global parameters
[global]
server string = %h server (Samba, Ubuntu)
interfaces = 127.0.0.0/8 enp3s0
bind interfaces only = Yes
server role = standalone server
map to guest = Bad User
obey pam restrictions = Yes
pam password change = Yes
passwd program = /usr/bin/passwd %u
passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
unix password sync = Yes
syslog = 0
log file = /var/log/samba/log.%m
max log size = 1000
dns proxy = No
usershare allow guests = Yes
panic action = /usr/share/samba/panic-action %d
idmap config * : backend = tdb
[printers]
comment = All Printers
path = /var/spool/samba
create mask = 0700
printable = Yes
browseable = No
[print$]
comment = Printer Drivers
path = /var/lib/samba/printers
[4TBshare]
comment = 4TB share on media-pc
path = /mnt/4TB
read only = No
[sambashare]
comment = test share
path = /home/media/sambashare
read only = No
media@media-pc:~$ smbtree
Enter media's password:
WORKGROUP
\\MEDIA-PC media-pc server (Samba, Ubuntu)
smbtree 输出让我担心,因为它没有显示我设置的任何共享。我尝试直接从文件资源管理器 GUI 共享文件夹,但这也没有改变任何东西。
但是,使用 smbclient 可以正确显示共享:
media@media-pc:~$ smbclient -L 127.0.0.1
WARNING: The "syslog" option is deprecated
Enter media's password:
Domain=[WORKGROUP] OS=[Windows 6.1] Server=[Samba 4.3.11-Ubuntu]
Sharename Type Comment
--------- ---- -------
print$ Disk Printer Drivers
4TBshare Disk 4TB share on media-pc
sambashare Disk test share
IPC$ IPC IPC Service (media-pc server (Samba, Ubuntu))
Domain=[WORKGROUP] OS=[Windows 6.1] Server=[Samba 4.3.11-Ubuntu]
Server Comment
--------- -------
MEDIA-PC media-pc server (Samba, Ubuntu)
Workgroup Master
--------- -------
WORKGROUP MEDIA-PC
答案1
终于找到了问题所在。在 Windows 10 上,当无法映射网络驱动器时,我单击了诊断按钮,它提到它可以与远程服务器通信,但它不会响应。研究了一下,原来我需要打开 Ubuntu 中的端口。Samba 使用端口 139 和 445 作为 TCP,使用端口 137 和 138 作为 UDP。打开这些端口有效ufw allow <port>
。