ufw-ubuntu定期阻塞ftp_connect()PHP



我正在编写一个简单的php应用程序,它连接并从ftp服务器获取数据。问题是,我有时会成功连接,但有时会被屏蔽。这是我使用Apache 在Ubuntu中运行的代码

$ftpConn = ftpConnect($ftpHost, $ftpUser, $ftpPassword);

function ftpConnect($host, $user, $password) {
$ftpConn = ftp_connect($host,21,3)or die("Couldn't connect to $host");
$login = ftp_login($ftpConn, $user, $password);
// check connection
if ((!$ftpConn) || (!$login)) {
echo 'FTP connection has failed again! Attempted to connect to ' . $host . ' for user ' . $user . '.';
} else {
return $ftpConn;
}
}

ufw状态编号如下:

[ 1] Apache Full                ALLOW IN    Anywhere
[ 2] 20/tcp                     ALLOW IN    Anywhere
[ 3] 21/tcp                     ALLOW IN    Anywhere
[ 4] 40000:50000/tcp            ALLOW IN    Anywhere
[ 5] 990/tcp                    ALLOW IN    Anywhere
[ 6] 9822                       ALLOW IN    Anywhere
[ 7] Apache Full (v6)           ALLOW IN    Anywhere (v6)
[ 8] 20/tcp (v6)                ALLOW IN    Anywhere (v6)
[ 9] 21/tcp (v6)                ALLOW IN    Anywhere (v6)
[10] 40000:50000/tcp (v6)       ALLOW IN    Anywhere (v6)
[11] 990/tcp (v6)               ALLOW IN    Anywhere (v6)
[12] 9822 (v6)                  ALLOW IN    Anywhere (v6)

我不知道为什么会发生这种情况。任何建议都欢迎

我试图连接的ftp服务器被配置为在被动连接时使用30000:61000/tcp端口,因此我的本地防火墙允许其中一些端口,并拒绝其他一些端口。解决方案?增加了允许端口的范围。

谢谢!

相关内容

  • 没有找到相关文章

最新更新