在測試 FTP Server 是否可以正常連線時,通常都是用指令模式來測試,後來在 Windows 平台上用 FileZilla / Xftp 時,才發現無法連線,測試一下,原來是 FTP Server 沒有設定成被動模式,而防火牆中也沒有開啟 FTP Server 被動模式所要用的 Port。
底下是以 FileZilla 做測試
在 FTP Server 和 iptables 防火牆沒做任何設定時
解決方式:
1. ProFTPd FTP Server 連線埠可以自訂
# vim /etc/proftpd.conf
PassivePorts                    60000   61000
重新啟動 FTP Server
# service proftpd restart
正在關閉 proftpd:                                         [  確定  ]
正在啟動 proftpd:                                         [  確定  ]
修改防火牆設定
# vim /etc/sysconfig/iptables
-A INPUT -m state –state NEW -m tcp -p tcp –dport 60000:61000 -j ACCEPT
重新啟動 iptables 防火牆
# service iptables stop
iptables:正在設定 chains 為 ACCEPT 政策:filter           [  確定  ]
iptables:正在清除防火牆規則:                             [  確定  ]
iptables:正在卸載模組:                                   [  確定  ]
# service iptables start
iptables:正在套用防火牆規則:                             [  確定  ]
檢查規則是否有產生
# iptables -L -n
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  —  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED
ACCEPT     icmp —  0.0.0.0/0            0.0.0.0/0
ACCEPT     all  —  0.0.0.0/0            0.0.0.0/0
ACCEPT     tcp  —  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:22
ACCEPT     tcp  —  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:21
ACCEPT     tcp  —  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpts:60000:61000
REJECT     all  —  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited
Chain FORWARD (policy ACCEPT)
target     prot opt source               destination
REJECT     all  —  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited
Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination









