找回密码
 注册

QQ登录

只需一步,快速开始

搜索
楼主: bfrader

限制连接数与限制带宽的效果比较

[复制链接]
发表于 2008-1-24 14:35:03 | 显示全部楼层
没用,UDP是无连接的,所有的P2P都同时走TCP和UDP
routeros
回复

使用道具 举报

 楼主| 发表于 2008-1-27 21:13:58 | 显示全部楼层

UDP可以用限制带宽解决,因为UDP是无连接的,所以不会占用我们有限的连接数
routeros
回复

使用道具 举报

发表于 2008-2-6 16:00:58 | 显示全部楼层
原来bfw3.0中根本就没有expr这个表达式命令,所以从minifw中复制出来,ftp到bfw的/usr/bin中,执行chmod +x /usr/bin/expr ,然后就可以使用 a=`expr $a "+" 1`这样的shell语句了。

红色的这个不太明白```加个限制这么麻烦吗?
刚传到FTP上下载的时候下到mnt目录里面去了,怎么把它删除呢?
我个人理解是这样的
在BFW命令下执行cd /usr/bin
把expr上传到FTP,在BFW命令下执行wget ftp://xxx.xxx.xxx.xxx/expr
在BFW命令下执行chmod +x /usr/bin/expr
再进入WEB页面保存。进入WEB页面加入连接限制对吗?有不对的地方希望大家帮忙说下谢谢``
routeros
回复

使用道具 举报

 楼主| 发表于 2008-2-24 12:43:44 | 显示全部楼层
a=`expr $a "+" 1`
因为shell语言中没有直接对变量进行加减的语句,所以只能把变量参数和操作参数传给linux的表达式命令expr,计算后又把结果传回来。
expr $a "+" 1就是对表达式$a "+" 1进行计算,输出结果。在shell中对shell外部命令的调用要用`  `括起来。
你的操作步骤不错,但是不能把expr保存在/usr/bin中,因为我试过,即使保存过,重启后还会丢失,所以我保存在/etc中

[ 本帖最后由 bfrader 于 2008-2-24 12:45 编辑 ]
routeros
回复

使用道具 举报

发表于 2008-2-26 10:44:13 | 显示全部楼层
请问下我这样是不是加载成功呢?
Local Custom Firewall rules

Level 7 Filtering example:
iptables -t mangle -A POSTROUTING -m layer7 --l7proto edonkey -j DROP
iptables -I FORWARD -p tcp -s 192.168.0.11 -m connlimit --connlimit-above 25 -j REJECT
iptables -I FORWARD -p tcp -s 192.168.0.9 -m connlimit --connlimit-above 10 -j REJECT

Attention: To enable the commands below can cause some side effects
Syn-flood and DOS protection
iptables -A FORWARD -p tcp --syn -m limit --limit 1/s -j ACCEPT
Port Scanners protection
iptables -A FORWARD -p tcp --tcp-flags SYN,ACK,FIN,RST RST -m limit --limit 1/s -j ACCEPT
iptables -A FORWARD -p tcp --tcp-flags ALL SYN,ACK -j DROP
Ping-of-dead protection
iptables -A FORWARD -p icmp --icmp-type echo-request -m limit --limit 1/s -j ACCEPT

Speed UP DNS
iptables -t mangle -A OUTPUT -p udp --dport 53 -j TOS --set-tos 0x08
iptables -t mangle -A PREROUTING -p udp --dport 53 -j TOS --set-tos 0x10

Speed UP HTTP
iptables -t mangle -A OUTPUT -p tcp -j TOS --sport 80 --set-tos 0x08
iptables -t mangle -A PREROUTING -p tcp --dport 80 -j TOS --set-tos 0x08
iptables -t mangle -A OUTPUT -p tcp -j TOS --sport 80 --set-tos 0x10

ipt_connlimit
iptables -I FORWARD -p tcp -s 192.168.0.11 -m connlimit --connlimit-above 25 -j REJECT
iptables -I FORWARD -p tcp -s 192.168.0.9 -m connlimit --connlimit-above 10 -j REJECT

iptables -I FORWARD -p tcp -s 192.168.0.$a -m connlimit --connlimit-above 20 -j REJECT
iptables -I INPUT -p tcp -s 192.168.0.$a -m connlimit --connlimit-above 20 -j REJECT
a=`expr $a "+" 1`
这是我加载的内容


Chain INPUT (policy ACCEPT 58364 packets, 4099K bytes)
pkts bytes target     prot opt in     out     source               destination         
686K   51M accounting  all  --  *      *       0.0.0.0/0            0.0.0.0/0           
    0     0 REJECT     tcp  --  *      *       202.111.148.132      0.0.0.0/0           #conn/32 > 20 reject-with icmp-port-unreachable
46827   12M ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED
3183  263K DROP       all  --  *      *       0.0.0.0/0            0.0.0.0/0           state INVALID
636K   39M remote-admin  all  --  *      *       0.0.0.0/0            0.0.0.0/0           
636K   39M user-filter  all  --  *      *       0.0.0.0/0            0.0.0.0/0           
636K   39M if-filter  all  --  *      *       0.0.0.0/0            0.0.0.0/0           state NEW

Chain FORWARD (policy ACCEPT 538K packets, 37M bytes)
pkts bytes target     prot opt in     out     source               destination         
  613  191K ACCEPT     tcp  --  *      *       0.0.0.0/0            192.168.0.135       tcp dpt:80
3276  202K ACCEPT     udp  --  *      *       0.0.0.0/0            192.168.0.20        udp dpt:20191
   14   672 ACCEPT     tcp  --  *      *       0.0.0.0/0            192.168.0.20        tcp dpt:80
  754  546K ACCEPT     tcp  --  *      *       0.0.0.0/0            192.168.0.133       tcp dpt:80
  804  475K ACCEPT     tcp  --  *      *       0.0.0.0/0            192.168.0.133       tcp dpt:80
2444 1656K ACCEPT     udp  --  *      *       0.0.0.0/0            192.168.0.24        udp dpt:15000
    0     0 ACCEPT     tcp  --  *      *       0.0.0.0/0            192.168.0.24        tcp dpt:80
  11M 1022M ACCEPT     udp  --  *      *       0.0.0.0/0            192.168.0.128       udp dpt:4168
147K   17M ACCEPT     tcp  --  *      *       0.0.0.0/0            192.168.0.128       tcp dpt:4043
490K   70M ACCEPT     udp  --  *      *       0.0.0.0/0            192.168.0.128       udp dpt:4168
20311 1896K ACCEPT     tcp  --  *      *       0.0.0.0/0            192.168.0.128       tcp dpt:4043
    5   325 ACCEPT     udp  --  *      *       0.0.0.0/0            192.168.0.128       udp dpt:15000
   86  4618 ACCEPT     udp  --  *      *       0.0.0.0/0            192.168.0.36        udp dpt:15000
    0     0 ACCEPT     tcp  --  *      *       0.0.0.0/0            192.168.0.36        tcp dpt:80
  161  8593 ACCEPT     udp  --  *      *       0.0.0.0/0            192.168.0.18        udp dpt:15000
    0     0 ACCEPT     tcp  --  *      *       0.0.0.0/0            192.168.0.18        tcp dpt:80
446K  464M ACCEPT     udp  --  *      *       0.0.0.0/0            192.168.0.121       udp dpt:1
35641 6892K ACCEPT     tcp  --  *      *       0.0.0.0/0            192.168.0.121       tcp dpt:1
624K  702M ACCEPT     udp  --  *      *       0.0.0.0/0            192.168.0.34        udp dpt:15000
15686 9335K ACCEPT     tcp  --  *      *       0.0.0.0/0            192.168.0.34        tcp dpt:80
    0     0 ACCEPT     tcp  --  *      *       0.0.0.0/0            192.168.0.254       tcp dpt:44501
    0     0 ACCEPT     tcp  --  *      *       0.0.0.0/0            192.168.0.254       tcp dpt:44500
    0     0 ACCEPT     tcp  --  *      *       0.0.0.0/0            192.168.0.254       tcp dpt:21
349K  325M ACCEPT     udp  --  *      *       0.0.0.0/0            192.168.0.130       udp dpt:15000
43373   20M ACCEPT     tcp  --  *      *       0.0.0.0/0            192.168.0.130       tcp dpt:80
9921 7493K ACCEPT     tcp  --  *      *       0.0.0.0/0            192.168.0.132       tcp dpt:80
27969   23M ACCEPT     tcp  --  *      *       0.0.0.0/0            192.168.0.120       tcp dpt:1
419K  460M ACCEPT     udp  --  *      *       0.0.0.0/0            192.168.0.130       udp dpt:15000
39760   18M ACCEPT     tcp  --  *      *       0.0.0.0/0            192.168.0.130       tcp dpt:80
  116  6166 ACCEPT     tcp  --  *      *       0.0.0.0/0            192.168.0.130       tcp dpt:80
92291   54M ACCEPT     udp  --  *      *       0.0.0.0/0            192.168.0.35        udp dpt:15000
13112 3606K ACCEPT     tcp  --  *      *       0.0.0.0/0            192.168.0.35        tcp dpt:80
  42M   28G ipacc      all  --  *      *       0.0.0.0/0            0.0.0.0/0           
  42M   28G accounting  all  --  *      *       0.0.0.0/0            0.0.0.0/0           
    0     0 REJECT     tcp  --  *      *       202.111.148.132      0.0.0.0/0           #conn/32 > 20 reject-with icmp-port-unreachable
  502 27646 REJECT     tcp  --  *      *       192.168.0.9          0.0.0.0/0           #conn/32 > 10 reject-with icmp-port-unreachable
    0     0 REJECT     tcp  --  *      *       192.168.0.11         0.0.0.0/0           #conn/32 > 25 reject-with icmp-port-unreachable
    0     0 REJECT     tcp  --  *      *       192.168.0.9          0.0.0.0/0           #conn/32 > 10 reject-with icmp-port-unreachable
    0     0 REJECT     tcp  --  *      *       192.168.0.11         0.0.0.0/0           #conn/32 > 25 reject-with icmp-port-unreachable
  41M   28G ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED
    0     0 DROP       all  --  *      *       0.0.0.0/0            0.0.0.0/0           state INVALID
591K   40M access-acl  all  --  *      *       0.0.0.0/0            0.0.0.0/0           
591K   40M autofw-acl  all  --  *      *       0.0.0.0/0            0.0.0.0/0           
591K   40M portfw-acl  all  --  *      *       0.0.0.0/0            0.0.0.0/0           
590K   40M user-filter  all  --  *      *       0.0.0.0/0            0.0.0.0/0           
590K   40M port-filter  all  --  *      *       0.0.0.0/0            0.0.0.0/0           
590K   40M if-filter  all  --  *      *       0.0.0.0/0            0.0.0.0/0           state NEW
34875 1789K ACCEPT     tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           tcp flags:0x17/0x02 limit: avg 1/sec burst 5
    6   240 ACCEPT     tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           tcp flags:0x17/0x04 limit: avg 1/sec burst 5
  178  8736 DROP       tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           tcp flags:0x3F/0x12
17239 1166K ACCEPT     icmp --  *      *       0.0.0.0/0            0.0.0.0/0           icmp type 8 limit: avg 1/sec burst 5

Chain OUTPUT (policy ACCEPT 65705 packets, 12M bytes)
pkts bytes target     prot opt in     out     source               destination         
65555   12M accounting  all  --  *      *       0.0.0.0/0            0.0.0.0/0           

Chain access-acl (1 references)
pkts bytes target     prot opt in     out     source               destination         

Chain accounting (3 references)
pkts bytes target     prot opt in     out     source               destination         
  17M   15G RETURN     all  --  eth1   *       0.0.0.0/0            0.0.0.0/0           
  26M   13G RETURN     all  --  *      eth1    0.0.0.0/0            0.0.0.0/0           
168K   27M RETURN     all  --  *      *       0.0.0.0/0            0.0.0.0/0           

Chain autofw-acl (1 references)
pkts bytes target     prot opt in     out     source               destination         

Chain if-filter (2 references)
pkts bytes target     prot opt in     out     source               destination         
578K   35M log-and-drop  all  --  eth1   *       0.0.0.0/0            0.0.0.0/0           

Chain ipacc (1 references)
pkts bytes target     prot opt in     out     source               destination         
  42M   28G RETURN     all  --  *      *       0.0.0.0/0            0.0.0.0/0           

Chain log-and-drop (1 references)
pkts bytes target     prot opt in     out     source               destination         
578K   35M DROP       all  --  *      *       0.0.0.0/0            0.0.0.0/0           

Chain port-filter (1 references)
pkts bytes target     prot opt in     out     source               destination         

Chain portfw-acl (1 references)
pkts bytes target     prot opt in     out     source               destination         
  258 12384 ACCEPT     tcp  --  *      *       0.0.0.0/0            192.168.0.254       tcp dpt:88

Chain remote-admin (1 references)
pkts bytes target     prot opt in     out     source               destination         
    0     0 ACCEPT     tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           tcp spts:1024:65535 dpt:6689

Chain user-filter (2 references)
pkts bytes target     prot opt in     out     source               destination         

这是我防火墙内容```
routeros
回复

