{"id":1278,"date":"2012-11-01T13:47:27","date_gmt":"2012-11-01T09:47:27","guid":{"rendered":"http:\/\/saradmin.ru\/?p=1278"},"modified":"2012-11-01T13:47:27","modified_gmt":"2012-11-01T09:47:27","slug":"cheatsheet-20-%d0%bf%d1%80%d0%b8%d0%bc%d0%b5%d1%80%d0%be%d0%b2-%d0%b8%d1%81%d0%bf%d0%be%d0%bb%d1%8c%d0%b7%d0%be%d0%b2%d0%b0%d0%bd%d0%b8%d1%8f-iptables-%d0%b4%d0%bb%d1%8f-%d0%b0%d0%b4%d0%bc%d0%b8","status":"publish","type":"post","link":"https:\/\/saradmin.ru\/?p=1278","title":{"rendered":"CheatSheet: 20 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f iptables \u0434\u043b\u044f \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u043e\u0432"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/saradmin.ru\/wp-content\/uploads\/iptables-150x150.jpg\" alt=\"\" title=\"console\" width=\"150\" height=\"150\" class=\"alignleft size-thumbnail wp-image-150\" \/>\u0424\u0430\u0439\u0440\u0432\u043e\u043b\u043b \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 linux \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f iptables (\u0434\u043b\u044f ipv4) \u0438 ip6tables (\u0434\u043b\u044f ipv6). \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0448\u043f\u0430\u0440\u0433\u0430\u043b\u043a\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u044b \u0441\u0430\u043c\u044b\u0435 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f iptables \u0434\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0445\u043e\u0447\u0435\u0442 \u0437\u0430\u0449\u0438\u0442\u0438\u0442\u044c \u0441\u0432\u043e\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u043e\u0442 \u0432\u0437\u043b\u043e\u043c\u0449\u0438\u043a\u043e\u0432 \u0438\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435.<\/p>\n<h2>1. \u041f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u0443\u0441.<\/h2>\n<p><code># iptables -L -n -v<\/code><\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440\u043d\u044b\u0439 \u0432\u044b\u0432\u043e\u0434 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0434\u043b\u044f \u043d\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u0440\u0432\u043e\u043b\u043b\u0430:<\/p>\n<blockquote><p>Chain INPUT (policy ACCEPT 0 packets, 0 bytes)<br \/>\n pkts bytes target     prot opt in     out     source               destination<br \/>\nChain FORWARD (policy ACCEPT 0 packets, 0 bytes)<br \/>\n pkts bytes target     prot opt in     out     source               destination<br \/>\nChain OUTPUT (policy ACCEPT 0 packets, 0 bytes)<br \/>\n pkts bytes target     prot opt in     out     source               destination<\/p><\/blockquote>\n<p><!--more--><br \/>\n \u0414\u043b\u044f \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u0440\u0432\u043e\u043b\u043b\u0430:<\/p>\n<blockquote><p>Chain INPUT (policy DROP 0 packets, 0 bytes)<br \/>\n pkts bytes target     prot opt in     out     source               destination<br \/>\n    0     0 DROP       all  &#8212;  *      *       0.0.0.0\/0            0.0.0.0\/0           state INVALID<br \/>\n  394 43586 ACCEPT     all  &#8212;  *      *       0.0.0.0\/0            0.0.0.0\/0           state RELATED,ESTABLISHED<br \/>\n   93 17292 ACCEPT     all  &#8212;  br0    *       0.0.0.0\/0            0.0.0.0\/0<br \/>\n    1   142 ACCEPT     all  &#8212;  lo     *       0.0.0.0\/0            0.0.0.0\/0<br \/>\nChain FORWARD (policy DROP 0 packets, 0 bytes)<br \/>\n pkts bytes target     prot opt in     out     source               destination<br \/>\n    0     0 ACCEPT     all  &#8212;  br0    br0     0.0.0.0\/0            0.0.0.0\/0<br \/>\n    0     0 DROP       all  &#8212;  *      *       0.0.0.0\/0            0.0.0.0\/0           state INVALID<br \/>\n    0     0 TCPMSS     tcp  &#8212;  *      *       0.0.0.0\/0            0.0.0.0\/0           tcp flags:0x06\/0x02 TCPMSS clamp to PMTU<br \/>\n    0     0 ACCEPT     all  &#8212;  *      *       0.0.0.0\/0            0.0.0.0\/0           state RELATED,ESTABLISHED<br \/>\n    0     0 wanin      all  &#8212;  vlan2  *       0.0.0.0\/0            0.0.0.0\/0<br \/>\n    0     0 wanout     all  &#8212;  *      vlan2   0.0.0.0\/0            0.0.0.0\/0<br \/>\n    0     0 ACCEPT     all  &#8212;  br0    *       0.0.0.0\/0            0.0.0.0\/0<br \/>\nChain OUTPUT (policy ACCEPT 425 packets, 113K bytes)<br \/>\n pkts bytes target     prot opt in     out     source               destination<br \/>\nChain wanin (1 references)<br \/>\n pkts bytes target     prot opt in     out     source               destination<br \/>\nChain wanout (1 references)<br \/>\n pkts bytes target     prot opt in     out     source               destination\n<\/p><\/blockquote>\n<p> \u0413\u0434\u0435:<br \/>\n -L : \u041f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0440\u0430\u0432\u0438\u043b.<br \/>\n -v : \u041e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e. \u042d\u0442\u0430 \u043e\u043f\u0446\u0438\u044f \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0438\u043c\u044f \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430, \u043e\u043f\u0446\u0438\u0438, TOS \u043c\u0430\u0441\u043a\u0438. \u0422\u0430\u043a\u0436\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442 \u0441\u0443\u0444\u0444\u0438\u043a\u0441\u044b &#8216;K&#8217;, &#8216;M&#8217; or &#8216;G&#8217;.<br \/>\n -n : \u041e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c ip \u0430\u0434\u0440\u0435\u0441 \u0438 \u043f\u043e\u0440\u0442 \u0447\u0438\u0441\u043b\u0430\u043c\u0438 (\u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f DNS \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0438\u043c\u0435\u043d. \u042d\u0442\u043e \u0443\u0441\u043a\u043e\u0440\u0438\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435).<\/p>\n<h3>1.1 \u041e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0440\u0430\u0432\u0438\u043b \u0441 \u043d\u043e\u043c\u0435\u0440\u0430\u043c\u0438 \u0441\u0442\u0440\u043e\u043a.<\/h3>\n<p><code># iptables -n -L -v --line-numbers<\/code><\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440\u043d\u044b\u0439 \u0432\u044b\u0432\u043e\u0434:<\/p>\n<blockquote><p>Chain INPUT (policy DROP)<br \/>\nnum  target     prot opt source               destination<br \/>\n1    DROP       all  &#8212;  0.0.0.0\/0            0.0.0.0\/0           state INVALID<br \/>\n2    ACCEPT     all  &#8212;  0.0.0.0\/0            0.0.0.0\/0           state RELATED,ESTABLISHED<br \/>\n3    ACCEPT     all  &#8212;  0.0.0.0\/0            0.0.0.0\/0<br \/>\n4    ACCEPT     all  &#8212;  0.0.0.0\/0            0.0.0.0\/0<br \/>\nChain FORWARD (policy DROP)<br \/>\nnum  target     prot opt source               destination<br \/>\n1    ACCEPT     all  &#8212;  0.0.0.0\/0            0.0.0.0\/0<br \/>\n2    DROP       all  &#8212;  0.0.0.0\/0            0.0.0.0\/0           state INVALID<br \/>\n3    TCPMSS     tcp  &#8212;  0.0.0.0\/0            0.0.0.0\/0           tcp flags:0x06\/0x02 TCPMSS clamp to PMTU<br \/>\n4    ACCEPT     all  &#8212;  0.0.0.0\/0            0.0.0.0\/0           state RELATED,ESTABLISHED<br \/>\n5    wanin      all  &#8212;  0.0.0.0\/0            0.0.0.0\/0<br \/>\n6    wanout     all  &#8212;  0.0.0.0\/0            0.0.0.0\/0<br \/>\n7    ACCEPT     all  &#8212;  0.0.0.0\/0            0.0.0.0\/0<br \/>\nChain OUTPUT (policy ACCEPT)<br \/>\nnum  target     prot opt source               destination<br \/>\nChain wanin (1 references)<br \/>\nnum  target     prot opt source               destination<br \/>\nChain wanout (1 references)<br \/>\nnum  target     prot opt source               destination<\/p><\/blockquote>\n<p> \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u043e\u043c\u0435\u0440\u0430 \u0441\u0442\u0440\u043e\u043a \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430.<\/p>\n<h3>1.2 \u041e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c INPUT \u0438\u043b\u0438 OUTPUT \u0446\u0435\u043f\u043e\u0447\u043a\u0438 \u043f\u0440\u0430\u0432\u0438\u043b.<\/h3>\n<p><code># iptables -L INPUT -n -v<br \/>\n# iptables -L OUTPUT -n -v --line-numbers<br \/>\n<\/code><\/p>\n<h2>2. \u041e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \/ \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \/ \u041f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0444\u0430\u0439\u0440\u0432\u043e\u043b\u043b.<\/h2>\n<p> \u0421\u0438\u043b\u0430\u043c\u0438 \u0441\u0430\u043c\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b:<br \/>\n<code># service iptables stop<br \/>\n# service iptables start<br \/>\n# service iptables restart<br \/>\n<\/code><br \/>\n \u041c\u043e\u0436\u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u044b iptables \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0444\u0430\u0439\u0440\u0432\u043e\u043b\u043b \u0438 \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0432\u0441\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430:<br \/>\n<code># iptables -F<br \/>\n# iptables -X<br \/>\n# iptables -t nat -F<br \/>\n# iptables -t nat -X<br \/>\n# iptables -t mangle -F<br \/>\n# iptables -t mangle -X<br \/>\n# iptables -P INPUT ACCEPT<br \/>\n# iptables -P OUTPUT ACCEPT<br \/>\n# iptables -P FORWARD ACCEPT<\/code><\/p>\n<p> \u0413\u0434\u0435:<br \/>\n -F : \u0423\u0434\u0430\u043b\u0438\u0442\u044c (flush) \u0432\u0441\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430.<br \/>\n -X : \u0423\u0434\u0430\u043b\u0438\u0442\u044c \u0446\u0435\u043f\u043e\u0447\u043a\u0443.<br \/>\n -t table_name : \u0412\u044b\u0431\u0440\u0430\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 (nat \u0438\u043b\u0438 mangle) \u0438 \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0432\u0441\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430.<br \/>\n -P : \u0412\u044b\u0431\u0440\u0430\u0442\u044c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e (\u0442\u0430\u043a\u0438\u0435, \u043a\u0430\u043a DROP, REJECT, \u0438\u043b\u0438 ACCEPT).<\/p>\n<h2>3. \u0423\u0434\u0430\u043b\u0438\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0444\u0430\u0439\u0440\u0432\u043e\u043b\u043b\u0430.<\/h2>\n<p> \u0427\u0442\u043e\u0431\u044b \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c \u043d\u043e\u043c\u0435\u0440 \u0441\u0442\u0440\u043e\u043a\u0438 \u0441 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c\u0438:<br \/>\n<code># iptables -L INPUT -n --line-numbers<br \/>\n# iptables -L OUTPUT -n --line-numbers<br \/>\n# iptables -L OUTPUT -n --line-numbers | less<br \/>\n# iptables -L OUTPUT -n --line-numbers | grep 202.54.1.1<br \/>\n<\/code><br \/>\n \u041f\u043e\u043b\u0443\u0447\u0438\u043c \u0441\u043f\u0438\u0441\u043e\u043a ip \u0430\u0434\u0440\u0435\u0441\u043e\u0432. \u041f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043d\u043e\u043c\u0435\u0440 \u0441\u043b\u0435\u0432\u0430 \u0438 \u0443\u0434\u0430\u043b\u0438\u043c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443. \u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443 \u0434\u043b\u044f \u043d\u043e\u043c\u0435\u0440\u0430 3:<br \/>\n<code># iptables -D INPUT 3<\/code><\/p>\n<p> \u0418\u043b\u0438 \u043d\u0430\u0439\u0434\u0435\u043c ip \u0430\u0434\u0440\u0435\u0441 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430 (202.54.1.1) \u0438 \u0443\u0434\u0430\u043b\u0438\u043c \u0438\u0437 \u043f\u0440\u0430\u0432\u0438\u043b\u0430:<br \/>\n<code># iptables -D INPUT -s 202.54.1.1 -j DROP<\/code><\/p>\n<p> \u0413\u0434\u0435:<br \/>\n -D : \u0423\u0434\u0430\u043b\u0438\u0442\u044c \u043e\u0434\u043d\u043e \u0438\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0430\u0432\u0438\u043b \u0438\u0437 \u0446\u0435\u043f\u043e\u0447\u043a\u0438.<\/p>\n<h2>4. \u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u0432 \u0444\u0430\u0439\u0440\u0432\u043e\u043b\u043b.<\/h2>\n<p> \u0427\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043e\u0434\u043d\u043e \u0438\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0430\u0432\u0438\u043b \u0432 \u0446\u0435\u043f\u043e\u0447\u043a\u0443, \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043d\u043e\u043c\u0435\u0440\u043e\u0432 \u0441\u0442\u0440\u043e\u043a:<br \/>\n<code># iptables -L INPUT -n --line-numbers<\/code><\/p>\n<p> \u041f\u0440\u0438\u043c\u0435\u0440\u043d\u044b\u0439 \u0432\u044b\u0432\u043e\u0434:<\/p>\n<blockquote><p>Chain INPUT (policy DROP)<br \/>\nnum  target     prot opt source               destination<br \/>\n1    DROP       all  &#8212;  202.54.1.1           0.0.0.0\/0<br \/>\n2    ACCEPT     all  &#8212;  0.0.0.0\/0            0.0.0.0\/0           state NEW,ESTABLISHED\n<\/p><\/blockquote>\n<p> \u0427\u0442\u043e\u0431\u044b \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u043c\u0435\u0436\u0434\u0443 1 \u0438 2 \u0441\u0442\u0440\u043e\u043a\u043e\u0439:<br \/>\n<code># iptables -I INPUT 2 -s 202.54.1.2 -j DROP<\/code><\/p>\n<p> \u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c, \u043e\u0431\u043d\u043e\u0432\u0438\u043b\u043e\u0441\u044c \u043b\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u043e:<br \/>\n<code># iptables -L INPUT -n --line-numbers<\/code><\/p>\n<p> \u0412\u044b\u0432\u043e\u0434 \u0441\u0442\u0430\u043d\u0435\u0442 \u0442\u0430\u043a\u0438\u043c:<\/p>\n<blockquote><p>Chain INPUT (policy DROP)<br \/>\nnum  target     prot opt source               destination<br \/>\n1    DROP       all  &#8212;  202.54.1.1           0.0.0.0\/0<br \/>\n2    DROP       all  &#8212;  202.54.1.2           0.0.0.0\/0<br \/>\n3    ACCEPT     all  &#8212;  0.0.0.0\/0            0.0.0.0\/0           state NEW,ESTABLISHED\n<\/p><\/blockquote>\n<h2>5. \u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0444\u0430\u0439\u0440\u0432\u043e\u043b\u043b\u0430.<\/h2>\n<p> \u0421\u0438\u043b\u0430\u043c\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u044b:<br \/>\n<code># service iptables save<\/code><\/p>\n<p> \u0427\u0435\u0440\u0435\u0437 iptables-save:<br \/>\n<code># iptables-save > \/root\/my.active.firewall.rules<br \/>\n# cat \/root\/my.active.firewall.rules<br \/>\n<\/code><\/p>\n<h2>6. \u0412\u043e\u0441\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u0430.<\/h2>\n<p> \u0421\u0438\u043b\u0430\u043c\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u044b:<br \/>\n<code># service iptables restart<br \/>\n<\/code><br \/>\n \u0427\u0435\u0440\u0435\u0437 iptables-restore<br \/>\n<code># iptables-restore < \/root\/my.active.firewall.rules\n<\/code><\/p>\n<h2>7. \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0438 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e.<\/h2>\n<p> \u0427\u0442\u043e\u0431\u044b \u0441\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0442\u044c \u0432\u0435\u0441\u044c \u0442\u0440\u0430\u0444\u0438\u043a:<br \/>\n<code># iptables -P INPUT DROP<br \/>\n# iptables -P OUTPUT DROP<br \/>\n# iptables -P FORWARD DROP<br \/>\n# iptables -L -v -n<br \/>\n<\/code><\/p>\n<h3>7.1 \u0411\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f.<\/h3>\n<p> \u0427\u0442\u043e\u0431\u044b \u0441\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u043f\u0430\u043a\u0435\u0442\u044b, \u043d\u043e \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044c \u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u0442\u0440\u0430\u0444\u0438\u043a:<br \/>\n<code># iptables -P INPUT DROP<br \/>\n# iptables -P FORWARD DROP<br \/>\n# iptables -P OUTPUT ACCEPT<br \/>\n# iptables -A INPUT -m state --state NEW,ESTABLISHED -j ACCEPT<br \/>\n# iptables -L -v -n<br \/>\n<\/code><\/p>\n<h2>8. \u0421\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0442\u044c \u0430\u0434\u0440\u0435\u0441\u0430 \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0441\u0435\u0442\u0435\u0439 \u0432 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u043e\u0439 \u0441\u0435\u0442\u0438.<\/h2>\n<p><code># iptables -A INPUT -i eth1 -s 192.168.0.0\/24 -j DROP<br \/>\n# iptables -A INPUT -i eth1 -s 10.0.0.0\/8 -j DROP<\/code><\/p>\n<h2>9. \u0411\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e ip \u0430\u0434\u0440\u0435\u0441\u0430.<\/h2>\n<p> \u0427\u0442\u043e\u0431\u044b \u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0430\u0434\u0440\u0435\u0441 \u0432\u0437\u043b\u043e\u043c\u0449\u0438\u043a\u0430 1.2.3.4:<br \/>\n<code># iptables -A INPUT -s 1.2.3.4 -j DROP<br \/>\n# iptables -A INPUT -s 192.168.0.0\/24 -j DROP<br \/>\n<\/code><\/p>\n<h2>10. \u0417\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043f\u043e\u0440\u0442\u0430.<\/h2>\n<p> \u0427\u0442\u043e\u0431\u044b \u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043f\u043e\u0440\u0442\u0430 80:<br \/>\n<code># iptables -A INPUT -p tcp --dport 80 -j DROP<br \/>\n# iptables -A INPUT -i eth1 -p tcp --dport 80 -j DROP<br \/>\n<\/code><br \/>\n \u0427\u0442\u043e\u0431\u044b \u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u043e\u0440\u0442\u0430 80 \u0441 \u0430\u0434\u0440\u0435\u0441\u0430 1.2.3.4r:<br \/>\n<code># iptables -A INPUT -p tcp -s 1.2.3.4 --dport 80 -j DROP<br \/>\n# iptables -A INPUT -i eth1 -p tcp -s 192.168.1.0\/24 --dport 80 -j DROP<br \/>\n<\/code><\/p>\n<h2>11. \u0417\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043d\u0430 \u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0439 ip \u0430\u0434\u0440\u0435\u0441.<\/h2>\n<p> \u0427\u0442\u043e\u0431\u044b \u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u0434\u043e\u043c\u0435\u043d, \u0443\u0437\u043d\u0430\u0435\u043c \u0435\u0433\u043e \u0430\u0434\u0440\u0435\u0441:<br \/>\n<code># host -t a www.facebook.com<\/code><\/p>\n<p> \u0412\u044b\u0432\u043e\u0434:<\/p>\n<blockquote><p> www.facebook.com has address 69.171.228.40\n<\/p><\/blockquote>\n<p> \u041d\u0430\u0439\u0434\u0435\u043c CIDR \u0434\u043b\u044f 69.171.228.40:<br \/>\n<code># whois 69.171.228.40 | grep CIDR<\/code><\/p>\n<p> \u0412\u044b\u0432\u043e\u0434:<\/p>\n<blockquote><p>CIDR:           69.171.224.0\/19\n<\/p><\/blockquote>\n<p> \u0417\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u043c \u0434\u043e\u0441\u0442\u0443\u043f \u043d\u0430 69.171.224.0\/19:<br \/>\n<code># iptables -A OUTPUT -p tcp -d 69.171.224.0\/19 -j DROP<br \/>\n<\/code><br \/>\n \u0422\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043e\u043c\u0435\u043d \u0434\u043b\u044f \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438:<br \/>\n<code># iptables -A OUTPUT -p tcp -d www.facebook.com -j DROP<br \/>\n# iptables -A OUTPUT -p tcp -d facebook.com -j DROP<br \/>\n<\/code><\/p>\n<h2>12. \u0417\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u0438 \u0441\u0431\u0440\u043e\u0441\u0438\u0442\u044c.<\/h2>\n<p> \u0427\u0442\u043e\u0431\u044b \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u0436\u0443\u0440\u043d\u0430\u043b \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0435 \u043f\u0430\u043a\u0435\u0442\u043e\u0432 \u043f\u0435\u0440\u0435\u0434 \u0441\u0431\u0440\u043e\u0441\u043e\u043c, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u043e:<br \/>\n<code># iptables -A INPUT -i eth1 -s 10.0.0.0\/8 -j LOG --log-prefix \"IP_SPOOF A: \"<br \/>\n# iptables -A INPUT -i eth1 -s 10.0.0.0\/8 -j DROP<br \/>\n<\/code><br \/>\n \u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0436\u0443\u0440\u043d\u0430\u043b (\u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \/var\/log\/messages):<br \/>\n<code># tail -f \/var\/log\/messages<br \/>\n# grep --color 'IP SPOOF' \/var\/log\/messages<br \/>\n<\/code><\/p>\n<h2>13. \u0417\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u0438 \u0441\u0431\u0440\u043e\u0441\u0438\u0442\u044c (\u0441 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435\u043c \u043d\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u0430\u043f\u0438\u0441\u0435\u0439).<\/h2>\n<p> \u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0440\u0430\u0437\u0434\u0435\u043b \/ \u0440\u0430\u0437\u0434\u0443\u0442\u044b\u043c \u0436\u0443\u0440\u043d\u0430\u043b\u043e\u043c, \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e -m.\u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0435 5 \u043c\u0438\u043d\u0443\u0442 \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c 7 \u0441\u0442\u0440\u043e\u043a:<br \/>\n<code># iptables -A INPUT -i eth1 -s 10.0.0.0\/8 -m limit --limit 5\/m --limit-burst 7 -j LOG --log-prefix \"IP_SPOOF A: \"<br \/>\n# iptables -A INPUT -i eth1 -s 10.0.0.0\/8 -j DROP<br \/>\n<\/code><\/p>\n<h2>14. \u0421\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0442\u044c \u0438\u043b\u0438 \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044c \u0442\u0440\u0430\u0444\u0438\u043a \u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 mac \u0430\u0434\u0440\u0435\u0441\u043e\u0432.<\/h2>\n<p><code># iptables -A INPUT -m mac --mac-source 00:0F:EA:91:04:08 -j DROP<br \/>\n## *\u0440\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f TCP port # 8080 \u0441 mac \u0430\u0434\u0440\u0435\u0441\u0430 00:0F:EA:91:04:07 * ##<br \/>\n# iptables -A INPUT -p tcp --destination-port 22 -m mac --mac-source 00:0F:EA:91:04:07 -j ACCEPT<br \/>\n<\/code><\/p>\n<h2>15. \u0420\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044c \u0438\u043b\u0438 \u0437\u0430\u043f\u0440\u0435\u0442\u0438\u0442\u044c ICMP Ping \u0437\u0430\u043f\u0440\u043e\u0441\u044b.<\/h2>\n<p> \u0427\u0442\u043e\u0431\u044b \u0437\u0430\u043f\u0440\u0435\u0442\u0438\u0442\u044c:<br \/>\n<code># iptables -A INPUT -p icmp --icmp-type echo-request -j DROP<br \/>\n# iptables -A INPUT -i eth1 -p icmp --icmp-type echo-request -j DROP<br \/>\n<\/code><br \/>\n \u0420\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044c \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u0441\u0435\u0442\u0435\u0439 \/ \u0445\u043e\u0441\u0442\u043e\u0432:<br \/>\n<code># iptables -A INPUT -s 192.168.1.0\/24 -p icmp --icmp-type echo-request -j ACCEPT<\/code><\/p>\n<p> \u0420\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0430\u0441\u0442\u044c ICMP \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432:<br \/>\n<code>### ** \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0438 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0434\u043b\u044f \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u044b \u0432 DROP ** ###<br \/>\n# iptables -A INPUT -p icmp --icmp-type echo-reply -j ACCEPT<br \/>\n# iptables -A INPUT -p icmp --icmp-type destination-unreachable -j ACCEPT<br \/>\n# iptables -A INPUT -p icmp --icmp-type time-exceeded -j ACCEPT<br \/>\n## ** \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u043c \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c \u043d\u0430 \u0437\u0430\u043f\u0440\u043e\u0441 ** ##<br \/>\n# iptables -A INPUT -p icmp --icmp-type echo-request -j ACCEPT<br \/>\n<\/code><\/p>\n<h2>16. \u041e\u0442\u043a\u0440\u044b\u0442\u044c \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d \u043f\u043e\u0440\u0442\u043e\u0432.<\/h2>\n<p><code># iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 7000:7010 -j ACCEPT<br \/>\n<\/code><\/p>\n<h2>17. \u041e\u0442\u043a\u0440\u044b\u0442\u044c \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d \u0430\u0434\u0440\u0435\u0441\u043e\u0432.<\/h2>\n<p><code>## \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u043f\u043e\u0440\u0442\u0443 80 (Apache)  \u0435\u0441\u043b\u0438 \u0430\u0434\u0440\u0435\u0441 \u0432 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435 \u043e\u0442 192.168.1.100 \u0434\u043e 192.168.1.200 ##<br \/>\n# iptables -A INPUT -p tcp --destination-port 80 -m iprange --src-range 192.168.1.100-192.168.1.200 -j ACCEPT<br \/>\n## \u043f\u0440\u0438\u043c\u0435\u0440 \u0434\u043b\u044f nat ##<br \/>\n# iptables -t nat -A POSTROUTING -j SNAT --to-source 192.168.1.20-192.168.1.25<br \/>\n<\/code><\/p>\n<h2>18. \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0438 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a \u0444\u0430\u0439\u0440\u0432\u043e\u043b\u043b\u0430.<\/h2>\n<p> \u041f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430 iptables, \u0441\u0435\u0440\u0432\u0438\u0441 \u0441\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u0442 \u0432\u0441\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0438 \u0432\u044b\u0433\u0440\u0443\u0436\u0430\u0435\u0442 \u043c\u043e\u0434\u0443\u043b\u0438 \u0438\u0437 \u0441\u0438\u0441\u0442\u0435\u043c\u044b. \u041e\u0442\u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u0443\u0435\u043c \/etc\/sysconfig\/iptables-config \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 no, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0435\u0434\u043e\u0442\u0432\u0440\u0430\u0442\u0438\u0442\u044c \u044d\u0442\u043e:<br \/>\n<code>IPTABLES_MODULES_UNLOAD = no<\/code><\/p>\n<h2>19. \u0417\u0430\u043a\u0440\u044b\u0442\u044c \u0438\u043b\u0438 \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u043f\u043e\u0440\u0442\u044b.<\/h2>\n<p> (\u0417\u0430\u043c\u0435\u043d\u0438\u0442\u044c ACCEPT \u043d\u0430 DROP, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0440\u0442)<br \/>\n<code>## ssh tcp port 22 ##<br \/>\niptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT<br \/>\niptables -A INPUT -s 192.168.1.0\/24 -m state --state NEW -p tcp --dport 22 -j ACCEPT<\/p>\n<p>## cups (printing service) udp\/tcp port 631 \u0434\u043b\u044f \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u0435\u0442\u0438 ##<br \/>\niptables -A INPUT -s 192.168.1.0\/24 -p udp -m udp --dport 631 -j ACCEPT<br \/>\niptables -A INPUT -s 192.168.1.0\/24 -p tcp -m tcp --dport 631 -j ACCEPT<\/p>\n<p>## time sync via NTP \u0434\u043b\u044f \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u0435\u0442\u0438 (udp port 123) ##<br \/>\niptables -A INPUT -s 192.168.1.0\/24 -m state --state NEW -p udp --dport 123 -j ACCEPT<\/p>\n<p>## tcp port 25 (smtp) ##<br \/>\niptables -A INPUT -m state --state NEW -p tcp --dport 25 -j ACCEPT<\/p>\n<p> # dns server ports ##<br \/>\niptables -A INPUT -m state --state NEW -p udp --dport 53 -j ACCEPT<br \/>\niptables -A INPUT -m state --state NEW -p tcp --dport 53 -j ACCEPT<\/p>\n<p> ## http\/https (Apache) server port ##<br \/>\niptables -A INPUT -m state --state NEW -p tcp --dport 80 -j ACCEPT<br \/>\niptables -A INPUT -m state --state NEW -p tcp --dport 443 -j ACCEPT<\/p>\n<p> ## tcp port 110 (pop3) ##<br \/>\niptables -A INPUT -m state --state NEW -p tcp --dport 110 -j ACCEPT<\/p>\n<p> ## tcp port 143 (imap) ##<br \/>\niptables -A INPUT -m state --state NEW -p tcp --dport 143 -j ACCEPT<\/p>\n<p> ## Samba file server \u0434\u043b\u044f \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u0435\u0442\u0438 ##<br \/>\niptables -A INPUT -s 192.168.1.0\/24 -m state --state NEW -p tcp --dport 137 -j ACCEPT<br \/>\niptables -A INPUT -s 192.168.1.0\/24 -m state --state NEW -p tcp --dport 138 -j ACCEPT<br \/>\niptables -A INPUT -s 192.168.1.0\/24 -m state --state NEW -p tcp --dport 139 -j ACCEPT<br \/>\niptables -A INPUT -s 192.168.1.0\/24 -m state --state NEW -p tcp --dport 445 -j ACCEPT<\/p>\n<p>## proxy server \u0434\u043b\u044f \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u0435\u0442\u0438 ##<br \/>\niptables -A INPUT -s 192.168.1.0\/24 -m state --state NEW -p tcp --dport 3128 -j ACCEPT<\/p>\n<p>## mysql server \u0434\u043b\u044f \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u0435\u0442\u0438 ##<br \/>\niptables -I INPUT -p tcp --dport 3306 -j ACCEPT<br \/>\n<\/code><\/p>\n<h2>20. \u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439 \u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0443 \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u0430\u0434\u0440\u0435\u0441\u0430.<\/h2>\n<p> \u0414\u043b\u044f \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f connlimit \u043c\u043e\u0434\u0443\u043b\u044c. \u0427\u0442\u043e\u0431\u044b \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e 3 ssh \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u043d\u0430 \u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0430:<br \/>\n<code># iptables -A INPUT -p tcp --syn --dport 22 -m connlimit --connlimit-above 3 -j REJECT<\/code><\/p>\n<p> \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 HTTP \u0434\u043e 20:<br \/>\n<code># iptables -p tcp --syn --dport 80 -m connlimit --connlimit-above 20 --connlimit-mask 24 -j DROP<\/code><\/p>\n<p> \u0413\u0434\u0435:<br \/>\n --connlimit-above 3 : \u0423\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439 \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u0435\u0442 3.<br \/>\n --connlimit-mask 24 : \u0423\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043c\u0430\u0441\u043a\u0443 \u0441\u0435\u0442\u0438.<\/p>\n<h2>\u041f\u043e\u043c\u043e\u0449\u044c \u043f\u043e iptables.<\/h2>\n<p> \u0414\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u043e\u043c\u043e\u0449\u0438 \u043f\u043e iptables, \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f man:<br \/>\n<code>$ man iptables<\/code><\/p>\n<p> \u0418\u043b\u0438 \u043a\u0440\u0430\u0442\u043a\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043a\u043e\u0439 \u043f\u043e\u043c\u043e\u0449\u0438:<br \/>\n<code># iptables -h<\/code><\/p>\n<p> \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043f\u043e\u043c\u043e\u0449\u044c \u043f\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u043c \u0438 \u0446\u0435\u043b\u044f\u043c:<br \/>\n<code># iptables -j DROP -h<\/code><\/p>\n<p><a href=\"http:\/\/skai-falkorr.blogspot.ru\/2011\/12\/overview-20-iptables.html\" target=\"_blank\">\u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0424\u0430\u0439\u0440\u0432\u043e\u043b\u043b \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 linux \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f iptables (\u0434\u043b\u044f ipv4) \u0438 ip6tables (\u0434\u043b\u044f ipv6). \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0448\u043f\u0430\u0440\u0433\u0430\u043b\u043a\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u044b \u0441\u0430\u043c\u044b\u0435 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f iptables \u0434\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0445\u043e\u0447\u0435\u0442 \u0437\u0430\u0449\u0438\u0442\u0438\u0442\u044c \u0441\u0432\u043e\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u043e\u0442 \u0432\u0437\u043b\u043e\u043c\u0449\u0438\u043a\u043e\u0432 \u0438\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435. 1. \u041f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u0443\u0441. # iptables -L -n -v \u041f\u0440\u0438\u043c\u0435\u0440\u043d\u044b\u0439 \u0432\u044b\u0432\u043e\u0434 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0434\u043b\u044f \u043d\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u0440\u0432\u043e\u043b\u043b\u0430: Chain INPUT (policy ACCEPT 0 packets, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[26,20],"tags":[176,148,27,589,28,21,49,43,23,177],"class_list":["post-1278","post","type-post","status-publish","format-standard","hentry","category-linux","category-20","tag-cheatsheet","tag-console","tag-iptables","tag-linux","tag-ubuntu","tag-21","tag-49","tag-43","tag-23","tag-177"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p2HrGV-kC","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/saradmin.ru\/index.php?rest_route=\/wp\/v2\/posts\/1278","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/saradmin.ru\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/saradmin.ru\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/saradmin.ru\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/saradmin.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1278"}],"version-history":[{"count":9,"href":"https:\/\/saradmin.ru\/index.php?rest_route=\/wp\/v2\/posts\/1278\/revisions"}],"predecessor-version":[{"id":1287,"href":"https:\/\/saradmin.ru\/index.php?rest_route=\/wp\/v2\/posts\/1278\/revisions\/1287"}],"wp:attachment":[{"href":"https:\/\/saradmin.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1278"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/saradmin.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1278"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/saradmin.ru\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1278"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}