首页 > 服务器 > Ftp服务器 > 正文

实现vsftpd对不同网段分别限速

2020-02-09 11:01:47
字体:
来源:转载
供稿:网友

公司有一台vsftpd的FTP服务器,现需要实现在公司内网访问时不限速,在公司外访问时限制速度。vsftpd的限速是通过anon_max_rate和local_max_rate来分别配置匿名用户和授权用户的上传下载速度的,但这是针对所有客户端的,如果要实现不同网段的分别限速,则需要借助于tcp_wrapper这个功能,通过man vsftpd.conf,然后查找tcp_wrapper这个选项,得到的解释如下:

If enabled, and vsftpd was compiled with tcp_wrappers support, incoming connections will be fed through tcp_wrappers access control. Furthermore, there is a mechanism for per-IP based configuration. If tcp_wrappers sets the VSFTPD_LOAD_CONF environ-ment variable, then the vsftpd session will try and load the vsftpd configuration file specified in this variable.
Default: NO

大概的意思就是如果启用tcp_wrapper这个功能,就可以实现来自不同的IP的会话加载不同的配置文件。因此也就能够满足我们的要求,配置步骤如下:

软件环境:CentOS5.7 + vsftpd2.0.5

1、编辑/etc/vsftpd/vsftpd.conf,加入: tcp_wrapper=YES

2、编辑/etc/hosts.allow,加入:
vsftpd:192.168.*.*:setenv VSFTPD_LOAD_CONF /etc/vsftpd/local.class
vsftpd:ALL:setenv VSFTPD_LOAD_CONF /etc/vsftpd/internet.class
注意顺序

3、创建并编辑/etc/vsftpd/local.class,加入内容:
anon_max_rate=0 #匿名登录用户
local_max_rate=0 #授权登录用户
设置为0代表不限速

4、创建并编辑/etc/vsftpd/internet.class,加入内容:
anon_max_rate=300000 #匿名用户的速度约300KB/s
local_max_rate=500000 #授权用户的速度约500KB/s

重启vsftpd服务,这样就实现对192.168.0.0这个网段不限速,其余网段限速的效果。

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表