首页 > linux, ubuntu, xen > linux tc 对本机网卡限速

linux tc 对本机网卡限速

2010年1月25日 eric 发表评论 阅读评论

今天由于项目要测试在网络环境不好的情况下,会不会对平台有所影响,要求测试限制服务器流量,我想到了TC,我对TC不是很了解, google了一下,看到了不少文章都是做路由用的,对我来说不是很实用,因为我是对单机测试。先看看TC命令在说,没想到报错,错误如下:
shell$> tc -s qdisc
RTNETLINK answers: Invalid argument
看到这个错误很迷茫,命令是支持的啊,在网上查询了很久,发现是内核不支持,不支持QOS,不支持正常,因为我的内部测试服务器用XEN,虚拟的系统,所以我重新编译DomU内核,添加 QOS,CBQ等

环境:
xen domU : ubuntu-server 8.0.4  IP:192.168.6.101
kernel : linux-2.6.18-xen
xen dom0 : ubuntu-server 8.0.4  IP:192.168.6.209
操作:

DomU $> tc -s qdisc
RTNETLINK answers: Invalid argument

进入父系统:
Dom0 $> cd xen-3.4.2
编译xen DomU 内核
Dom0 $> make linux-2.6-xenU-config CONFIGMODE=menuconfig
选择 Networking  —>
          Networking options  —>
                QoS and/or fair queueing  —>
                      [*] QoS and/or fair queueing
把下面的最好都选上吧 * 是打入内核,M 是以模块方式。我全选择 *
选择好,保存退出

Dom0 $> make linux-2.6-xenU-build        

Dom0 $> cd xen-3.4.2/dist/install/boot

Dom0 $> scp vmlinuz-2.6.18.8-xenU root@192.168.6.101:~

好,然后进入 DomU

DomU $> ls
vmlinuz-2.6.18.8-xenU
覆盖 以前的vmlinuz-2.6.18.8-xenU
DomU $> mv vmlinuz-2.6.18.8-xenU /boot/
DomU $> reboot

重启后,在进入系统,看是否还报错:

DomU $> tc -s qdisc
好没有报错“下来我们对 服务器 1935 端口进行限速,限制为 上传下载都为50Kbit

CBQ 算法:

DomU $> tc qdisc del dev eth0 root
DomU $> tc qdisc add dev eth0 root handle 1:0 cbq bandwidth 100Mbit avpkt 1000 cell 8
DomU $> tc class add dev eth0 parent 1:0 classid 1:1 cbq bandwidth 100Mbit rate 50Kbit weight 50Kbit prio 8 allot 1514 cell 8 maxburst 20 avpkt 1000 bounded
DomU $> tc class add dev eth0 parent 1:1 classid 1:4 cbq bandwidth 100Mbit rate 50Kbit weight 50Kbit prio 5 allot 1514 cell 8 maxburst 20 avpkt 1000
DomU $> tc qdisc add dev eth0 parent 1:4 handle 40: sfq
DomU $> tc filter add dev eth0 parent 1:0 protocol ip prio 1 u32 match ip sport 1935 0xffff flowid 1:4

好了 连接 1935 试试吧`

转载请注明:文章转载自:Eric's linux and nginx! (http://www.nginxs.com)
本文地址:http://www.nginxs.com/linux/29.html

  1. 2017年11月13日16:40 | #1

    My partner and I stumbled over here by a different website and thought I might check
    things out. I like what I see so now i am following you.
    Look forward to going over your web page for a second time.

  2. 2017年11月13日19:07 | #2

    Hi there to every one, it’s in fact a nice for me to pay a visit this site,
    it includes helpful Information.

  3. 2017年11月13日21:08 | #3

    hi!,I really like your writing so a lot!
    percentage we communicate more about your article
    on AOL? I need a specialist in this house to solve my problem.
    May be that is you! Taking a look forward to see you.

  4. 2017年11月13日23:09 | #4

    Hello there! I just would like to give you a huge thumbs up for the excellent information you have here on this post.
    I’ll be coming back to your blog for more soon.

  5. 2017年11月14日17:41 | #5

    If you are than needed and your family members?

  6. 2017年11月15日15:47 | #6

    Wow! This blog looks exactly like my old one! It’s on a totally different subject
    but it has pretty much the same page layout and design.
    Outstanding choice of colors!

  7. 2017年11月16日19:59 | #7

    You happen to be worried about you and your family?

  8. 2017年11月17日08:27 | #8

    Commander Levitra Bayer online pharmacy Propecia Generico Farmacias

  9. 2017年11月20日02:47 | #9

    Propecia Grandvalira Cialis Generique France cialis price Finegra Viagra Canada Pharmacy Sells Levitra Flomax Without Prescription

  10. 2017年11月22日21:05 | #10

    I love what you guys are usually up too. This type of clever work and reporting!
    Keep up the amazing works guys I’ve added you guys to blogroll.

  11. 2017年11月27日21:52 | #11

    Amoxicillin Effect On Kidneys Amoxicillin E Cialis Cura Disfunzione Erettile levitra wholesale no prescription Genericos De Propecia 1 Mg Cephalexin Open Capsule Sprinkle

  12. 2017年12月14日01:09 | #12

    I got this site from my buddy who informed me concerning this site and now this time I am visiting this website and reading very informative articles at this time.

  13. 2017年12月25日00:01 | #13

    The “shale revolution”, probably, thoroughly masters the minds political figures and businessmen of the world. Palm superiority this area maintain US, but, apparently, there is a chance that the rest of world shortly to them to connect. Naturally, has country where virtually is carried out production of shale gas in Russia, in particular, it endeavor the main interest of political and business elites applies enough skeptical. In this issue is not so much the factor economic profitability. Major condition that has the ability to affect prospects such industries as craft of shale gas, – effects for environment.
    electricity bill cost per month

  14. 2017年12月26日13:58 | #14

    casino games list
    casino online
    online casino games
    casino online
    casino games

  15. 2017年12月29日19:54 | #15

    casino online
    casino online
    free casino games
    casino games
    casino online

  16. 2018年1月2日16:52 | #16

    Admiring the hard work you put into your website and detailed information you offer.

    It’s nice to come across a blog every once in a while that isn’t the same
    out of date rehashed material. Excellent read!
    I’ve saved your site and I’m including your RSS feeds to my Google account.

  17. 2018年1月3日20:49 | #17

    payday loans no credit check
    payday loans no credit
    loans for bad credit
    loans online
    payday loans online no credit check

  18. 2018年1月6日10:47 | #18

    What’s up Dear, are you truly visiting this web page regularly,
    if so after that you will without doubt obtain pleasant know-how.

  19. 2018年1月7日23:31 | #19

    free slots casino games
    free slot games
    casino slot games
    casino games slots
    free casino games slot machines

  20. 2018年1月12日17:14 | #20

    It’s an amazing paragraph in support of all the online
    visitors; they will obtain advantage from it I am sure.

  21. 2018年1月18日22:40 | #21

    payday loans online
    payday loans
    payday loans
    payday loans
    payday loans no credit check

  22. 2018年1月21日13:21 | #22

    casino games online real money
    sizzling 777 slots free online
    free casino games no download no registration
    online casinos for us players
    best us casinos online

评论分页
1 2 3 4 29
订阅评论
3+8= (必填)