公司有一臺vsftpd的FTP服務(wù)器,現(xiàn)需要實現(xiàn)在公司內(nèi)網(wǎng)訪問時不限速,在公司外訪問時限制速度。vsftpd的限速是通過anon_max_rate和local_max_rate來分別配置匿名用戶和授權(quán)用戶的上傳下載速度的,但這是針對所有客戶端的,如果要實現(xiàn)不同網(wǎng)段的分別限速,則需要借助于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這個功能,就可以實現(xiàn)來自不同的IP的會話加載不同的配置文件。因此也就能夠滿足我們的要求,配置步驟如下:
軟件環(huán)境: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、創(chuàng)建并編輯/etc/vsftpd/local.class,加入內(nèi)容:
anon_max_rate=0 #匿名登錄用戶
local_max_rate=0 #授權(quán)登錄用戶
設(shè)置為0代表不限速
4、創(chuàng)建并編輯/etc/vsftpd/internet.class,加入內(nèi)容:
anon_max_rate=300000 #匿名用戶的速度約300KB/s
local_max_rate=500000 #授權(quán)用戶的速度約500KB/s
重啟vsftpd服務(wù),這樣就實現(xiàn)對192.168.0.0這個網(wǎng)段不限速,其余網(wǎng)段限速的效果。
新聞熱點
疑難解答
圖片精選