LINUX网关上的流量控制
2011-12-13 16:34
155 查看
原文2008年1月30日写在MSN SPACE上
这是为公司上LINUX做的网关上的QOS设置,请自行研究,详细说明以后补上。
#!/bin/sh
CEIL=1600
tc qdisc add dev eth1 root handle 1: htb default 13
tc class add dev eth1 parent 1:1 classid 1:10 htb rate 800kbit ceil ${CEIL}kbit prio 0
tc class add dev eth1 parent 1:1 classid 1:11 htb rate 300kbit ceil ${CEIL}kbit prio 1
tc class add dev eth1 parent 1:1 classid 1:12 htb rate 200kbit ceil ${CEIL}kbit prio 2
tc class add dev eth1 parent 1:1 classid 1:13 htb rate 300kbit ceil ${CEIL}kbit prio 3
tc qdisc add dev eth1 parent 1:12 handle 120: sfq perturb 10
tc qdisc add dev eth1 parent 1:13 handle 130: sfq perturb 10
tc filter add dev eth1 parent 1:0 protocol ip prio 1 handle 1 fw classid 1:10
tc filter add dev eth1 parent 1:0 protocol ip prio 2 handle 2 fw classid 1:11
tc filter add dev eth1 parent 1:0 protocol ip prio 3 handle 3 fw classid 1:12
tc filter add dev eth1 parent 1:0 protocol ip prio 4 handle 4 fw classid 1:13
iptables -t mangle -A PREROUTING -s 192.168.1.32/29 -j MARK --set-mark 0x1
iptables -t mangle -A PREROUTING -s 192.168.1.32/29 -j RETURN
iptables -t mangle -A PREROUTING -s 192.168.1.0/28 -j MARK --set-mark 0x1
iptables -t mangle -A PREROUTING -s 192.168.1.0/28 -j RETURN
iptables -t mangle -A PREROUTING -p tcp -m tcp --tcp-flags SYN,RST,ACK SYN -j MARK --set-mark 0x1
iptables -t mangle -A PREROUTING -p tcp -m tcp --tcp-flags SYN,RST,ACK SYN -j RETURN
iptables -t mangle -A PREROUTING -p tcp -m tcp --dport 80 -j MARK --set-mark 0x2
iptables -t mangle -A PREROUTING -p tcp -m tcp --dport 80 -j RETURN
iptables -t mangle -A PREROUTING -p tcp -m tcp --dport 25 -j MARK --set-mark 0x3
iptables -t mangle -A PREROUTING -p tcp -m tcp --dport 25 -j RETURN
iptables -t mangle -A PREROUTING -p tcp -m tcp --dport 110 -j MARK --set-mark 0x3
iptables -t mangle -A PREROUTING -p tcp -m tcp --dport 110 -j RETURN
iptables -t mangle -A PREROUTING -m tos --tos Minimize-Delay -j MARK --set-mark 0x2
iptables -t mangle -A PREROUTING -m tos --tos Minimize-Delay -j RETURN
iptables -t mangle -A PREROUTING -m tos --tos Minimize-Cost -j MARK --set-mark 0x3
iptables -t mangle -A PREROUTING -m tos --tos Minimize-Cost -j RETURN
iptables -t mangle -A PREROUTING -m tos --tos Maximize-Throughput -j MARK --set-mark 0x4
iptables -t mangle -A PREROUTING -m tos --tos Maximize-Throughput -j RETURN
iptables -t mangle -A PREROUTING -j MARK --set-mark 0x4
#-----END-----
查看:tc -s class show dev eth1
这是为公司上LINUX做的网关上的QOS设置,请自行研究,详细说明以后补上。
#!/bin/sh
CEIL=1600
tc qdisc add dev eth1 root handle 1: htb default 13
tc class add dev eth1 parent 1:1 classid 1:10 htb rate 800kbit ceil ${CEIL}kbit prio 0
tc class add dev eth1 parent 1:1 classid 1:11 htb rate 300kbit ceil ${CEIL}kbit prio 1
tc class add dev eth1 parent 1:1 classid 1:12 htb rate 200kbit ceil ${CEIL}kbit prio 2
tc class add dev eth1 parent 1:1 classid 1:13 htb rate 300kbit ceil ${CEIL}kbit prio 3
tc qdisc add dev eth1 parent 1:12 handle 120: sfq perturb 10
tc qdisc add dev eth1 parent 1:13 handle 130: sfq perturb 10
tc filter add dev eth1 parent 1:0 protocol ip prio 1 handle 1 fw classid 1:10
tc filter add dev eth1 parent 1:0 protocol ip prio 2 handle 2 fw classid 1:11
tc filter add dev eth1 parent 1:0 protocol ip prio 3 handle 3 fw classid 1:12
tc filter add dev eth1 parent 1:0 protocol ip prio 4 handle 4 fw classid 1:13
iptables -t mangle -A PREROUTING -s 192.168.1.32/29 -j MARK --set-mark 0x1
iptables -t mangle -A PREROUTING -s 192.168.1.32/29 -j RETURN
iptables -t mangle -A PREROUTING -s 192.168.1.0/28 -j MARK --set-mark 0x1
iptables -t mangle -A PREROUTING -s 192.168.1.0/28 -j RETURN
iptables -t mangle -A PREROUTING -p tcp -m tcp --tcp-flags SYN,RST,ACK SYN -j MARK --set-mark 0x1
iptables -t mangle -A PREROUTING -p tcp -m tcp --tcp-flags SYN,RST,ACK SYN -j RETURN
iptables -t mangle -A PREROUTING -p tcp -m tcp --dport 80 -j MARK --set-mark 0x2
iptables -t mangle -A PREROUTING -p tcp -m tcp --dport 80 -j RETURN
iptables -t mangle -A PREROUTING -p tcp -m tcp --dport 25 -j MARK --set-mark 0x3
iptables -t mangle -A PREROUTING -p tcp -m tcp --dport 25 -j RETURN
iptables -t mangle -A PREROUTING -p tcp -m tcp --dport 110 -j MARK --set-mark 0x3
iptables -t mangle -A PREROUTING -p tcp -m tcp --dport 110 -j RETURN
iptables -t mangle -A PREROUTING -m tos --tos Minimize-Delay -j MARK --set-mark 0x2
iptables -t mangle -A PREROUTING -m tos --tos Minimize-Delay -j RETURN
iptables -t mangle -A PREROUTING -m tos --tos Minimize-Cost -j MARK --set-mark 0x3
iptables -t mangle -A PREROUTING -m tos --tos Minimize-Cost -j RETURN
iptables -t mangle -A PREROUTING -m tos --tos Maximize-Throughput -j MARK --set-mark 0x4
iptables -t mangle -A PREROUTING -m tos --tos Maximize-Throughput -j RETURN
iptables -t mangle -A PREROUTING -j MARK --set-mark 0x4
#-----END-----
查看:tc -s class show dev eth1
相关文章推荐
- linux网关之流量控制(iptables Qos)
- linux网关之流量控制(Qos)
- Linux 流量控制工具 TC 详解
- Linux 流量控制
- Linux 内核流量控制 TC 详解
- Linux中用Coyote Linux实现流量控制
- 嵌入式 Linux流量监控工具- iftop (最全面的iftop教程)以及TC命令内核流量控制
- 使用linux下的TC进行服务器流量控制
- Linux的高级路由和流量控制HOWTO中文版 网址 很棒的文章
- openwrt linux portal 实现 支持 https 支持基于时长和流量控制
- linux中用TC.来做流量控制 ZT
- Linux下用tc控制网络延时和丢包率 流量控制
- linux 流量控制全攻略(TC)
- Linux网关及安全应用之(5)漏洞检测和远程访问控制
- Linux网卡流量控制
- API网关(TYK)设置流量控制
- [置顶] Linux 流量控制
- Linux下利用TC工具控制网络流量(图)
- Linux网络流量控制工具—Netem(可用于网络故障注入)