![如何在 Linux 中使用 samba 安装中兴 ZXHN H267N 共享?](https://linux22.com/image/1537532/%E5%A6%82%E4%BD%95%E5%9C%A8%20Linux%20%E4%B8%AD%E4%BD%BF%E7%94%A8%20samba%20%E5%AE%89%E8%A3%85%E4%B8%AD%E5%85%B4%20ZXHN%20H267N%20%E5%85%B1%E4%BA%AB%EF%BC%9F.png)
我得到了一个ZTE ZXHN H267N
路由器,它允许将连接的 USB 存储设备导出为 samba 共享。
正如您在下面的屏幕截图中看到的,配置选项并不多,而且非常简单。
在 Windows 上,我可以通过简单访问来打开共享\\192.168.1.1
:我可以浏览它、读取文件、将文件写入/复制到其中……所以一切似乎都按预期工作。
但在 Linux 上我无法以读写模式挂载它。我实际上可以挂载它,但我无法读取或写入任何内容。我尝试过任何挂载选项的逻辑组合,但都无济于事。
root@host:/tmp# mount --verbose -t cifs -o rw,guest,file_mode=0777,dir_mode=0777 //192.168.1.1/samba ./asd
mount.cifs kernel mount options: ip=192.168.1.1,unc=\\192.168.1.1\samba,guest,file_mode=0777,dir_mode=0777,user=,prefixpath=,pass=********
root@host:/tmp# cd asd
root@host:/tmp/asd# LANG=C touch a
touch: cannot touch `a': Permission denied
root@host:/tmp/asd#
在上面的例子中,共享已挂载,但a
不存在。此外,如果我lsattr
在已存在的文件上运行,则会得到以下结果:
root@host:/tmp/asd# LANG=C lsattr existingfile
lsattr: Permission denied While reading flags on existingfile
似乎我没有读取或写入权限。我尝试了其他选项,例如:
- 指定
uid
和gid
,从1
到10000
。 - 指定
sec
任何可用选项。 - 指定
user
给本地用户。 - 设置用户和密码并尝试将其挂载为,而不是
guest
,而是指定username
和password
。 - 上述一些其他选项和组合。
我不知道应该指定哪些其他选项才能将此共享挂载为rw
。路由器的文档没有提到应该指定哪些选项才能正确挂载它。
有人设法从这个或类似的路由器(如 R/W)安装共享吗?
也欢迎任何建议。
--- 编辑 1 ---
根据 的建议,我在安装之前在机器上@gmelis
放置了一个监听器来查看发生了什么。我尝试的过滤器是: ,结果是:tcpdump
-i eth0 -n host 192.168.1.1
17:19:54.175169 IP 192.168.1.200.40703 > 192.168.1.1.445: Flags [S], seq 1716673820, win 29200, options [mss 1460,sackOK,TS val 45819160 ecr 0,nop,wscale 6], length 0
17:19:54.182221 IP 192.168.1.1.445 > 192.168.1.200.40703: Flags [R.], seq 0, ack 1716673821, win 0, length 0
17:19:54.186283 IP 192.168.1.200.42696 > 192.168.1.1.139: Flags [S], seq 170856558, win 29200, options [mss 1460,sackOK,TS val 45819161 ecr 0,nop,wscale 6], length 0
17:19:54.194053 IP 192.168.1.1.139 > 192.168.1.200.42696: Flags [S.], seq 2811302286, ack 170856559, win 14480, options [mss 1460,sackOK,TS val 50456624 ecr 45819161,nop,wscale 3], length 0
17:19:54.194931 IP 192.168.1.200.42696 > 192.168.1.1.139: Flags [.], ack 1, win 457, options [nop,nop,TS val 45819162 ecr 50456624], length 0
17:19:54.196654 IP 192.168.1.200.42696 > 192.168.1.1.139: Flags [P.], seq 1:73, ack 1, win 457, options [nop,nop,TS val 45819162 ecr 50456624], length 72 NBT Session Packet: Session Request
17:19:54.202629 IP 192.168.1.1.139 > 192.168.1.200.42696: Flags [.], ack 73, win 1810, options [nop,nop,TS val 50456625 ecr 45819162], length 0
17:19:54.202992 IP 192.168.1.200.42696 > 192.168.1.1.139: Flags [P.], seq 73:155, ack 1, win 457, options [nop,nop,TS val 45819163 ecr 50456625], length 82 NBT Session Packet: Session Message
17:19:54.209332 IP 192.168.1.1.139 > 192.168.1.200.42696: Flags [.], ack 155, win 1810, options [nop,nop,TS val 50456626 ecr 45819163], length 0
17:19:54.209336 IP 192.168.1.1.139 > 192.168.1.200.42696: Flags [P.], seq 1:5, ack 155, win 1810, options [nop,nop,TS val 50456626 ecr 45819163], length 4 NBT Session Packet: Session Granted
17:19:54.212933 IP 192.168.1.200.42696 > 192.168.1.1.139: Flags [.], ack 5, win 457, options [nop,nop,TS val 45819164 ecr 50456626], length 0
17:19:54.217108 IP 192.168.1.1.139 > 192.168.1.200.42696: Flags [P.], seq 5:86, ack 155, win 1810, options [nop,nop,TS val 50456627 ecr 45819164], length 81 NBT Session Packet: Session Message
17:19:54.219993 IP 192.168.1.200.42696 > 192.168.1.1.139: Flags [.], ack 86, win 457, options [nop,nop,TS val 45819165 ecr 50456627], length 0
17:19:54.220637 IP 192.168.1.200.42696 > 192.168.1.1.139: Flags [P.], seq 155:409, ack 86, win 457, options [nop,nop,TS val 45819165 ecr 50456627], length 254 NBT Session Packet: Session Message
17:19:54.231137 IP 192.168.1.1.139 > 192.168.1.200.42696: Flags [P.], seq 86:162, ack 409, win 1944, options [nop,nop,TS val 50456628 ecr 45819165], length 76 NBT Session Packet: Session Message
17:19:54.232949 IP 192.168.1.200.42696 > 192.168.1.1.139: Flags [P.], seq 409:527, ack 162, win 457, options [nop,nop,TS val 45819166 ecr 50456628], length 118 NBT Session Packet: Session Message
17:19:54.259669 IP 192.168.1.1.139 > 192.168.1.200.42696: Flags [P.], seq 162:213, ack 527, win 1944, options [nop,nop,TS val 50456631 ecr 45819166], length 51 NBT Session Packet: Session Message
17:19:54.260757 IP 192.168.1.200.42696 > 192.168.1.1.139: Flags [P.], seq 527:599, ack 213, win 457, options [nop,nop,TS val 45819169 ecr 50456631], length 72 NBT Session Packet: Session Message
17:19:54.267619 IP 192.168.1.1.139 > 192.168.1.200.42696: Flags [P.], seq 213:281, ack 599, win 1944, options [nop,nop,TS val 50456632 ecr 45819169], length 68 NBT Session Packet: Session Message
17:19:54.268189 IP 192.168.1.200.42696 > 192.168.1.1.139: Flags [P.], seq 599:671, ack 281, win 457, options [nop,nop,TS val 45819169 ecr 50456632], length 72 NBT Session Packet: Session Message
17:19:54.273042 IP 192.168.1.1.139 > 192.168.1.200.42696: Flags [P.], seq 281:363, ack 671, win 1944, options [nop,nop,TS val 50456632 ecr 45819169], length 82 NBT Session Packet: Session Message
17:19:54.273609 IP 192.168.1.200.42696 > 192.168.1.1.139: Flags [P.], seq 671:763, ack 363, win 457, options [nop,nop,TS val 45819170 ecr 50456632], length 92 NBT Session Packet: Session Message
17:19:54.277267 IP 192.168.1.1.139 > 192.168.1.200.42696: Flags [P.], seq 363:402, ack 763, win 1944, options [nop,nop,TS val 50456633 ecr 45819170], length 39 NBT Session Packet: Session Message
17:19:54.278342 IP 192.168.1.200.42696 > 192.168.1.1.139: Flags [P.], seq 763:841, ack 402, win 457, options [nop,nop,TS val 45819170 ecr 50456633], length 78 NBT Session Packet: Session Message
17:19:54.282561 IP 192.168.1.1.139 > 192.168.1.200.42696: Flags [P.], seq 402:565, ack 841, win 1944, options [nop,nop,TS val 50456633 ecr 45819170], length 163 NBT Session Packet: Session Message
17:19:54.283691 IP 192.168.1.200.42696 > 192.168.1.1.139: Flags [P.], seq 841:919, ack 565, win 473, options [nop,nop,TS val 45819171 ecr 50456633], length 78 NBT Session Packet: Session Message
17:19:54.287372 IP 192.168.1.1.139 > 192.168.1.200.42696: Flags [P.], seq 565:728, ack 919, win 1944, options [nop,nop,TS val 50456634 ecr 45819171], length 163 NBT Session Packet: Session Message
17:19:54.287949 IP 192.168.1.200.42696 > 192.168.1.1.139: Flags [P.], seq 919:997, ack 728, win 490, options [nop,nop,TS val 45819171 ecr 50456634], length 78 NBT Session Packet: Session Message
17:19:54.292238 IP 192.168.1.1.139 > 192.168.1.200.42696: Flags [P.], seq 728:830, ack 997, win 1944, options [nop,nop,TS val 50456634 ecr 45819171], length 102 NBT Session Packet: Session Message
17:19:54.329627 IP 192.168.1.200.42696 > 192.168.1.1.139: Flags [.], ack 830, win 490, options [nop,nop,TS val 45819176 ecr 50456634], length 0
从该输出中,我得出结论,最初尝试在445
远程主机重置的端口上建立连接,然后下一个尝试的端口139
似乎成功了。
我还设法运行ngrep
带有等效过滤器的命令,结果是:
#
G 192.168.1.1 -> 224.0.0.1 17:100
..................
##
T 192.168.1.1:445 -> 192.168.1.200:40822 [AR]
......
####
T 192.168.1.200:42815 -> 192.168.1.1:139 [AP]
...D CKFDENECFDEFFCFGEFFCCACACACACACA. FCFAEJCOEEEFFGEFEMFDCOEFFDCACAAA.
##
T 192.168.1.200:42815 -> 192.168.1.1:139 [AP]
...N.SMBr......................~.....+..LM1.2X002..LANMAN2.1..NT LM 0.12..POSIX 2.
##
T 192.168.1.1:139 -> 192.168.1.200:42815 [AP]
....
##
T 192.168.1.1:139 -> 192.168.1.200:42815 [AP]
...M.SMBr......................~.....................Z...................N?...zTR
##
T 192.168.1.200:42815 -> 192.168.1.1:139 [AP]
.....SMBs......................~.........T@..........F............D...+.Pm..0.a\...........'E....Tb.....F........W.O.R.K.G.R.O.U.P........W.O.R.K.G.R.O.U.P...L.i.n.
u.x. .v.e.r.s.i.o.n. .4...1...1.9.+...C.I.F.S. .V.F.S. .C.l.i.e.n.t. .f.o.r. .L.i.n.u.x...
##
T 192.168.1.1:139 -> 192.168.1.200:42815 [AP]
...H.SMBs......................~d............Unix.Samba 1.9.16p10.WORKGROUP.
#
T 192.168.1.200:42815 -> 192.168.1.1:139 [AP]
...r.SMBu......................~d............G......?....{v....H...a....\.\.1.9.2...1.6.8...1...1.\.s.a.m.b.a...?????.
##
T 192.168.1.1:139 -> 192.168.1.200:42815 [AP]
.../.SMBu...................'..~d............A:....
#
T 192.168.1.200:42815 -> 192.168.1.1:139 [AP]
...D.SMB2...................'..~d........................B..............
##
T 192.168.1.1:139 -> 192.168.1.200:42815 [AP]
[email protected].............'..~d..................8................
#
T 192.168.1.200:42815 -> 192.168.1.1:139 [AP]
...D.SMB2...................'..~d........................B..............
#
T 192.168.1.1:139 -> 192.168.1.200:42815 [AP]
...N.SMB2.....A.............'[email protected].
#
T 192.168.1.200:42815 -> 192.168.1.1:139 [AP]
...X.SMBu......................~d............-..\.\.1.9.2...1.6.8...1...1.\.I.P.C.$...?????.
#
T 192.168.1.1:139 -> 192.168.1.200:42815 [AP]
...#.SMBu......................~d......
#
[...]
尝试了其他方法:
- 我尝试将点安装为
uid=nobody
和gid=nogroup
,结果相同。 - 我
chmod -R 777
在挂载点上运行,也没有什么区别。 - 我发现了一件有趣的事情:如果我运行,
touch
我会收到权限被拒绝错误,但如果我尝试运行,mkdir
我总是会收到一条mkdir: cannot create directory
blah':文件存在' 消息,无论我指定什么目录名(当然,它不存在)。
--- 编辑 2 ---
我还尝试运行smbclient -L //192.168.1.1
(没有用户),它要求我输入我没有的密码。如果我输入任何值作为密码,就会显示上述错误(NT_STATUS_ACCESS_DENIED
)。
但我也尝试在路由器面板中激活安全性(设置Anonymous
为no
,并设置用户名和密码),以下是我发现的情况:
1) 如果我只是运行:smbclient -L //192.168.1.1
,系统会要求我输入密码。如果我只是点击Enter,我会得到以下输出:
# smbclient -L //192.168.1.1
Enter root's password:
Server does not support EXTENDED_SECURITY but 'client use spnego = yes and 'client ntlmv2 auth = yes'
Anonymous login successful
OS=[楮x慓扭⸱⸹㘱ㅰ0佗䭒則問P] Server=[]
Sharename Type Comment
--------- ---- -------
samba Disk samba share dir
IPC$ IPC IPC Service (Samba Server)
Server does not support EXTENDED_SECURITY but 'client use spnego = yes and 'client ntlmv2 auth = yes'
Anonymous login successful
OS=[楮x慓扭⸱⸹㘱ㅰ0佗䭒則問P] Server=[]
Server Comment
--------- -------
Workgroup Master
--------- -------
WORKGROUP SMBSHARE
2)如果我输入“正确”的凭据,我会得到以下输出:
# smbclient -L //192.168.1.1 -U smbshare
Enter smbshare's password:
Server does not support EXTENDED_SECURITY but 'client use spnego = yes and 'client ntlmv2 auth = yes'
session setup failed: SUCCESS - 0
我开始认为这是路由器中的某种错误,但奇怪的是,在 Windows 机器上安装 samba 共享没有任何问题,而且我也可以从共享中读取和写入内容。