vsftpd使用standalone模式启动,其限制某些IP地址访问的方法如下:BSD爱好者乐园"b(Xdo dS F
BSD爱好者乐园$X`AB3YV6{
1、重新编译 builddefs.h
4h-C"j F1}.J%{$Tlvi builddefs.h
4~?6a u&fqF7c将 #undef VSF_BUILD_TCPWRAPPERSBSD爱好者乐园 d.gTzo(?"g
改为 #define VSF_BUILD_TCPWRAPPERSBSD爱好者乐园-H:G ur!k7?
并重新编译BSD爱好者乐园TWHh%~。
(我的centos5.5没有builddefs.h这个文件,直接从第二步开始,也没什么问题。)
2、修改/etc/vsftpd/vsftpd.conf
{9Za'AD(^3V添加 tcp_wrappers=YES
7^h:GMlT/Er3、 重启vsftpd服务
service vsftpd restart
4、修改/etc/hosts.deny
O.Q'\R)_%D z加入vsftpd : ALLBSD爱好者乐园fg XLMQ2d4A
5.修改/etc/hosts.allow
BSD爱好者乐园x.A O:Wu
加入vsftpd:.admin99.netBSD爱好者乐园K-K&Q[1o\
vsftpd:192.168.0.
y#Y]4a1G1wC!H vsftpd:192.168.0.0/255.255.255.0
r#y*bW wMz第一行表示,只有admin99.net这个域里的主机允许访问vsftpd服务,注意admin99.net前面的那个点(.);
$gd rSM5t/第二行表示,只有192.168.0这个网段的用户允许访问vsftpd服务,注意0后面的点(.);
,eQKGC8w-O'`第三行表示,只有192.168.0这个网段的用户允许访问vsftpd服务,注意这里不能写为192.168.0.0/24。
vsftpd服务是由xinetd管理的话,可以修改/etc/xinetd.d/
/vsftpd配置文件,加入only_from = 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
vsftpd:192.168.0.125
vsftpd:192.168.0.126
转载于:https://blog.51cto.com/wuhaoshu/489684