1.vsftpd 的设置。
listen_port=10000
pasv_enable=YES
pasv_max_port=10003
pasv_min_port=10001
pasv_address=VPS公网IP
这一步似乎是关键。
我用的是被动模式,之前 Filezilla 出现过 “读取目录列表失败”的错误。是因为 FTP 被动模式 会产生随机端口,而这些随机端口无法让 frp 知道。所以需要 通过 ‘pasv_max_port’ 和 ‘pasv_min_port’ 设置随机端口的范围,把范围内的端口填到 frpc.ini 里。
P.S. ‘pasv_max_port’ 一定要比 ‘pasv_min_port’ 大,否则无法生效,也没有错误提示,我就是因为眼花填错了,折腾了好久……
也出现过“服务器发回了不可路由的地址”,是因为 vsftp 被动模式返回的是二级路由 WAN 口的网址,192.168.1.1。所以需要 pasv_address 设置成 VPS 的公网 IP。
2.frps.ini 的设置。
设置了 bind_port,privilege_token。
3.frpc.ini 的设置。
设置好 bind_port,privilege_token,与 frps.ini 相同。
打开 10000,10001,10002,10003 端口。
4.VPS 的设置。
iptables 打开 10000,10001,10002,10003 端口,和 bind_port 端口。
vsftp限制ip地址访问
附录:
限制ftp与ssh服务的访问IP
1、修改文件:/etc/hosts.deny,加上最后两行,阻止所以进入,如下:
# hosts.deny This file describes the names of the hosts which are
# *not* allowed to use the local INET services, as decided
# by the ‘/usr/sbin/tcpd’ server.
#
# The portmap line is redundant, but it is left to remind you that
# the new secure portmap uses hosts.deny and hosts.allow. In particular
# you should know that NFS uses portmap!
sshd:ALL
vsftpd:ALL
2、修改 /etc/hosts.allow,加上允许访问的IP,如下:
#
# hosts.allow This file describes the names of the hosts which are
# allowed to use the local INET services, as decided
# by the ‘/usr/sbin/tcpd’ server.
#
#sshd
sshd:192.168.0.125
sshd:192.168.0.126
#vsfptd
vsftpd:192.168.0.125
vsftpd:192.168.0.126
最新评论