大网数据广告活动
服务器运维问答

ProFTPd server behind firewall returns internal IP address for WAN and LAN connections

· 52CE 我爱测

I'm using ProFTPD on a Debian server behind another Debian firewall. I can connect to the ftp server from the outside. However, the virtual host that gets chosen is always 192.168.0.4 regardless of WAN or LAN connections. This ca…

问题原文

原帖链接 · Lifz · CC BY-SA 3.0

I'm using ProFTPD on a Debian server behind another Debian firewall. I can connect to the ftp server from the outside. However, the virtual host that gets chosen is always 192.168.0.4 regardless of WAN or LAN connections. This causes an issue when entering PASV mode when the ftp server responds with the internal IP address to WAN connections.

I know there is a MasqueradeAddress directive for WAN connectoins but my WAN connections are connecting to my internal virtual host.

Since there is only 1 IP address on the FTP server, do I need to use the mod_ifsession module as described here: http://www.proftpd.org/docs/howto/NAT.html?

已采纳解答

原帖链接 · Lifz · CC BY-SA 3.0

In the original question, I asked if I have to use the mod_ifsession module. So far, that is the only way I can get it to work. Maybe that's expected but I was hoping to use a <VirtualHost> block to get it working.

Here is what I did:

<IfModule mod_ifsession.c>
  <Class internal>
    From 192.168.0.0/24
  </Class>

  <IfClass !internal>
    MasqueradeAddress 1.2.3.4
  </IfClass>
</IfModule>

Using that, incoming LAN connections get the internal IP (192.168.0.4) and WAN connections get the external IP (1.2.3.4). I don't know if it's ideal, but it does work.

Edit: I was also able to get it working using a different port, as suggested. You may or may not wish to run ftp on a non-standard port so maybe this method is not for you. If you forward port 21 on the firewall to the ftp server using, say, 2121 and listen on port 2121 in one of your <virtualHost> blocks, you then know it's an external connection. Here is the block I used for that:

<VirtualHost 192.168.0.4>
  ServerName "External"
  Port 2121
  MasqueradeAddress 1.2.3.4
</VirtualHost>

Note: If you do it this way, the "server config" (anything not in a <virtualHost> or <Global> block) directives will not be applied. You may have to repeat some directives or use a <Global> block.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-09-08)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。