NTH(翻译的官方的话)
(Every:取值范围{整数:无要求,只要是整数就行},Counter:取值范围{整数:0-15中的任意一个数,共16个},Packet:取值范围{整数:0或者1,共2个})--作用:把规则收到的第N个包匹配为一个特殊的包。16个计数器中的任何一个都可以用来统计数据包。
Every 匹配每一个第“Every+1”个通过的数据包。例如:如果Every的值为1,那么匹配的将是每一个“第二个”通的数据包。
Counter 指定你要用的计数器。规则每次统计次数的增量等于NTH匹配次数的值(意思是它每次归0重新计数的同期跟Every设定的值相等,不明白的话看上面的翻译的最后一句)
Packet 用数字标记已经统计过的数据包。很明显这个参数的取值是介于0和“Every的值”之间的一个整数。 If this option is used for a given counter, then there must be at least Every+1 rules with this option, covering all values between 0 and Every inclusively(这句话我实在是翻译不好。个人理解的是如果它被用到规则里去的话,那么应用它的规则的总数必须是"every+1",是从0开始计算到“Every的值”)
代码如下
(Every:取值范围{整数:无要求,只要是整数就行},Counter:取值范围{整数:0-15中的任意一个数,共16个},Packet:取值范围{整数:0或者1,共2个})--作用:把规则收到的第N个包匹配为一个特殊的包。16个计数器中的任何一个都可以用来统计数据包。
Every 匹配每一个第“Every+1”个通过的数据包。例如:如果Every的值为1,那么匹配的将是每一个“第二个”通的数据包。
Counter 指定你要用的计数器。规则每次统计次数的增量等于NTH匹配次数的值(意思是它每次归0重新计数的同期跟Every设定的值相等,不明白的话看上面的翻译的最后一句)
Packet 用数字标记已经统计过的数据包。很明显这个参数的取值是介于0和“Every的值”之间的一个整数。 If this option is used for a given counter, then there must be at least Every+1 rules with this option, covering all values between 0 and Every inclusively(这句话我实在是翻译不好。个人理解的是如果它被用到规则里去的话,那么应用它的规则的总数必须是"every+1",是从0开始计算到“Every的值”)
代码如下
- 代码:
#限速设置部分
/queue type
add kind=pcq name=up pcq-classifier=src-address pcq-limit=50 pcq-rate=128000 \
pcq-total-limit=2000
add kind=pcq name=down pcq-classifier=dst-address pcq-limit=50 pcq-rate=\
1000000 pcq-total-limit=2000
set default-small kind=pfifo name=default-small pfifo-limit=10
/queue simple
add burst-limit=0/0 burst-threshold=0/0 burst-time=0s/0s comment="" \
direction=download disabled=no dst-address=0.0.0.0/0 inte***ce=all \
limit-at=0/0 max-limit=1000000/10000000 name=down parent=none priority=8 \
queue=up/down target-addresses=192.168.10.0/24 total-queue=default-small
add burst-limit=0/0 burst-threshold=0/0 burst-time=0s/0s comment="" \
direction=upload disabled=no dst-address=0.0.0.0/0 inte***ce=all \
limit-at=0/0 max-limit=1000000/11000000 name=up parent=none priority=8 \
queue=up/down target-addresses=192.168.10.0/24 total-queue=default-small
#nth设置部分
/ip firewall mangle
add action=mark-connection chain=prerouting comment=nth_1 connection-state=\
new disabled=no new-connection-mark=nth_1 nth=5,1 passthrough=yes \
src-address=192.168.10.0/24
add action=mark-routing chain=prerouting comment="" connection-mark=nth_1 \
disabled=no new-routing-mark=routing_1 passthrough=no src-address=\
192.168.10.0/24
add action=mark-connection chain=prerouting comment=nth_2 connection-state=\
new disabled=no new-connection-mark=nth_2 nth=4,1 passthrough=yes \
src-address=192.168.10.0/24
add action=mark-routing chain=prerouting comment="" connection-mark=nth_2 \
disabled=no new-routing-mark=routing_2 passthrough=no src-address=\
192.168.10.0/24
add action=mark-connection chain=prerouting comment=nth_3 connection-state=\
new disabled=no new-connection-mark=nth_3 nth=3,1 passthrough=yes \
src-address=192.168.10.0/24
add action=mark-routing chain=prerouting comment="" connection-mark=nth_3 \
disabled=no new-routing-mark=routing_3 passthrough=no src-address=\
192.168.10.0/24
add action=mark-connection chain=prerouting comment=nth_4 connection-state=\
new disabled=no new-connection-mark=nth_4 nth=2,1 passthrough=yes \
src-address=192.168.10.0/24
add action=mark-routing chain=prerouting comment="" connection-mark=nth_4 \
disabled=no new-routing-mark=routing_4 passthrough=no src-address=\
192.168.10.0/24
add action=mark-connection chain=prerouting comment=nth_5 connection-state=\
new disabled=no new-connection-mark=nth_5 passthrough=yes src-address=\
192.168.10.0/24
add action=mark-routing chain=prerouting comment="" connection-mark=nth_5 \
disabled=no new-routing-mark=routing_5 passthrough=no src-address=\
192.168.10.0/24
/ip firewall nat
add action=masquerade chain=srcnat comment=1 connection-mark=nth_1 disabled=\
no out-inte***ce=pppoe-out1
add action=masquerade chain=srcnat comment=2 connection-mark=nth_2 disabled=\
no out-inte***ce=pppoe-out2
add action=masquerade chain=srcnat comment=3 connection-mark=nth_3 disabled=\
no out-inte***ce=pppoe-out3
add action=masquerade chain=srcnat comment=4 connection-mark=nth_4 disabled=\
no out-inte***ce=pppoe-out4
add action=masquerade chain=srcnat comment=5 connection-mark=nth_5 disabled=\
no out-inte***ce=pppoe-out5
add action=masquerade chain=srcnat comment=nat disabled=no
/ip route
add comment="" disabled=no distance=1 dst-address=0.0.0.0/0 gateway=\
pppoe-out2 routing-mark=routing_2
add comment="" disabled=no distance=1 dst-address=0.0.0.0/0 gateway=\
pppoe-out3 routing-mark=routing_3
add comment="" disabled=no distance=1 dst-address=0.0.0.0/0 gateway=\
pppoe-out4 routing-mark=routing_4
add comment="" disabled=no distance=1 dst-address=0.0.0.0/0 gateway=\
pppoe-out1 routing-mark=routing_1
add comment="" disabled=no distance=1 dst-address=0.0.0.0/0 gateway=\
pppoe-out5 routing-mark=routing_5