如何排除 Samba 错误 NT_STATUS_HOST_UNREACHABLE

如何排除 Samba 错误 NT_STATUS_HOST_UNREACHABLE

我正在努力通过 Lan 在两台 Ubuntu 17.04 机器之间共享文件夹。

我首先尝试了 Nautilus 公共共享方法,但当我无法双向浏览文件夹时,我转而使用 Samba。据我所知,两个 Samba 安装几乎相同;我在机器之间复制了 smb.conf 几次,但没有任何效果。

我可以在“其他地点' 在 Nautilus 中,可以从笔记本电脑浏览桌面的共享文件夹,但不能反过来。

跑步:

john@Laptop:~$ smbclient -L //192.168.20.136 -U john

在我的笔记本电脑上,它生成了预期的共享资源列表。在台式机上,它生成了一个错误:

john@Desktop:~$ smbclient -L //192.168.20.102 -U john
WARNING: The "syslog" option is deprecated
Enter john2's password: 
Connection to 192.168.20.102 failed (Error NT_STATUS_HOST_UNREACHABLE)

我正在使用passdb 后端 = tdbsam但改用密码保护程序把事情简单化却没有任何效果。

防火墙已关闭;GUFW 报告两台机器正在使用相同的端口。

名称解析正在运行;我可以 ping 网络名称。我检查了 Wireshark,发现 Samba 正在从台式机到笔记本电脑进行通信,反之亦然。

我设置系统日志 = 3smb配置文件在两台机器上查看了它们的 journalctrl、auth.log、/var/log/samba/log.smbd、/var/log/samba/log.nmbd,没有发现与连接失败有关的任何内容。

唯一的小问题是两台机器轮流充当工作组的本地主浏览器;我提高了桌面的优先级以避免这种情况,但这种行为仍在继续。

这看起来像是某种授权问题,所以我在笔记本电脑上设置了第二个用户帐户来测试干净的设置,但得到的结果与之前相同。

当台式机的 Samba 尝试访问笔记本电脑的共享文件夹时,如何才能仔细观察发生的情况?

john@Laptop:/etc/samba$ samba -V    
Version 4.5.8-Ubuntu

桌面smb.conf:

john@Desktop:~$ testparm -s
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 "[Public]"
Processing section "[Documents]"
Loaded services file OK.
Server role: ROLE_STANDALONE

# Global parameters
[global]
    server string = %h server (Samba, Ubuntu)
    workgroup = office-design
    os level = 33
    log file = /var/log/samba/log.%m
    max log size = 1000
    syslog = 3
    panic action = /usr/share/samba/panic-action %d
    usershare allow guests = Yes
    usershare owner only = No
    printcap name = CUPS
    name resolve order = bcast lmhosts hosts wins
    map to guest = Bad User
    obey pam restrictions = Yes
    pam password change = Yes
    passdb backend = smbpasswd
    passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
    passwd program = /usr/bin/passwd %u
    security = USER
    server role = standalone server
    unix password sync = Yes
    username map = /etc/samba/smbusers
    dns proxy = No
    idmap config * : backend = tdb


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


[print$]
    comment = Printer Drivers
    path = /var/lib/samba/printers


[Public]
    path = /home/nicole/Public
    read only = No


[Documents]
    path = /home/john/Documents
    read only = No
    valid users = john john2

桌面 smbtree;没有可见的笔记本电脑资源:

john@Desktop:~$ smbtree
Enter john's password: 
OFFICE-DESIGN
    \\DESKTOP           Desktop server (Samba, Ubuntu)
        \\DESKTOP\Downloads         
        \\DESKTOP\Pictures          
        \\DESKTOP\PDF               PDF
        \\DESKTOP\IX6500            IX6500
        \\DESKTOP\Canon-PIXMA-iX6560    Canon PIXMA iX6560
        \\DESKTOP\Canon-iX6500-series   Canon iX6500 series
        \\DESKTOP\iX6500-series     Canon iX6500 series
        \\DESKTOP\Canon-iX6500-series-2 Canon iX6500 series
        \\DESKTOP\IPC$              IPC Service (Desktop server (Samba, Ubuntu))
        \\DESKTOP\Documents         
        \\DESKTOP\Public            
        \\DESKTOP\print$            Printer Drivers
    \\LAPTOP        laptop server (Samba, Ubuntu)

桌面 smbd;没有错误。桌面 nmbd 错误:

