转至繁体中文版     | 网站首页 | 图文教程 | 资源下载 | 站长博客 | 图片素材 | 武汉seo | 武汉网站优化 | 
最新公告:     敏韬网|教学资源学习资料永久免费分享站!  [mintao  2008年9月2日]        
您现在的位置: 学习笔记 >> 图文教程 >> 数据库 >> MySql >> 正文
Linux做一个功能完备的路由器 二         ★★★★

Linux做一个功能完备的路由器 二

作者:闵涛 文章来源:闵涛的学习笔记 点击数:1741 更新时间:2009/4/22 20:48:13
add $ALIAS1 dev eth0 
#$IP addr add $ALIAS2 dev eth0 
################################################## 
# Attaching a device queue discipline to an 
# interface a device queue discipline is 
# equivalent almost to a device manager 

#Attach CBQ to eth0 
#Things you might need to change: 
# bandwidth -- the bandwidth of the eth0 device 
# note it must match the devices real bandwidth 
# allot -- it is safe to leave it at the MTU of 
# the device 
# avpkt -- the average packet size that you 
# suspect will be seen safe to leave at 1000 
# for Ethernet with MTU of 1514 bytes 
# mpu -- minimum packet size 

$TC qdisc add dev eth0 root handle 1: cbq 
bandwidth 10Mbit allot 1514 cell 8 avpkt 1000 
mpu 64 
################################################## 
# Attaching class queue disciplines 
# bounded -- it is bound to the rate allocated; 
# can borrow even if there is a lot of idle 
# bandwidth just sitting there isolated -- cannot 
# share its bandwidth to other classes prio is the 
# priority assigned 0 being the highest and 7 the 
# lowest weight -- safer to leave at 1 
# queue discipline setup. Classid 1:1 will have a 
# rate of 1Mbps which is bounded. 

$TC class add dev eth0 parent 1:0 classid 1:1 cbq 
bandwidth 10Mbit rate 1Mbit avpkt 1000 prio 5 
bounded isolated allot 1514 weight 1 maxburst 21 
#rate 1Mbit avpkt 1000 prio 5 bounded allot 1514 
#weight 1 maxburst 21 
# Classid 1:2 will have a rate of 3Mbps which is 
# bounded. 
$TC class add dev eth0 parent 1:0 classid 1:2 cbq 
bandwidth 10Mbit rate 3Mbit avpkt 1000 prio 5 
bounded allot 1514 weight 1 maxburst 21 
################################################## 
# Define the filter to be attached to eth0 
# Create with hash table of 256 slots with ID 1: 

$TC filter add dev eth0 parent 1:0 protocol ip 
prio 5 handle 1: u32 divisor 256 
################################################## 
# define the criteria for mapping incoming packets 
# to classes. Add to the 5th slot of hash table a 
# rule to select virtual address ALIAS1 direct it 
# to class 1:1 

$TC filter add dev eth0 parent 1:0 prio 5 u32 
ht 1:6: match ip src $ALIAS1 flowid 1:1 
# Add to 6th slot of hash table rule to select 
# ALIAS2 direct it to class 1:2 
$TC filter add dev eth0 parent 1:0 prio 5 u32 
ht 1:6: match ip src $ALIAS2 flowid 1:2 
## Lookup hash table, if it is not fragmented 
## frame. Use protocol as hash key 

$TC filter add dev eth0 parent 1:0 prio 5 handle 
::1 u32 ht 800:: match ip nofrag 
offset mask 0x0F00 shift 6 
hashkey mask 0x00ff0000 at 8 link 1: 

