简体   繁体   English

Ruby NET :: FTP无法解析正确的IP

[英]Ruby NET::FTP Not Resolving Correct IP

I am trying to connect to an FTP server using: 我正在尝试使用以下方法连接到FTP服务器:

ftp = Net::FTPFXPTLS.new
ftp.passive=true
ftp.debug_mode=true
ftp.connect('200.111.111.11',21)
ftp.login('Username','Pass')
ftp.chdir('inbound')
ftp.putbinaryfile("./#{filename}", "/#{filename}")
ftp.close()

For the purposes of this example 200.111.111.11 is the correct IP and 10.1.1.1 is the fake IP. 就本示例而言,200.111.111.11是正确的IP,10.1.1.1是伪IP。

When I connect via an FTP client such as Transmit I connect fine and everything works as normal but in the transcript it states: 当我通过FTP客户端(例如Transmit)进行连接时,我可以正常连接,并且一切正常,但在抄本中显示:

Cmd: PASV
227: Entering Passive Mode (10,1,1,1,47,79).
Fixing bogus PASV data address from 10.1.1.1:12111 to 200.111.111.11:12111.

Then when it tries to connect via the ruby script: 然后,当它尝试通过ruby脚本进行连接时:

get: 425 Failed to establish connection.

When it tries to do any action like LIST or STOR because the PASV command always returns 10.1.1.1:12111. 当它尝试执行诸如LIST或STOR之类的任何操作时,因为PASV命令始终返回10.1.1.1:12111。

So is there anyway to ensure the PASV command uses 200.111.111.11 and not what is sent back to it? 因此,无论如何,要确保PASV命令使用200.111.111.11而不是返回给它的内容?

This seems to be more of an issue with the gem, there is a solution for it but woud take a little while to implement. 对于gem来说,这似乎是更多的问题,有解决方案,但是要花一些时间才能实现。 In order to save time we simply switched the protocol to use SFTP which works flawlessly. 为了节省时间,我们只是简单地将协议切换为使用SFTP,即可正常工作。 (Switched both server and code) (同时切换服务器和代码)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM