vsftpd使用standalone模式启动,其限制某些IP地址访问的方法如下:
1、重新编译 builddefs.h
vi builddefs.h
将 #undef VSF_BUILD_TCPWRAPPERS
改为 #define VSF_BUILD_TCPWRAPPERS
并重新编译。
(我的centos5.5没有builddefs.h这个文件,直接从第二步开始,也没什么问题。)
2、修改/etc/vsftpd/vsftpd.conf
添加 tcp_wrappers=YES
3、 重启vsftpd服务
service vsftpd restart
4、修改/etc/hosts.deny
加入vsftpd : ALL
5.修改/etc/hosts.allow
加入vsftpd:.admin99.net
vsftpd:192.168.0.
vsftpd:192.168.0.0/255.255.255.0
第一行表示,只有admin99.net这个域里的主机允许访问vsftpd服务,注意admin99.net前面的那个点(.);
/第二行表示,只有192.168.0这个网段的用户允许访问vsftpd服务,注意0后面的点(.);
第三行表示,只有192.168.0这个网段的用户允许访问vsftpd服务,注意这里不能写为192.168.0.0/24。
vsftpd服务是由xinetd管理的话,可以修改/etc/xinetd.d/
/vsftpd配置文件,加入only_from = 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