使用道具 举报

发表于 2008-3-1 20:29:57 | 显示全部楼层

.......当心iptables被贴死。

256行过滤策略
routeros
回复

使用道具 举报

发表于 2008-3-1 21:46:21 | 显示全部楼层
呵呵```米事```速度不赖
未命名.jpg
routeros
回复

使用道具 举报

发表于 2008-9-23 07:43:52 | 显示全部楼层
如果打开一个有很多嵌入网页的网站,是不是会使用多个连接?我试了限制为20个连接,很多网页都打不开了,速度也很慢。
routeros
回复

使用道具 举报

发表于 2008-10-6 23:03:42 | 显示全部楼层
限 20 开2个 sina之类的网站就会打不开.
routeros
回复

使用道具 举报

 楼主| 发表于 2008-10-27 14:54:13 | 显示全部楼层
你可以试试尽量放宽,只要不影响整体网速就行
routeros
回复

使用道具 举报

发表于 2008-10-29 08:34:34 | 显示全部楼层
原帖由 bfrader 于 2008-2-24 12:43 发表
a=`expr $a "+" 1`
因为shell语言中没有直接对变量进行加减的语句,所以只能把变量参数和操作参数传给linux的表达式命令expr,计算后又把结果传回来。
expr $a "+" 1就是对表达式$a "+" 1进行计算,输出结果。在sh ...

expr文件的保存是个问题,在/usr/bin中无法保存,因为重启后丢失。在/etc中能保存,但重启后无法使用,或者是我不知道如何使用?怎样才能让BFW重启后expr自动生效呢?
routeros
回复

使用道具 举报

发表于 2009-4-23 22:02:40 | 显示全部楼层
这样的帖子不顶不行,楼主是个高手,有问题想请教一下,我的QQ是11381901,谢谢!
routeros
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|手机版|小黑屋|软路由 ( 渝ICP备15001194号-1|渝公网安备 50011602500124号 )

GMT+8, 2024-5-20 16:43 , Processed in 0.096455 second(s), 7 queries , Gzip On, Redis On.

Powered by Discuz! X3.5 Licensed

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表