环境:freebsd 4.5-release
在freebsd下可以通过ipfw+dumm.net来进行带宽控制,具体实现如下:
1、 修改kernel configuration file, 加入对ipfw和dumm.net的支持
options ipfirewall
options dumm.net
重新编译,安装新的kernel
注:如果原内核中支持ipfilter, 请注释 options ipfilter。
2、 新内核缺省是deny所有的连接,因此在/etc/rc.conf文件里加入以下行:
# ---------------------------------------------------------------------------
firewall_enable="yes" # set to yes to enable firewall functionality
firewall_script="/etc/rc.firewall" # which script to run to set up the firewall
firewall_type="open" # firewall type (see /etc/rc.firewall)
# ---------------------------------------------------------------------------
注:因为是测试freebsd的带宽管理, 不想在ipfw上浪费时间,因此我们将firewall设置
为open状态, 允许所有包的in, out
3、 重新启动系统,让新内核起作用。在ipfw里加入自己的rules来进行带宽管理:
# ipfw pipe 1 config bw 128kbytes/s
# ipfw add 1000 pipe 1 ip from 172.22.4.90 to 172.22.0.0/24 out
注:172.22.4.90是freebsd网卡的ip address, 172.22.0.0/16是它所在的网段
第一条rule定义了一个128kbytes/s的pipe
第二条rule 是将从172.22.4.90-〉172.22.0.0/16 的packet送到pipe 1处理
测试结果:
加入两条rule前从freebsd上下载文件速率是900k bytes/s(10m局域网)
加入两条rule后从freebsd上下载文件速率是127k bytes/s
以上只是一个很简单的测试,但从结果看freebsd下通过ipfw+dumm.net可以很好的进行带宽
的控制。大家可以参考dumm.net手册来定制更复杂的rule来满足自己的需求!
参考文档:dumm.net(4)
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器