ufw ubuntu 不规则地阻塞 ftp_connect() PHP
ufw ubuntu blocks iregularly ftp_connect() PHP
我正在编写一个简单的 php 应用程序,它连接 ftp 服务器并从中获取数据。问题是我有时会成功连接,有时会被阻止。这是我在 Ubuntu 和 Apache
中运行的代码
$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 端口,因此我的本地防火墙允许其中一些端口并拒绝其他端口。解决?增加允许的端口范围。
谢谢!
我正在编写一个简单的 php 应用程序,它连接 ftp 服务器并从中获取数据。问题是我有时会成功连接,有时会被阻止。这是我在 Ubuntu 和 Apache
中运行的代码$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 端口,因此我的本地防火墙允许其中一些端口并拒绝其他端口。解决?增加允许的端口范围。
谢谢!