Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3095492
  • 博文数量: 797
  • 博客积分: 10134
  • 博客等级: 上将
  • 技术积分: 9335
  • 用 户 组: 普通用户
  • 注册时间: 2006-06-22 22:57
个人简介

1

文章分类

全部博文(797)

文章存档

2022年(1)

2021年(2)

2017年(2)

2016年(1)

2015年(4)

2014年(1)

2013年(6)

2012年(6)

2011年(10)

2010年(26)

2009年(63)

2008年(61)

2007年(51)

2006年(563)

我的朋友

分类: LINUX

2006-07-26 10:22:33

linux服务器站点流量限制方案

#! /bin/sh
# Simple bandwidth limiter - <[email]j@4u.net[/email]>
# Change this to your link bandwidth
# (for cable modem, DSL links, etc. put the maximal bandwidth you can
# get, not the speed of a local Ethernet link)
REAL_BW='10Mbit'
# Change this to the bandwidth you want to allocate to WEB.
# We're talking about megabits, not megabytes, so 80Kbit is
# 10 Kilobytes/s
WEB_BW='1000Kbit'
# Change this to your physical network device (or 'ppp0')
NIC='eth0'

tc qdisc del dev "$NIC" root 2> /dev/null

tc qdisc add dev "$NIC" root handle 1: cbq \
bandwidth "$REAL_BW" avpkt 1000

tc class add dev "$NIC" parent 1: classid 1:1 cbq bandwidth "$REAL_BW" \
rate "$REAL_BW" maxburst 1 avpkt 1000

tc class add dev "$NIC" parent 1:1 classid 1:10 cbq \
bandwidth "$REAL_BW" rate "$WEB_BW" maxburst 1 avpkt 1000 bounded

tc qdisc add dev "$NIC" parent 1:10 sfq perturb 10

tc filter add dev "$NIC" parent 1: protocol ip handle 1 fw classid 1:10

iptables -t mangle -A OUTPUT -p tcp --sport 80 -j MARK --set-mark 1

阅读(1759) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~