我們需要兩台虛擬機,一台作為ftp服務器,一台作為客戶端;
在服務器端建立測試文件
[root@mycat ftp]# touch {1..5}.txt
在客戶端進行測試,我們用telnet進行測試
[root@slave1 ~]# telnet 192.168.88.128 21 Trying 192.168.88.128... Connected to 192.168.88.128. Escape character is '^]'. 220 (vsFTPd 3.0.2) user ftp 331 Please specify the password. pass ftp 230 Login successful. PORT 192,168,88,102,48,57 200 PORT command successful. Consider using PASV.
客戶端再開一個窗口用nc工具進行監聽12345端口
[root@slave1 ~]# nc -l 192.168.88.102 12345
在客戶端測試
list 150 Here comes the directory listing. 226 Directory send OK. [root@slave1 ~]# nc -l 192.168.88.102 12345 -rw-r--r-- 1 0 0 0 Jul 15 02:10 1.txt -rw-r--r-- 1 0 0 0 Jul 15 02:10 2.txt -rw-r--r-- 1 0 0 0 Jul 15 02:10 3.txt -rw-r--r-- 1 0 0 0 Jul 15 02:10 4.txt -rw-r--r-- 1 0 0 0 Jul 15 02:10 5.txt drwxr-xr-x 2 0 0 6 Oct 30 2018 pub
這就是ftp主動連接工作原理