- 论坛徽章:
- 0
|
做了一些网关, 一直是iptables + tc才能对网内每一个IP 限速! 用pf来做有点困难. 参考网上找到的许多规则, 实验了一些, 成了下面的规则, 各位可试验, 贴些自己的pf规则技巧, 让我也受益一些!
-
- ext_if="pppoe0"
- int_if="fxp1"
- set state-policy if-bound
- set block-policy return
- set optimization aggressive
- scrub in all
- altq on $ext_if hfsc bandwidth 512Kb queue { u1, u2, u3, u4, u5, u6, u7, u8, u9, u10, u11, u12, u13, u14, u15, u16, u17, u18, u19, u20, u21, u22, u23, u24, u25, u26, u27, u28, u29, u30, uother }
- queue u1 bandwidth 16Kb hfsc ( upperlimit 128Kb red )
- queue u2 bandwidth 16Kb hfsc ( upperlimit 128Kb red )
- queue u3 bandwidth 16Kb hfsc ( upperlimit 128Kb red )
- queue u4 bandwidth 16Kb hfsc ( upperlimit 128Kb red )
- queue u5 bandwidth 16Kb hfsc ( upperlimit 128Kb red )
- queue u6 bandwidth 16Kb hfsc ( upperlimit 128Kb red )
- queue u7 bandwidth 16Kb hfsc ( upperlimit 128Kb red )
- queue u8 bandwidth 16Kb hfsc ( upperlimit 128Kb red )
- queue u9 bandwidth 16Kb hfsc ( upperlimit 128Kb red )
- queue u10 bandwidth 16Kb hfsc ( upperlimit 128Kb red )
- queue u11 bandwidth 16Kb hfsc ( upperlimit 128Kb red )
- queue u12 bandwidth 16Kb hfsc ( upperlimit 128Kb red )
- queue u13 bandwidth 16Kb hfsc ( upperlimit 128Kb red )
- queue u14 bandwidth 16Kb hfsc ( upperlimit 128Kb red )
- queue u15 bandwidth 16Kb hfsc ( upperlimit 128Kb red )
- queue u16 bandwidth 16Kb hfsc ( upperlimit 128Kb red )
- queue u17 bandwidth 16Kb hfsc ( upperlimit 128Kb red )
- queue u18 bandwidth 16Kb hfsc ( upperlimit 128Kb red )
- queue u19 bandwidth 16Kb hfsc ( upperlimit 128Kb red )
- queue u20 bandwidth 16Kb hfsc ( upperlimit 128Kb red )
- queue u21 bandwidth 16Kb hfsc ( upperlimit 128Kb red )
- queue u22 bandwidth 16Kb hfsc ( upperlimit 128Kb red )
- queue u23 bandwidth 16Kb hfsc ( upperlimit 128Kb red )
- queue u24 bandwidth 16Kb hfsc ( upperlimit 128Kb red )
- queue u25 bandwidth 16Kb hfsc ( upperlimit 128Kb red )
- queue u26 bandwidth 16Kb hfsc ( upperlimit 128Kb red )
- queue u27 bandwidth 16Kb hfsc ( upperlimit 128Kb red )
- queue u28 bandwidth 16Kb hfsc ( upperlimit 128Kb red )
- queue u29 bandwidth 16Kb hfsc ( upperlimit 128Kb red )
- queue u30 bandwidth 16Kb hfsc ( upperlimit 128Kb red )
- queue uother bandwidth 32Kb hfsc ( default upperlimit 128Kb )
- altq on $int_if hfsc bandwidth 2Mb queue{ c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30, other }
- queue c1 bandwidth 64Kb hfsc( upperlimit 512Kb red )
- queue c2 bandwidth 64Kb hfsc( upperlimit 512Kb red )
- queue c3 bandwidth 64Kb hfsc( upperlimit 512Kb red )
- queue c4 bandwidth 64Kb hfsc( upperlimit 512Kb red )
- queue c5 bandwidth 64Kb hfsc( upperlimit 512Kb red )
- queue c6 bandwidth 64Kb hfsc( upperlimit 512Kb red )
- queue c7 bandwidth 64Kb hfsc( upperlimit 512Kb red )
- queue c8 bandwidth 64Kb hfsc( upperlimit 512Kb red )
- queue c9 bandwidth 64Kb hfsc( upperlimit 512Kb red )
- queue c10 bandwidth 64Kb hfsc( upperlimit 512Kb red )
- queue c11 bandwidth 64Kb hfsc( upperlimit 512Kb red )
- queue c12 bandwidth 64Kb hfsc( upperlimit 512Kb red )
- queue c13 bandwidth 64Kb hfsc( upperlimit 512Kb red )
- queue c14 bandwidth 64Kb hfsc( upperlimit 512Kb red )
- queue c15 bandwidth 64Kb hfsc( upperlimit 512Kb red )
- queue c16 bandwidth 64Kb hfsc( upperlimit 512Kb red )
- queue c17 bandwidth 64Kb hfsc( upperlimit 512Kb red )
- queue c18 bandwidth 64Kb hfsc( upperlimit 512Kb red )
- queue c19 bandwidth 64Kb hfsc( upperlimit 512Kb red )
- queue c20 bandwidth 64Kb hfsc( upperlimit 512Kb red )
- queue c21 bandwidth 64Kb hfsc( upperlimit 512Kb red )
- queue c22 bandwidth 64Kb hfsc( upperlimit 512Kb red )
- queue c23 bandwidth 64Kb hfsc( upperlimit 512Kb red )
- queue c24 bandwidth 64Kb hfsc( upperlimit 512Kb red )
- queue c25 bandwidth 64Kb hfsc( upperlimit 512Kb red )
- queue c26 bandwidth 64Kb hfsc( upperlimit 512Kb red )
- queue c27 bandwidth 64Kb hfsc( upperlimit 512Kb red )
- queue c28 bandwidth 64Kb hfsc( upperlimit 512Kb red )
- queue c29 bandwidth 64Kb hfsc( upperlimit 512Kb red )
- queue c30 bandwidth 64Kb hfsc( upperlimit 512Kb red )
- queue other bandwidth 80Kb hfsc( default upperlimit 128Kb)
- nat on $ext_if from $int_if:network to any -> ($ext_if)
- block all
- block quick inet6 all
- pass quick on lo0 all
- antispoof for $ext_if
- pass in on $ext_if inet proto tcp from any to ($ext_if) port ssh flags S/SA keep state
- pass in quick on $int_if inet from 192.168.1.2 to any keep state tag 192.168.1.2 queue c1
- pass out quick on $ext_if inet all keep state tagged 192.168.1.2 queue u1
- pass in quick on $int_if inet from 192.168.1.3 to any keep state tag 192.168.1.3 queue c2
- pass out quick on $ext_if inet all keep state tagged 192.168.1.3 queue u2
- pass in quick on $int_if inet from 192.168.1.4 to any keep state tag 192.168.1.4 queue c3
- pass out quick on $ext_if inet all keep state tagged 192.168.1.4 queue u3
- pass in quick on $int_if inet from 192.168.1.5 to any keep state tag 192.168.1.5 queue c4
- pass out quick on $ext_if inet all keep state tagged 192.168.1.5 queue u4
- pass in quick on $int_if inet from 192.168.1.6 to any keep state tag 192.168.1.6 queue c5
- pass out quick on $ext_if inet all keep state tagged 192.168.1.6 queue u5
- pass in quick on $int_if inet from 192.168.1.7 to any keep state tag 192.168.1.7 queue c6
- pass out quick on $ext_if inet all keep state tagged 192.168.1.7 queue u6
- pass in quick on $int_if inet from 192.168.1.8 to any keep state tag 192.168.1.8 queue c7
- pass out quick on $ext_if inet all keep state tagged 192.168.1.8 queue u7
- pass in quick on $int_if inet from 192.168.1.9 to any keep state tag 192.168.1.9 queue c8
- pass out quick on $ext_if inet all keep state tagged 192.168.1.9 queue u8
- pass in quick on $int_if inet from 192.168.1.10 to any keep state tag 192.168.1.10 queue c9
- pass out quick on $ext_if inet all keep state tagged 192.168.1.10 queue u9
- pass in quick on $int_if inet from 192.168.1.11 to any keep state tag 192.168.1.11 queue c10
- pass out quick on $ext_if inet all keep state tagged 192.168.1.11 queue u10
- pass in quick on $int_if inet from 192.168.1.12 to any keep state tag 192.168.1.12 queue c11
- pass out quick on $ext_if inet all keep state tagged 192.168.1.12 queue u11
- pass in quick on $int_if inet from 192.168.1.13 to any keep state tag 192.168.1.13 queue c12
- pass out quick on $ext_if inet all keep state tagged 192.168.1.13 queue u12
- pass in quick on $int_if inet from 192.168.1.14 to any keep state tag 192.168.1.14 queue c13
- pass out quick on $ext_if inet all keep state tagged 192.168.1.14 queue u13
- pass in quick on $int_if inet from 192.168.1.18 to any keep state tag 192.168.1.18 queue c14
- pass out quick on $ext_if inet all keep state tagged 192.168.1.18 queue u14
- pass in quick on $int_if inet from 192.168.1.19 to any keep state tag 192.168.1.19 queue c15
- pass out quick on $ext_if inet all keep state tagged 192.168.1.19 queue u15
- pass in quick on $int_if inet from 192.168.1.20 to any keep state tag 192.168.1.20 queue c16
- pass out quick on $ext_if inet all keep state tagged 192.168.1.20 queue u16
- pass in quick on $int_if inet from 192.168.1.21 to any keep state tag 192.168.1.21 queue c17
- pass out quick on $ext_if inet all keep state tagged 192.168.1.21 queue u17
- pass in quick on $int_if inet from 192.168.1.22 to any keep state tag 192.168.1.22 queue c18
- pass out quick on $ext_if inet all keep state tagged 192.168.1.22 queue u18
- pass in quick on $int_if inet from 192.168.1.23 to any keep state tag 192.168.1.23 queue c19
- pass out quick on $ext_if inet all keep state tagged 192.168.1.23 queue u19
- pass in quick on $int_if inet from 192.168.1.24 to any keep state tag 192.168.1.24 queue c20
- pass out quick on $ext_if inet all keep state tagged 192.168.1.24 queue u20
- pass in quick on $int_if inet from 192.168.1.25 to any keep state tag 192.168.1.25 queue c21
- pass out quick on $ext_if inet all keep state tagged 192.168.1.25 queue u21
- pass in quick on $int_if inet from 192.168.1.26 to any keep state tag 192.168.1.26 queue c22
- pass out quick on $ext_if inet all keep state tagged 192.168.1.26 queue u22
- pass in quick on $int_if inet from 192.168.1.27 to any keep state tag 192.168.1.27 queue c23
- pass out quick on $ext_if inet all keep state tagged 192.168.1.27 queue u23
- pass in quick on $int_if inet from 192.168.1.28 to any keep state tag 192.168.1.28 queue c24
- pass out quick on $ext_if inet all keep state tagged 192.168.1.28 queue u24
- pass in quick on $int_if inet from 192.168.1.29 to any keep state tag 192.168.1.29 queue c25
- pass out quick on $ext_if inet all keep state tagged 192.168.1.29 queue u25
- pass in quick on $int_if inet from 192.168.1.30 to any keep state tag 192.168.1.30 queue c26
- pass out quick on $ext_if inet all keep state tagged 192.168.1.30 queue u26
复制代码 |
|