Your Ad Here
首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 操作系统 > Linux > squid限制带宽
【标  题】:squid限制带宽
【关键字】:squid
【来  源】:http://www.cublog.cn/u/14155/showart.php?id=209993

squid限制带宽

Your Ad Here
關於設定 SQUID 的頻寬及流量限制,可利用 squid.conf 中的 delay_pools 區段來完成

delay pools 裡的 bucket 像是一個容器,而這個容器就是 squid 要控制頻寬用的,當容器到達所設定的容量時,這個容器的擁有者也無法超過我們所設定的頻寬限制,所有的 bucket 則稱為 unified bucket

Class 分為三種:
(1)Class 1:包含一個 unified bucket,而這個 bucket 是給這個 class 裡所定義的 host 使用
(2)Class 2:包含一個 unified bucket 和 255 個 buckets,每一個 bucket 分配給 8 bit 網路的使用者(255 hosts)使用 (IPv4 class C)
(3)Class 3:包含255個 buckets,每一個 bucket 分配給 16 bit 網路的使用者(65535 hosts)使用 (IPv4 class cool.gif

(1)Class 1:contains a single unified bucket which is used for all requests from hosts subject to the pool
(2)Class 2:contains one unified bucket and 255 buckets, one for each host on an 8-bit network (IPv4 class C)
(3)Class 3:contains 255 buckets for the subnets in a 16-bit network, and individual buckets for every host on these networks (IPv4 class cool.gif

推測:若 ACL 只有定義單一個 class C 區段,要限制每個 host 的單一連線流速,可使用 Class 2 來完成;但若 ACL 有定義好幾個 class C 區段,使用 Class 3 可再對各個 class C 區段做個別的總流速限制

delay_parameters 語法:
class 1 delay pool:
delay_parameters pool total
class 2 delay pool:
delay_parameters pool total per-host
class 3 delay pool:
delay_parameters pool total network per-host

每個 delay_parameters 的數值是由 restore(bytes/sec)/max(bytes) 組成,restore 是表示以 bytes/sec 的速度下載 object 到 bucket 裡,而 max 則表示 buckets 的 bytes 值
備註1:如果要設定為 unlimit speed 的話,將數值設定為 -1 即可
備註2:SQUID FAQ 中有提到,建議 max 至少要設為 restore 的兩倍 (It is recommended that the maximum is at least twice the restore value)

[設定檔格式說明]
acl all src 0.0.0.0/0.0.0.0
acl lan src 192.168.1.0/255.255.255.0 # 定義 ACL
delay_pools n # 總共有幾個 delay_pools
delay_class n1 1 # 第 n1 個 delay_pool 的種類是 Class 1
delay_class n2 3 # 第 n2 個 delay_pool 的種類是 Class 3
delay_class n3 2 # 第 n3 個 delay_pool 的種類是 Class 2
delay_access n1 allow lan
delay_access n1 deny all # 定義 delay_pool n1 的 access rule
delay_parameters n1 64000/64000 # 定義 delay_pool n1 的速度限制,依 class 的不同有不同的定義方式 (請參照上面的說明)

[範例說明]
1. 限制總流速為 512 Kbps
acl all src 0.0.0.0/0.0.0.0 # might already be defined
delay_pools 1
delay_class 1 1
delay_access 1 allow all
delay_parameters 1 64000/64000 # 512 kbits == 64 kbytes per second

2. 限制單一連線的流速為 128 Kbps
acl only128kusers src 192.168.1.0/255.255.192.0
acl all src 0.0.0.0/0.0.0.0
delay_pools 1
delay_class 1 3
delay_access 1 allow only128kusers
delay_access 1 deny all
delay_parameters 1 64000/64000 -1/-1 16000/64000

3. 對某些特定網站設定不同的流速限制 (自己試著設定的,若有錯誤請自行修改)
acl lan_use src 192.168.1.0/255.255.255.0 # 設定 LAN 使用者的 ACL
acl kkbox dstdomain .kkbox.com.tw # 設定特定網域的 ACL
delay_pools 2 # 設定兩個 delay_pools
delay_class 1 1 # 第一個是 Class 1 的,用來限制總流速
delay_class 2 2 # 第二個是 Class 2 的,用來限制單一連線流速
delay_access 1 allow kkbox
delay_access 1 deny all
delay_access 2 allow lan_use
delay_access 2 deny all
delay_parameters 1 64000/64000 # 不限制特定網域的單一連線流速,但對總流速作限制
delay_parameters 2 64000/64000 10000/50000 # 限制 LAN 的所有使用者單一連線流速,並對總流速作限制
在SX1实现linux:【上一篇】
裁减linux:【下一篇】
【相关文章】
  • 在LINUX下使用 Squid 代理服务器
  • crond实现Squid定时清理Cache
  • Squid2.6反向代理实现多个Web缓存加速--[配置文档]
  • squid-2.5STABLE13的http代理+mysql认证(mysql_auth-0.8)
  • squid详细介绍
  • (CentOS)iptables+squid透明代理+防火墙终极配置
  • 【转载】《Squid 中文权威指南》(上)-向译者彭勇华致敬!!!
  • 【转载】《Squid 中文权威指南》(下)-向译者彭勇华致敬!!!
  • Squid 日志打 Apache 兼容 combined 日志的步骤。
  • 我刚学习SQUID时的参考文档,感觉永远是经典之作。
  • 【随机文章】
  • 有人给你发东西千万要小心
  • SERV-U 6002版安全设置全攻略
  • 一个复合控件的简单例子
  • One more Quiz about String Interning
  • 武汉理工大学卓刀泉校区
  • 有关活动目录的常见问答
  • Signing a midlet suite的讨论稿[J2ME]
  • 第一个试验hello word
  • wappush,pdu Modem信息
  • VS2005开发注意事项
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 软讯网络 All Rigths Reserved.