john@Desktop:~$ systemctl status nmbd.service
● nmbd.service - Samba NMB Daemon
   Loaded: loaded (/lib/systemd/system/nmbd.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2017-12-19 11:52:52 +07; 20min ago
     Docs: man:nmbd(8)
           man:samba(7)
           man:smb.conf(5)
 Main PID: 25317 (nmbd)
   Status: "nmbd: ready to serve connections..."
    Tasks: 1 (limit: 4915)
   CGroup: /system.slice/nmbd.service
           └─25317 /usr/sbin/nmbd

Dec 19 12:09:58 Desktop nmbd[25317]:   
Dec 19 12:09:58 Desktop nmbd[25317]:   Samba name server DESKTOP has stopped being a local master browser for workgroup OFFICE-DESIGN on subnet 192.168
Dec 19 12:09:58 Desktop nmbd[25317]:   
Dec 19 12:09:58 Desktop nmbd[25317]:   *****
Dec 19 12:10:15 Desktop nmbd[25317]: [2017/12/19 12:10:15.371279,  0] ../source3/nmbd/nmbd_become_lmb.c:397(become_local_master_stage2)
Dec 19 12:10:15 Desktop nmbd[25317]:   *****
Dec 19 12:10:15 Desktop nmbd[25317]:   
Dec 19 12:10:15 Desktop nmbd[25317]:   Samba name server DESKTOP is now a local master browser for workgroup OFFICE-DESIGN on subnet 192.168.20.136
Dec 19 12:10:15 Desktop nmbd[25317]:   
Dec 19 12:10:15 Desktop nmbd[25317]:   *****

笔记本电脑 smb.conf:

john@laptop:/etc/samba$ testparm -s
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 "[Pictures]"
Processing section "[Documents]"
Processing section "[j2Documents]"
Loaded services file OK.
Server role: ROLE_STANDALONE

# Global parameters
[global]
    server string = %h server (Samba, Ubuntu)
    workgroup = office-design
    log file = /var/log/samba/log.%m
    max log size = 1000
    syslog = 3
    panic action = /usr/share/samba/panic-action %d
    usershare allow guests = Yes
    usershare owner only = No
    name resolve order = bcast lmhosts hosts wins
    map to guest = Bad User
    obey pam restrictions = Yes
    pam password change = Yes
    passdb backend = smbpasswd
    passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
    passwd program = /usr/bin/passwd %u
    security = USER
    server role = standalone server
    unix password sync = Yes
    username map = /etc/samba/smbusers
    dns proxy = No
    idmap config * : backend = tdb


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


[print$]
    comment = Printer Drivers
    path = /var/lib/samba/printers


[Pictures]
    path = /media/john/Home/john/Pictures
    read only = No
    valid users = @sambashare


[Documents]
    path = /home/john/Documents
    read only = No
    valid users = @sambashare


[j2Documents]
    path = /home/john2/Documents
    read only = No
    valid users = john2

笔记本电脑 smbd 状态;无错误。笔记本电脑 nmbd 状态:

john@laptop:/etc/samba$ systemctl status nmbd.service
● nmbd.service - Samba NMB Daemon
   Loaded: loaded (/lib/systemd/system/nmbd.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2017-12-20 11:57:37 +07; 1min 38s ago
     Docs: man:nmbd(8)
           man:samba(7)
           man:smb.conf(5)
 Main PID: 11314 (nmbd)
   Status: "nmbd: ready to serve connections..."
    Tasks: 1 (limit: 4915)
   CGroup: /system.slice/nmbd.service
           └─11314 /usr/sbin/nmbd

Dec 20 11:57:37 laptop systemd[1]: nmbd.service: Supervising process 11314 which is not our child. We'll most likely not notice when it exits.
Dec 20 11:57:37 laptop nmbd[11314]: [2017/12/20 11:57:37.518663,  0] ../lib/util/become_daemon.c:124(daemon_ready)
Dec 20 11:57:37 laptop nmbd[11314]:   STATUS=daemon 'nmbd' finished starting up and ready to serve connections
Dec 20 11:57:37 laptop systemd[1]: Started Samba NMB Daemon.
Dec 20 11:58:08 laptop nmbd[11314]: [2017/12/20 11:58:08.875623,  0] ../source3/nmbd/nmbd_become_lmb.c:397(become_local_master_stage2)
Dec 20 11:58:08 laptop nmbd[11314]:   *****
Dec 20 11:58:08 laptop nmbd[11314]:   
Dec 20 11:58:08 laptop nmbd[11314]:   Samba name server LAPTOP is now a local master browser for workgroup OFFICE-DESIGN on subnet 192.168.20.102
Dec 20 11:58:08 laptop nmbd[11314]:   
Dec 20 11:58:08 laptop nmbd[11314]:   *****

使用 smbclient,我可以在笔记本电脑和台式机上进行本地连接,也可以从笔记本电脑远程连接到台式机,但台式机到笔记本电脑的连接会失败。

本地桌面:

john@Desktop:/etc/samba$ smbclient //192.168.20.136/Documents -U john
WARNING: The "syslog" option is deprecated
Enter john's password: 
Domain=[VIVID-DESIGN] OS=[Windows 6.1] Server=[Samba 4.5.8-Ubuntu]
smb: \>

台式机到笔记本电脑:

john@Desktop:/etc/samba$ smbclient //192.168.20.102/j2Documents -U john2
WARNING: The "syslog" option is deprecated
Enter john2's password: 
Connection to 192.168.20.102 failed (Error NT_STATUS_HOST_UNREACHABLE)

答案1

解决了有两处变化。

我已将 Firewalld 添加到我的笔记本电脑中,以便使用防火墙小程序显示防火墙状态。虽然 GUFW 显示防火墙已关闭,但网络“编辑连接”(nm-connection-editor)显示我的 WiFi 连接正在使用不同的“防火墙区域”。

我删除了 Gufw 和 Ufw,并设置了 Firewalld 区域,并启用了 mdns(用于 Avahi)、nfs、samba 和 samba-client。

这使得台式机能够使用 Nautilus 浏览笔记本电脑,并通过 smb://Desktop/ 和 CLI smbclient 进行连接。

其次我补充说

可浏览 = 是

到桌面的 smb.conf 共享文件夹。这些文件夹可能已经连接,但这使得可以通过笔记本电脑上的 Nautilus 浏览工作组和共享。

笔记本电脑和台式机现在均可在工作组下(在‘Windows Server’下...)看到,而之前均无法查看。

另外两个更改可能有所帮助。我安装了 Avahi,并编辑了笔记本电脑的 /etc/nsswitch.conf 文件以匹配台式机的,方法是添加我的主机名到最后主办方线。

除了 /var/log/samba/nmbd.log 之外,我没有找到任何来自 Samba 的更有用的日志;将 syslog 设置为 10 对级别 3 的影响不大。

相关内容