#some more examples of how to use u32 
# Add to 4th slot of hash table rule to select 
# tcp/telnet to 193.233.7.75 direct it to class 
# 1:4 and prescribe to fall to best effort, 
# if traffic violates TBF (32kbit,5K) 
#$TC filter add dev eth1 parent 1:0 prio 5 u32 
# ht 1:4: match ip dst 193.233.7.75 
# match tcp dst 0x17 0xffff 
# flowid 1:4 
# police rate 32kbit buffer 5kb/8 mpu 64 
# mtu 1514 index 1 
## Add to 1st slot of hash table rule to select 
## icmp to 193.233.7.75 direct it to class 1:3 
## and prescribe to fall to best effort, 
## if traffic violate TBF (10kbit,5K) 
#$TC filter add dev eth1 parent 1:0 prio 5 u32 
# ht 1:4: match ip dst 193.233.7.75 
# match tcp dst 0x17 0xffff 
# flowid 1:4 
# police rate 32kbit buffer 5kb/8 mpu 64 
# mtu 1514 index 1 
## Add to 1st slot of hash table rule to select 
## icmp to 193.233.7.75 direct it to class 1:3 
## and prescribe to fall to best effort, 
## if traffic violate TBF (10kbit,5K) 
#$TC filter add dev eth1 parent 1:0 prio 5 u32 
# ht 1:: sample ip protocol 1 0xff 
# match ip dst 193.233.7.75 flowid 1:3 
# police rate 10kbit buffer 5kb/8 mpu 64 
# mtu 1514 index 2 
################################################## 
#Look at all that we created: 

echo "---- qdisc parameters ----------" 
$TC qdisc ls dev eth0 
echo "---- Class parameters ----------" 
$TC class ls dev eth0 
echo "---- filter parameters ----------" 
$TC filter ls dev eth0 

测试 

    我们的例子当中,是有在同一个Linux服务器上有两个虚拟WWW服务器,我们的设定是采用了IP别名,将两个地址同时绑在一个接口上。我们可以用ftp来测试。首先用ftp连接10.0.0.10服务器,我们可以获得大概1Mbps的速率;然后ftp另外的地址10.0.0.11,我们可以获得大概3Mbps的速率。 
  

责任编辑:iamafan(2001-06-11 14:03)

上一页  [1] [2] 


[常用软件]评测:Gmail Beta(二)  [VB.NET程序]走近VB.Net(二) 再谈函数调用
[VB.NET程序]把握VB.NET中的流(Stream) (二)  [Delphi程序]Integer GUID和Comb做主键的效率测试(Delphi+acce…
[网页制作]DreamwaverMX与ASP.NET(二)  [Web开发]XPDL学习与分享 二 XPDL整体结构
[Web开发]ADO.net学习纪录 (二)  [Web开发]Asp.net(vb.net)的Calendar只顯示日,一,二,三...1…
[其他]让你的应用程序不再对数据库的改动“感冒”(二)  [SyBase](转载)深入Linux网络核心堆栈 (二)
教程录入:mintao    责任编辑:mintao 
  • 上一篇教程:

  • 下一篇教程:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
      注:本站部分文章源于互联网,版权归原作者所有!如有侵权,请原作者与本站联系,本站将立即删除! 本站文章除特别注明外均可转载,但需注明出处! [MinTao学以致用网]
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)

    同类栏目
    · Sql Server  · MySql
    · Access  · ORACLE
    · SyBase  · 其他
    更多内容
    热门推荐 更多内容
  • 没有教程
  • 赞助链接
    更多内容
    闵涛博文 更多关于武汉SEO的内容
    500 - 内部服务器错误。

    500 - 内部服务器错误。

    您查找的资源存在问题,因而无法显示。

    | 设为首页 |加入收藏 | 联系站长 | 友情链接 | 版权申明 | 广告服务
    MinTao学以致用网

    Copyright @ 2007-2012 敏韬网(敏而好学,文韬武略--MinTao.Net)(学习笔记) Inc All Rights Reserved.
    闵涛 投放广告、内容合作请Q我! E_mail:admin@mintao.net(欢迎提供学习资源)

    站长:MinTao ICP备案号:鄂ICP备11006601号-18

    闵涛站盟:医药大全-武穴网A打造BCD……
    咸宁网络警察报警平台