{"id":242,"date":"2010-06-22T16:11:18","date_gmt":"2010-06-22T13:11:18","guid":{"rendered":"http:\/\/skeletor.org.ua\/?p=242"},"modified":"2022-12-07T14:08:03","modified_gmt":"2022-12-07T12:08:03","slug":"ipfw-%d1%88%d0%b5%d0%b9%d0%bf%d0%b8%d0%bc-%d1%82%d1%80%d0%b0%d1%84%d0%b8%d0%ba","status":"publish","type":"post","link":"https:\/\/skeletor.org.ua\/?p=242","title":{"rendered":"[ipfw] \u0428\u0435\u0439\u043f\u0438\u043c \u0442\u0440\u0430\u0444\u0438\u043a"},"content":{"rendered":"<p>\u0412\u043e\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0440\u0430\u0432\u0438\u043b \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u0434\u043b\u044f \u0443\u0434\u0430\u0447\u043d\u043e\u0433\u043e \u0448\u0435\u0439\u043f\u0438\u043d\u0433\u0430 (\u0448\u0435\u0439\u043f\u0438\u043d\u0433 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435\u00a0<strong>1\u041c\u0431\u0438\u0442\/\u0441<\/strong>, \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043d\u0430 \u0438\u0441\u0445\u043e\u0434 \u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043d\u0430 \u0432\u0445\u043e\u0434):<\/p>\n<p><!--more--><\/p>\n<p><code>ipfw add 1101 pipe 1 all from 1.1.1.1 to any<br \/>\nipfw add 1102 pipe 1 all from any to 1.1.1.1<br \/>\nipfw pipe 1 config bw 1Mbit\/s<\/code><\/p>\n<p>\u0415\u0449\u0451 \u043d\u0443\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439\u00a0<strong>net.inet.ip.fw.one_pass=0<\/strong> \u0432\u00a0<strong>sysctl<\/strong> (\u043f\u043e \u0434\u0435\u0444\u043e\u043b\u0442\u0443 \u0441\u0442\u043e\u0438\u0442 \u0432 1). \u042d\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0431\u044b \u043f\u043e\u0441\u043b\u0435 \u043f\u0440\u043e\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0448\u0435\u0439\u043f\u0438\u043d\u0433\u0430 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u043b\u0438\u0441\u044c \u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 (\u0432 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u0447\u0438\u0442\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u043f\u043e\u0441\u043b\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0448\u0435\u0439\u043f\u0430 \u0438\u0434\u0451\u0442 \u043f\u0440\u0430\u0432\u0438\u043b\u043e\u00a0<strong>ipfw add allow from any to any<\/strong>)<\/p>\n<p>\u0422\u0430\u043a \u0436\u0435, \u043d\u0435\u043c\u0430\u043b\u043e\u0432\u0430\u0436\u043d\u044b\u043c \u0444\u0430\u043a\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432 \u043d\u0430\u0447\u0430\u043b\u043e \u0444\u0430\u0439\u043b\u0430 \u0441 \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c\u0438 \u0441\u0431\u0440\u043e\u0441 \u0432\u0441\u0435\u0445 <strong>pip&#8217;\u043e\u0432<\/strong>:<\/p>\n<p><code>ipfw -f pipe flush<br \/>\nipfw -f queue flush<\/code><\/p>\n<p>\u0412\u0440\u043e\u0434\u0435 \u0431\u044b \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u0430 (\u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441\u00a0<strong>FreeBSD 7.0<\/strong>), \u043d\u043e \u043f\u0438\u0448\u0443 \u043e\u0431\u0430 \ud83d\ude42<\/p>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e <strong>IP<\/strong> \u0432 \u043b\u043e\u043a\u0430\u043b\u043a\u0435 \u0438 \u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0430\u0440\u0443 10-\u043a\u043e\u0432 \u0438\u043b\u0438 \u0441\u043e\u0442\u0435\u043d \u043f\u0440\u0430\u0432\u0438\u043b \u043d\u0435 \u0445\u043e\u0447\u0435\u0442\u0441\u044f, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a\u0443\u044e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e:<\/p>\n<p><code>ipfw pipe 1 config bw 64Kbit\/s mask src-ip 0xffffffff<br \/>\nipfw pipe 2 config bw 64Kbit\/s mask dst-ip 0xffffffff<\/code><\/p>\n<p><code>ipfw add pipe 1 all from 10.5.0.0\/24 to any<br \/>\nipfw add pipe 2 all from any to 10.5.0.0\/24<\/code><\/p>\n<p><strong><em><span style=\"color: #ff6600;\">\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/span><\/em><\/strong><\/p>\n<p>\u041f\u0440\u0438\u0432\u0435\u0434\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043c\u0430\u0441\u043e\u043a \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0439:<\/p>\n<p><strong>&#8211; 0\u00d700000000\u00a0<\/strong>\u2013 \u043e\u0434\u043d\u0430 \u043e\u0447\u0435\u0440\u0435\u0434\u044c\/\u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0442\u0440\u0443\u0431\u044b \u043d\u0430 \u0432\u0441\u0435\u0445<br \/>\n<strong>&#8211; 0xffffffff<\/strong>\u00a0\u2013 \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u044e\u0437\u0435\u0440\u0430 \u0441\u0432\u043e\u044f \u043e\u0447\u0435\u0440\u0435\u0434\u044c\/\u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0442\u0440\u0443\u0431\u044b<\/p>\n<p><em><strong><span style=\"color: #ff6600;\">\u0414\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435<\/span><\/strong><\/em><\/p>\n<p>\u0422\u0440\u0443\u0431\u0430 (<strong>pipe<\/strong>) \u0438 \u043e\u0447\u0435\u0440\u0435\u0434\u044c (<strong>queue<\/strong>) \u044d\u0442\u043e \u0440\u0430\u0437\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b. \u0422\u0440\u0443\u0431\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438, \u0430 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0434\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u0430 \u0432\u043d\u0435\u0442\u0440\u0438 \u0442\u0440\u0443\u0431\u044b.<\/p>\n<p><em><span style=\"color: #0000ff;\">\u041f\u0440\u0438\u043c\u0435\u04401<\/span><\/em>:<\/p>\n<p><code>ipfw pipe 1 config bw 7000Kbit\/s<br \/>\nipfw queue 1 config pipe 1 weight 75 mask dst-ip 0x00000000<br \/>\nipfw queue 2 config pipe 1 weight 50 mask dst-ip 0x00000000<br \/>\nipfw queue 3 config pipe 1 weight 50 mask dst-ip 0x00000000<br \/>\nipfw queue 4 config pipe 1 weight 50 mask dst-ip 0x00000000<br \/>\nipfw add queue 1 ip from any to 192.168.0.0\/24<br \/>\nipfw add queue 2 ip from any to 192.168.1.0\/24<br \/>\nipfw add queue 3 ip from any to 192.168.2.0\/24<br \/>\nipfw add queue 4 ip from any to 192.168.3.0\/24<\/code><\/p>\n<p>\u0418\u0442\u043e\u0433\u043e \u0438\u043c\u0435\u0435\u043c: \u043e\u0434\u043d\u0443 \u0442\u043e\u043b\u0441\u0442\u0443\u044e \u0442\u0440\u0443\u0431\u0443 \u043d\u0430 7\u041a \u0438 4 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0432 \u043d\u0435\u0435. \u0423 \u043f\u0435\u0440\u0432\u043e\u0439 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442 75% \u043a\u0430\u043d\u0430\u043b\u0430. \u0423 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 &#8211; \u043f\u043e 50%<\/p>\n<p><em><span style=\"color: #0000ff;\">\u041f\u0440\u0438\u043c\u0435\u04402<\/span><\/em>:<\/p>\n<p><code>ipfw add pipe 1 ip from 192.168.2.0\/24 to any out<br \/>\nipfw add pipe 2 ip from any to 192.168.2.0\/24 in<br \/>\nipfw pipe 1 config mask src-ip 0x000000ff bw 200Kbit\/s queue<br \/>\n20Kbytes<\/code><\/p>\n<p>\u041a\u0430\u043d\u0430\u043b 200\u043a\u0431\u0438\u0442, \u043f\u043e\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u043c\u0435\u0436\u0434\u0443 \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u043c\u0438 \u044e\u0437\u0435\u0440\u0430\u043c\u0438.<\/p>\n<p><span style=\"color: #ff6600;\"><em><strong>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u04352<\/strong><\/em><\/span> (\u0437\u0430\u0438\u043c\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u043e <a href=\"http:\/\/www.bsdportal.ru\/viewtopic.php?f=13&amp;t=25705\" target=\"_blank\" rel=\"noopener\">\u043e\u0442\u0441\u044e\u0434\u0430<\/a>).<\/p>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0430\u0447\u0430\u043b\u0438 \u043f\u043e\u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f:<\/p>\n<p><code>kernel: Bump flowset buckets to 64 (was 0)<\/code><\/p>\n<p>(\u0432 \u043d\u043e\u0432\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 <strong>ipfw<\/strong>) \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043e\u0447\u0435\u0440\u0435\u0434\u0435\u0439 \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u044f\u0432\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 <strong>buckets<\/strong>:<\/p>\n<p><code>ipfw queue 2 config pipe 1 weight 10 buckets 128 mask src-ip 0xffffffff<\/code><\/p>\n<p>\u0415\u0441\u043b\u0438 \u044d\u0442\u043e\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043d\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u044c, \u0442\u043e \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 <strong>ipfw<\/strong> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438\u0437 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <strong>net.inet.ip.dummynet.hash_size<\/strong>, \u043e \u0447\u0435\u043c \u0438 \u0441\u043e\u043e\u0431\u0449\u0430\u0435\u0442 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438, \u0447\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0435 \u0443\u043a\u0430\u0437\u0430\u043b\u0438 \u044f\u0432\u043d\u043e, \u0430 \u043d\u0430\u0434\u043e-\u0431\u044b.<\/p>\n<p><span style=\"color: #ff6600;\"><em><strong>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u04353<\/strong><\/em><\/span> (\u0437\u0430\u0438\u043c\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u043e \u0438\u0437 pf@freebsd.org)<br \/>\n\u0421 \u0432\u0435\u0440\u0441\u0438\u0438 14 (\u043f\u043e\u043a\u0430 \u0442\u043e\u043b\u044c\u043a\u043e <strong>CURRENT<\/strong>) \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 dummynet \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u0438 \u0432 <strong>pf<\/strong>:<br \/>\n<code><br \/>\n# dnctl pipe 1 config bw 300KByte\/s<br \/>\n<\/code><br \/>\n\u0412 \/etc\/pf.conf:<br \/>\n<code>pass in quick inet from X.X.X.X to any dnpipe 1<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0412\u043e\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0440\u0430\u0432\u0438\u043b \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u0434\u043b\u044f \u0443\u0434\u0430\u0447\u043d\u043e\u0433\u043e \u0448\u0435\u0439\u043f\u0438\u043d\u0433\u0430 (\u0448\u0435\u0439\u043f\u0438\u043d\u0433 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435\u00a01\u041c\u0431\u0438\u0442\/\u0441, \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043d\u0430 \u0438\u0441\u0445\u043e\u0434 \u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043d\u0430 \u0432\u0445\u043e\u0434):<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,10],"tags":[],"class_list":["post-242","post","type-post","status-publish","format-standard","hentry","category-freebsd","category-others"],"_links":{"self":[{"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=\/wp\/v2\/posts\/242","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=242"}],"version-history":[{"count":11,"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=\/wp\/v2\/posts\/242\/revisions"}],"predecessor-version":[{"id":6047,"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=\/wp\/v2\/posts\/242\/revisions\/6047"}],"wp:attachment":[{"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=242"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=242"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=242"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}