嘗試使用活動模式時,lftp 在「連線」時掛起

嘗試使用活動模式時,lftp 在「連線」時掛起

我需要在主動模式下使用lftp(由於伺服器端的一些限制)。所以我設定了以下~/.lftprc設定檔:

debug
set ssl:verify-certificate no
set ftp:port-ipv4 148.X.X.86
set ftp:passive-mode false
set ftp:ssl-allow false
set ftp:prefer-epsv no
set ftp:port-range 1026-1029
set net:socket-bind-ipv4 192.168.2.114

當我使用任何位址執行 lftp 時,都會遇到相同的問題:

lftp ftp.gnu.org
---- Resolving host address...
---- 2 addresses found: 2001:470:142:3::b, 209.51.188.20
lftp ftp.gnu.org:~> ls
---- Connecting to ftp.gnu.org (2001:470:142:3::b) port 21
**** connect(control_sock): Network is unreachable
---- Closing control socket
---- Connecting to ftp.gnu.org (209.51.188.20) port 21
<--- 220 GNU FTP server ready.
---> FEAT
<--- 211-Features:               
<---  EPRT
<---  EPSV
<---  MDTM
<---  PASV
<---  REST STREAM
<---  SIZE
<---  TVFS
<--- 211 End
---> USER anonymous
<--- 230-NOTICE (Updated October 15 2021):

<--- 230 Login successful.
---> PWD
<--- 257 "/" is the current directory
---> PORT 148,X,X,86,4,3
<--- 200 PORT command successful. Consider using PASV.
---> LIST
`ls' at 0 [Waiting for transfer to complete]

並且客戶端在等待資料時掛斷。看來連接埠 4*256+3=1027 應該打開並列出資料連接,如果確實如此:

[root@c03 mkawka]# lsof -i -P |grep ftp
lftp      150072   mkawka    5u  IPv4 63562629      0t0  TCP c03:35266->ftp.gnu.org:21 (ESTABLISHED)
lftp      150072   mkawka    6u  IPv4 63607851      0t0  TCP c03:1027 (LISTEN)
[root@c03 mkawka]# 

我還從外部檢查開放連接埠是否確實可見(以排除防火牆問題):

[mkawka@huragan ~]$ nmap 148.X.X.86 -p1024-1029 -Pn

Starting Nmap 6.40 ( http://nmap.org ) at 2022-08-24 12:28 UTC
Nmap scan report for 148.X.X.86
Host is up (0.0021s latency).
PORT     STATE    SERVICE
[...]
1027/tcp open     IIS
[...]

我使用的是lftp 4.4.8和CentOS 7.9

編輯:我嘗試避免被動模式,因為伺服器端似乎有有限的套接字/連接埠池。看起來我們正在與其他用戶競爭,有時我們會收到「被動模式被拒絕」的回應。我們需要在很短的時間視窗內執行傳輸,因此等待被動模式可用性並不可靠。

相關內容