{"id":746,"date":"2019-08-21T14:00:09","date_gmt":"2019-08-21T08:00:09","guid":{"rendered":"http:\/\/ast-1c.kz\/almasoft\/?p=746"},"modified":"2019-08-23T17:23:59","modified_gmt":"2019-08-23T11:23:59","slug":"7-%d0%bd%d0%b0%d1%81%d1%82%d1%80%d0%be%d0%b9%d0%ba%d0%b0-%d1%84%d0%b0%d0%b9%d0%b5%d1%80%d0%b2%d0%be%d0%bb%d0%b0-%d0%b2-linux-%d0%bd%d0%b0-%d0%be%d1%81%d0%bd%d0%be%d0%b2%d0%b5-iptablas","status":"publish","type":"post","link":"http:\/\/ast-1c.kz\/almasoft\/?p=746","title":{"rendered":"7. \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0444\u0430\u0439\u0435\u0440\u0432\u043e\u043b\u0430 \u0432 linux \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 iptables"},"content":{"rendered":"\n<p>\u0417\u0434\u0435\u0441\u044c \u044f \u043d\u0435 \u0441\u0442\u0430\u043d\u0443 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u043e\u0431\u0449\u0438\u0439 \u043f\u0440\u0438\u043d\u0446\u0438\u043f, \u0442.\u043a. \u044d\u0442\u043e \u0442\u0435\u043c\u0430 \u043e\u0447\u0435\u043d\u044c \u043e\u0431\u0448\u0438\u0440\u043d\u0430\u044f, \u0430 \u0432\u044b\u043b\u043e\u0436\u0443 \u043b\u0438\u0448\u044c \u0443\u0436\u0435 \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u0441\u043a\u0440\u0438\u043f\u0442\u044b \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0439.<\/p>\n\n\n\n<p>\u0418 \u0442\u0430\u043a \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u0441\u0435 \u0442\u0430\u043a\u0438 \u0432\u043a\u043b\u044e\u0447\u0438\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0444\u043e\u0440\u0432\u0430\u0434\u0438\u043d\u0433\u0430 \u0442\u0440\u0430\u0444\u0438\u043a\u0430 \u0447\u0435\u0440\u0435\u0437 \u043c\u0430\u0448\u0438\u043d\u043a\u0443 \u043d\u0430 linux:<\/p>\n\n\n\n<p class=\"has-background has-small-font-size has-very-light-gray-background-color\">sudo sed -i \u2018\/#net.ipv4.ip_forward=1\/s\/#net.ipv4.ip_forward=1\/net.ipv4.ip_forward=1\/g\u2019 \/etc\/sysctl.conf<\/p>\n\n\n\n<p>\u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440.<\/p>\n\n\n\n<p>\u0421\u043a\u0440\u0438\u043f\u0442 \u043e\u0447\u0438\u0441\u0442\u043a\u0438 \u0444\u0430\u0439\u0435\u0440\u0432\u043e\u043b\u0430:<\/p>\n\n\n\n<p class=\"has-background has-small-font-size has-very-light-gray-background-color\">!\/bin\/bash<br># \u0423\u0434\u0430\u043b\u044f\u0435\u043c \u0432\u0441\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430<br> sudo iptables -F<br> sudo iptables &#8212;flush<br> sudo iptables &#8212;table nat &#8212;flush<br> sudo iptables &#8212;delete-chain<br> sudo iptables &#8212;table nat &#8212;delete-chain<br># \u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0432\u0441\u0435<br> sudo iptables -P INPUT ACCEPT<br> sudo iptables -P OUTPUT ACCEPT<br> sudo iptables -P FORWARD ACCEPT<br># \u0412\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u0430\u0432\u0442\u043e\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443<br> sudo echo &#171;#! \/sbin\/iptables-restore&#187; &gt; \/etc\/network\/if-up.d\/iptables-rules<br> sudo iptables-save &gt;&gt; \/etc\/network\/if-up.d\/iptables-rules<br> sudo chmod +x \/etc\/network\/if-up.d\/iptables-rules<\/p>\n\n\n\n<p>\u0421\u043a\u0440\u0438\u043f\u0442 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0444\u0430\u0439\u0435\u0440\u0432\u043e\u043b\u0430 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0447\u0435\u0439 \u0441\u0442\u0430\u043d\u0446\u0438\u0438:<\/p>\n\n\n\n<p class=\"has-background has-small-font-size has-very-light-gray-background-color\">!\/bin\/bash<br># \u0423\u0434\u0430\u043b\u044f\u0435\u043c \u0432\u0441\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430<br> sudo iptables -F<br> sudo iptables &#8212;flush<br> sudo iptables &#8212;table nat &#8212;flush<br> sudo iptables &#8212;delete-chain<br> sudo iptables &#8212;table nat &#8212;delete-chain<br># \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u0441\u0435 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u043c<br> sudo iptables -P INPUT DROP<br> sudo iptables -P OUTPUT DROP<br> sudo iptables -P FORWARD DROP<br># \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0443 \u043f\u0430\u043a\u0435\u0442\u043e\u0432 \u0447\u0435\u0440\u0435\u0437 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u043f\u0435\u0442\u043b\u0435\u0432\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0438 \u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u043f\u0435\u0442\u043b\u0435\u0432\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u0445 INPUT<br> sudo iptables -A INPUT -i lo -j ACCEPT <br> sudo iptables -A OUTPUT -o lo -j ACCEPT<br># \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 ICMP<br> sudo iptables -A INPUT -p icmp &#8212;icmp-type 0 -j ACCEPT<br> sudo iptables -A INPUT -p icmp &#8212;icmp-type 8 -j ACCEPT<br> sudo iptables -A OUTPUT -p icmp -j ACCEPT<br># \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u044e\u0449\u0435\u0439 \u0432\u0441\u0435 \u0438\u0441\u0445\u043e\u043b\u044f\u0449\u0438\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f<br> sudo iptables -P OUTPUT ACCEPT<br># \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044c \u043f\u043e\u043f\u0430\u0434\u0430\u043d\u0438\u0435 \u043d\u0430 \u043d\u0430\u0448 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435\u0445 TCP- \u0438 UDP-\u043f\u0430\u043a\u0435\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u044b\u043b\u0438 \u0437\u0430\u043f\u0440\u043e\u0448\u0435\u043d\u044b \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u043c\u0438<br> sudo iptables -A INPUT -p TCP -m state &#8212;state ESTABLISHED,RELATED -j ACCEPT<br> sudo iptables -A INPUT -p UDP -m state &#8212;state ESTABLISHED,RELATED -j ACCEPT<br># \u041c\u043e\u0434\u0443\u043b\u0438 iptables MicrosoftVPN \u043d\u0443\u0436\u043d\u044b \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 gre, \u0430 \u0442\u0430\u043a \u0436\u0435 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b ftp<br> modprobe ip_conntrack<br> modprobe ip_conntrack_ftp<br> modprobe ip_nat_ftp<br> modprobe ip_gre<br> modprobe ip_conntrack_pptp<br> modprobe ip_nat_pptp<br># \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u043f\u043e\u0440\u0442\u044b \u0434\u043b\u044f \u043d\u0430\u0448\u0438\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u043f\u0440\u0438\u0447\u0435\u043c \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 \u043f\u0435\u0440\u0435\u0431\u043e\u0440\u0430<br># \u0414\u043b\u044f DNS, \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e<br># \u0437\u0434\u0435\u0441\u044c \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u044f \u0441\u0435\u0442\u044c \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 192.168.1.0\/24<br># sudo iptables -A INPUT &#8212;protocol udp &#8212;dport 53 &#8212;match state &#8212;state NEW &#8212;match string &#8212;algo kmp &#8212;hex-string &#171;|00 00 02 00 01|&#187; &#8212;from 40 &#8212;to 45 &#8212;match recent &#8212;name DNST &#8212;update &#8212;seconds 600 &#8212;jump DROP<br># sudo iptables -A INPUT &#8212;protocol udp &#8212;dport 53 &#8212;match state &#8212;state NEW &#8212;match string &#8212;algo kmp &#8212;hex-string &#171;|00 00 02 00 01|&#187; &#8212;from 40 &#8212;to 45 &#8212;match recent &#8212;name DNST &#8212;set &#8212;jump ACCEPT<br># sudo iptables -A INPUT -p udp &#8212;dport 53 -j ACCEPT<br># sudo iptables -A OUTPUT -p udp &#8212;sport 53 -j ACCEPT<br># \u0414\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e RDP<br> sudo iptables -N RDP<br> sudo iptables -A INPUT -p tcp &#8212;dport 4319 -j RDP<br> sudo iptables -A OUTPUT -p tcp &#8212;sport 4319 -j RDP<br> sudo iptables -A RDP -m state &#8212;state NEW -m recent &#8212;set &#8212;name RDPH &#8212;rsource <br># sudo iptables -A RDP -m recent &#8212;update &#8212;seconds 300 &#8212;hitcount 2 &#8212;name RDPH &#8212;rsource -j LOG &#8212;log-prefix &#171;Anti RDPH-Bruteforce: &#187; &#8212;log-level 6<br> sudo iptables -A RDP -m recent &#8212;update &#8212;seconds 60 &#8212;hitcount 2 &#8212;name RDPH &#8212;rsource -j DROP<br> sudo iptables -A RDP -j ACCEPT<br># \u0414\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e SSH<br> sudo iptables -N SSH<br> sudo iptables -A INPUT -p tcp &#8212;dport 4318 -j SSH<br> sudo iptables -A OUTPUT -p tcp &#8212;sport 4318 -j SSH<br> sudo iptables -A SSH -m state &#8212;state NEW -m recent &#8212;set &#8212;name SSHH &#8212;rsource <br># sudo iptables -A SSH -m recent &#8212;update &#8212;seconds 300 &#8212;hitcount 2 &#8212;name SSHH &#8212;rsource -j LOG &#8212;log-prefix &#171;Anti SSHH-Bruteforce: &#187; &#8212;log-level 6<br> sudo iptables -A SSH -m recent &#8212;update &#8212;seconds 60 &#8212;hitcount 2 &#8212;name SSHH &#8212;rsource -j DROP<br> sudo iptables -A SSH -j ACCEPT<br># \u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u043e\u0447\u0442\u044b \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u043f\u043e\u0440\u0442\u044b<br># SMTP<br># sudo iptables -A INPUT -p tcp &#8212;dport 25 -j ACCEPT<br># sudo iptables -A OUTPUT -p tcp &#8212;sport 25 -j ACCEPT<br># SSMTP<br># sudo iptables -A INPUT -p tcp &#8212;dport 465 -j ACCEPT<br># sudo iptables -A OUTPUT -p tcp &#8212;sport 465 -j ACCEPT<br># SMTP Submission<br># sudo iptables -A INPUT -p tcp &#8212;dport 587 -j ACCEPT<br># sudo iptables -A OUTPUT -p tcp &#8212;sport 587 -j ACCEPT<br># POP3<br># sudo iptables -A INPUT -p tcp &#8212;dport 110 -j ACCEPT<br># sudo iptables -A OUTPUT -p tcp &#8212;sport 110 -j ACCEPT<br># SPOP3<br># sudo iptables -A INPUT -p tcp &#8212;dport 995 -j ACCEPT<br># sudo iptables -A OUTPUT -p tcp &#8212;sport 995 -j ACCEPT<br># IMAP<br># sudo iptables -A INPUT -p tcp &#8212;dport 143 -j ACCEPT<br># sudo iptables -A OUTPUT -p tcp &#8212;sport 143 -j ACCEPT<br># SIMAP<br># sudo iptables -A INPUT -p tcp &#8212;dport 993 -j ACCEPT<br># sudo iptables -A OUTPUT -p tcp &#8212;sport 993 -j ACCEPT<br># HTTP<br># sudo iptables -A INPUT -p tcp &#8212;dport 80 -j ACCEPT<br># sudo iptables -A OUTPUT -p tcp &#8212;sport 80 -j ACCEPT<br># sudo iptables -A INPUT -p tcp &#8212;dport 8800 -j ACCEPT<br># sudo iptables -A OUTPUT -p tcp &#8212;sport 8800 -j ACCEPTT<br># SHTTP<br># sudo iptables -A INPUT -p tcp &#8212;dport 443 -j ACCEPT<br># sudo iptables -A OUTPUT -p tcp &#8212;sport 443 -j ACCEPT<br># sudo iptables -A INPUT -p tcp &#8212;dport 8843 -j ACCEPT<br># sudo iptables -A OUTPUT -p tcp &#8212;sport 8843 -j ACCEPT<br># \u0414\u043b\u044f VPN<br># OpenVPN<br># sudo iptables -A INPUT -p udp &#8212;dport 1194 -j ACCEPT<br># sudo iptables -A OUTPUT -p udp &#8212;sport 1194 -j ACCEPT<br># KerioVPN<br># sudo iptables -A INPUT -p tcp &#8212;dport 4090 -j ACCEPT<br># sudo iptables -A OUTPUT -p tcp &#8212;sport 4090 -j ACCEPT<br># sudo iptables -A INPUT -p udp &#8212;dport 4090 -j ACCEPT<br># sudo iptables -A OUTPUT -p udp &#8212;sport 4090 -j ACCEPT<br># Microsoft VPN<br># sudo iptables -A INPUT -p tcp &#8212;dport 1723 -j ACCEPT<br># sudo iptables -A OUTPUT -p tcp &#8212;sport 1723 -j ACCEPT<br># sudo iptables -A INPUT -p tcp &#8212;dport 3522 -j ACCEPT<br># sudo iptables -A OUTPUT -p tcp &#8212;sport 3522 -j ACCEPT<br># sudo iptables -A INPUT -p 41 -j ACCEPT<br># sudo iptables -A INPUT -p gre -j ACCEPT<br># \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u043f\u043e\u0440\u0442 \u0434\u043b\u044f SQL<br># sudo iptables -A INPUT -p tcp &#8212;dport 1433 -j ACCEPT<br># sudo iptables -A OUTPUT -p tcp &#8212;sport 1433 -j ACCEPT<br># \u0412\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0437\u0430\u0449\u0438\u0442\u0443 \u043e\u0442 \u043f\u0435\u0440\u0435\u0431\u043e\u0440\u0430 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0445 \u043f\u043e\u0440\u0442\u043e\u0432<br># sudo iptables -A INPUT -p tcp -m tcp -j DROP<br># \u0412\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u0430\u0432\u0442\u043e\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443<br> sudo echo &#171;#! \/sbin\/iptables-restore&#187; &gt; \/etc\/network\/if-up.d\/iptables-rules<br> sudo iptables-save &gt;&gt; \/etc\/network\/if-up.d\/iptables-rules<br> sudo chmod +x \/etc\/network\/if-up.d\/iptables-rules<\/p>\n\n\n\n<p>\u0412 \u044d\u0442\u043e\u043c \u0441\u043a\u0440\u0438\u043f\u0442\u0435 \u043c\u043d\u043e\u0433\u043e \u043f\u0440\u043e \u0437\u0430\u043f\u0430\u0441, \u0447\u0442\u043e \u0431\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e, \u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0441\u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0443\u0436\u043d\u043e\u0435. \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043b\u0443\u0447\u0448\u0435 \u0432\u0441\u0435-\u0442\u0430\u043a \u043e\u0442 root-\u0430.<\/p>\n\n\n\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 \u0434\u043b\u044f \u0440\u0430\u0437\u0434\u0430\u0447\u0438 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0430 \u0432 \u0441\u0435\u0442\u0438:<\/p>\n\n\n\n<p class=\"has-background has-small-font-size has-very-light-gray-background-color\">!\/bin\/bash<br># \u041f\u0443\u0441\u0442\u044c eth1 (192.168.1.1\/24) \u044d\u0442\u043e \u0441\u0435\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0430, eth0 (10.41.0.1\/24) \u044d\u0442\u043e \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u0430\u044f \u0441\u0435\u0442\u044c<br># \u0423\u0434\u0430\u043b\u044f\u0435\u043c \u0432\u0441\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430<br> sudo iptables -F<br> sudo iptables &#8212;flush<br> sudo iptables &#8212;table nat &#8212;flush<br> sudo iptables &#8212;delete-chain<br> sudo iptables &#8212;table nat &#8212;delete-chain<br># \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u0441\u0435 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u043c<br> sudo iptables -P INPUT DROP<br> sudo iptables -P OUTPUT DROP<br> sudo iptables -P FORWARD DROP<br># \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0443 \u043f\u0430\u043a\u0435\u0442\u043e\u0432 \u0447\u0435\u0440\u0435\u0437 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u043f\u0435\u0442\u043b\u0435\u0432\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0438 \u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u043f\u0435\u0442\u043b\u0435\u0432\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u0445 INPUT<br> sudo iptables -A INPUT -i lo -j ACCEPT <br> sudo iptables -A OUTPUT -o lo -j ACCEPT<br># \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 ICMP<br> sudo iptables -A INPUT -p icmp &#8212;icmp-type 0 -j ACCEPT<br> sudo iptables -A INPUT -p icmp &#8212;icmp-type 8 -j ACCEPT<br> sudo iptables -A OUTPUT -p icmp -j ACCEPT<br># \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u044e\u0449\u0435\u0439 \u0432\u0441\u0435 \u0438\u0441\u0445\u043e\u043b\u044f\u0449\u0438\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f<br> sudo iptables -P OUTPUT ACCEPT<br># \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044c \u043f\u043e\u043f\u0430\u0434\u0430\u043d\u0438\u0435 \u043d\u0430 \u043d\u0430\u0448 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435\u0445 TCP- \u0438 UDP-\u043f\u0430\u043a\u0435\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u044b\u043b\u0438 \u0437\u0430\u043f\u0440\u043e\u0448\u0435\u043d\u044b \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u043c\u0438<br> sudo iptables -A INPUT -p TCP -m state &#8212;state ESTABLISHED,RELATED -j ACCEPT<br> sudo iptables -A INPUT -p UDP -m state &#8212;state ESTABLISHED,RELATED -j ACCEPT<br># \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u043f\u043e\u0440\u0442\u044b \u0434\u043b\u044f \u043d\u0430\u0448\u0438\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u043f\u0440\u0438\u0447\u0435\u043c \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 \u043f\u0435\u0440\u0435\u0431\u043e\u0440\u0430<br># \u0414\u043b\u044f DNS, \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e<br># sudo iptables -A INPUT &#8212;protocol udp &#8212;dport 53 &#8212;match state &#8212;state NEW &#8212;match string &#8212;algo kmp &#8212;hex-string &#171;|00 00 02 00 01|&#187; &#8212;from 40 &#8212;to 45 &#8212;match recent &#8212;name DNST &#8212;update &#8212;seconds 600 &#8212;jump DROP<br># sudo iptables -A INPUT &#8212;protocol udp &#8212;dport 53 &#8212;match state &#8212;state NEW &#8212;match string &#8212;algo kmp &#8212;hex-string &#171;|00 00 02 00 01|&#187; &#8212;from 40 &#8212;to 45 &#8212;match recent &#8212;name DNST &#8212;set &#8212;jump ACCEPT<br># sudo iptables -A INPUT -p udp &#8212;dport 53 -j ACCEPT<br># sudo iptables -A OUTPUT -p udp &#8212;sport 53 -j ACCEPT<br># \u0414\u043b\u044f \u043c\u043e\u0435\u0433\u043e RDP<br> sudo iptables -N RDP<br> sudo iptables -A INPUT -p tcp &#8212;dport 4319 -j RDP<br> sudo iptables -A OUTPUT -p tcp &#8212;sport 4319 -j RDP<br> sudo iptables -A RDP -m state &#8212;state NEW -m recent &#8212;set &#8212;name RDPH &#8212;rsource<br># sudo iptables -A RDP -m recent &#8212;update &#8212;seconds 300 &#8212;hitcount 2 &#8212;name RDPH &#8212;rsource -j LOG &#8212;log-prefix &#171;Anti RDPH-Bruteforce: &#187; &#8212;log-level 6<br> sudo iptables -A RDP -m recent &#8212;update &#8212;seconds 60 &#8212;hitcount 2 &#8212;name RDPH &#8212;rsource -j DROP<br> sudo iptables -A RDP -j ACCEPT<br># \u0414\u043b\u044f \u043c\u043e\u0435\u0433\u043e SSH<br> sudo iptables -N SSH<br> sudo iptables -A INPUT -p tcp &#8212;dport 4318 -j SSH<br> sudo iptables -A OUTPUT -p tcp &#8212;sport 4318 -j SSH<br> sudo iptables -A SSH -m state &#8212;state NEW -m recent &#8212;set &#8212;name SSHH &#8212;rsource<br># sudo iptables -A SSH -m recent &#8212;update &#8212;seconds 300 &#8212;hitcount 2 &#8212;name SSHH &#8212;rsource -j LOG &#8212;log-prefix &#171;Anti SSHH-Bruteforce: &#187; &#8212;log-level 6<br> sudo iptables -A SSH -m recent &#8212;update &#8212;seconds 60 &#8212;hitcount 2 &#8212;name SSHH &#8212;rsource -j DROP<br> sudo iptables -A SSH -j ACCEPT<br># \u041c\u043e\u0434\u0443\u043b\u0438 iptables MicrosoftVPN \u043d\u0443\u0436\u043d\u044b \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 gre, \u0430 \u0442\u0430\u043a \u0436\u0435 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b ftp<br> modprobe ip_conntrack<br> modprobe ip_conntrack_ftp<br> modprobe ip_nat_ftp<br> modprobe ip_gre<br> modprobe ip_conntrack_pptp<br> modprobe ip_nat_pptp<br># \u0412\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 NAT<br># \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u0435\u043c \u0443\u0436\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0432 \u0446\u0435\u043f\u043e\u0447\u043a\u0435 FORWARD, \u0442\u0430\u0431\u043b\u0438\u0446\u0435 filter<br> sudo iptables -A FORWARD -m conntrack &#8212;ctstate ESTABLISHED,RELATED -j ACCEPT<br># \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u0435\u043c \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0432 \u0446\u0435\u043f\u043e\u0447\u043a\u0435 FORWARD, \u0442\u0430\u0431\u043b\u0438\u0446\u0435 filter<br> sudo iptables -A FORWARD -m conntrack &#8212;ctstate NEW -i eth0 -j ACCEPT<br># \u0412\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0430\u043a\u0435\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u043e\u0445\u043e\u0434\u044f\u0442 \u0447\u0435\u0440\u0435\u0437 \u0446\u0435\u043f\u043e\u0447\u043a\u0443 FORWARD &#8212; \u043e\u0442\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0442\u044c<br> sudo iptables -P FORWARD DROP<br># \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043c\u0430\u0441\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 (\u043f\u043e\u0434\u043c\u0435\u043d\u0443 \u0430\u0434\u0440\u0435\u0441\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u0435\u043b\u044f \u043f\u0430\u043a\u0435\u0442\u0430 \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430\u0445) \u0432\u0441\u0435\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432, \u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0441 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 eth0<br> sudo iptables -t nat -A POSTROUTING -o eth1 -s 10.41.0.0\/24 -j MASQUERADE<br># \u0417\u0430\u043f\u0440\u0435\u0449\u0430\u0435\u043c \u0434\u043e\u0441\u0442\u0443\u043f \u0441\u043d\u0430\u0440\u0443\u0436\u0438 \u0432\u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u044e\u044e \u0441\u0435\u0442\u044c<br> iptables -A FORWARD -i eth1 -o eth1 -j REJECT<br># \u041f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c DNS<br> sudo iptables -t nat -A PREROUTING -p udp &#8212;in-interface eth1 &#8212;dport 53 -j DNAT &#8212;to-destination 10.41.0.13<br> sudo iptables -t nat -A POSTROUTING -p udp &#8212;dst 10.41.0.13 &#8212;dport 53 -j SNAT &#8212;to-source 192.168.1.1<br> sudo iptables -A FORWARD -i eth1 -p udp -d 10.41.0.13 &#8212;dport 53 -j ACCEPT<br> sudo iptables -t nat -A PREROUTING -p tcp &#8212;in-interface eth1 &#8212;dport 53 -j DNAT &#8212;to-destination 10.41.0.13<br> sudo iptables -t nat -A POSTROUTING -p tcp &#8212;dst 10.41.0.13 &#8212;dport 53 -j SNAT &#8212;to-source 192.168.1.1<br> sudo iptables -A FORWARD -i eth1 -p tcp -d 10.41.0.13 &#8212;dport 53 -j ACCEPT<br># \u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u043e\u0447\u0442\u044b \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u043f\u043e\u0440\u0442\u044b<br># SMTP<br> sudo iptables -t nat -A PREROUTING -p tcp &#8212;in-interface eth1 &#8212;dport 25 -j DNAT &#8212;to-destination 10.41.0.2<br> sudo iptables -t nat -A POSTROUTING -p tcp &#8212;dst 10.41.0.2 &#8212;dport 25 -j SNAT &#8212;to-source 192.168.1.1<br> sudo iptables -A FORWARD -i eth1 -p tcp -d 10.41.0.2 &#8212;dport 25 -j ACCEPT<br># SSMTP<br> sudo iptables -t nat -A PREROUTING -p tcp &#8212;in-interface eth1 &#8212;dport 465 -j DNAT &#8212;to-destination 10.41.0.2<br> sudo iptables -t nat -A POSTROUTING -p tcp &#8212;dst 10.41.0.2 &#8212;dport 465 -j SNAT &#8212;to-source 192.168.1.1<br> sudo iptables -A FORWARD -i eth1 -p tcp -d 10.41.0.2 &#8212;dport 465 -j ACCEPT<br># SMTP Submission<br> sudo iptables -t nat -A PREROUTING -p tcp &#8212;in-interface eth1 &#8212;dport 587 -j DNAT &#8212;to-destination 10.41.0.2<br> sudo iptables -t nat -A POSTROUTING -p tcp &#8212;dst 10.41.0.2 &#8212;dport 587 -j SNAT &#8212;to-source 192.168.1.1<br> sudo iptables -A FORWARD -i eth1 -p tcp -d 10.41.0.2 &#8212;dport 587 -j ACCEPT<br># POP3<br> sudo iptables -t nat -A PREROUTING -p tcp &#8212;in-interface eth1 &#8212;dport 110 -j DNAT &#8212;to-destination 10.41.0.2<br> sudo iptables -t nat -A POSTROUTING -p tcp &#8212;dst 10.41.0.2 &#8212;dport 110 -j SNAT &#8212;to-source 192.168.1.1<br> sudo iptables -A FORWARD -i eth1 -p tcp -d 10.41.0.2 &#8212;dport 110 -j ACCEPT<br># SPOP3<br> sudo iptables -t nat -A PREROUTING -p tcp &#8212;in-interface eth1 &#8212;dport 995 -j DNAT &#8212;to-destination 10.41.0.2<br> sudo iptables -t nat -A POSTROUTING -p tcp &#8212;dst 10.41.0.2 &#8212;dport 995 -j SNAT &#8212;to-source 192.168.1.1<br> sudo iptables -A FORWARD -i eth1 -p tcp -d 10.41.0.2 &#8212;dport 995 -j ACCEPT<br># IMAP<br> sudo iptables -t nat -A PREROUTING -p tcp &#8212;in-interface eth1 &#8212;dport 143 -j DNAT &#8212;to-destination 10.41.0.2<br> sudo iptables -t nat -A POSTROUTING -p tcp &#8212;dst 10.41.0.2 &#8212;dport 143 -j SNAT &#8212;to-source 192.168.1.1<br> sudo iptables -A FORWARD -i eth1 -p tcp -d 10.41.0.2 &#8212;dport 143 -j ACCEPT<br># SIMAP<br> sudo iptables -t nat -A PREROUTING -p tcp &#8212;in-interface eth1 &#8212;dport 993 -j DNAT &#8212;to-destination 10.41.0.2<br> sudo iptables -t nat -A POSTROUTING -p tcp &#8212;dst 10.41.0.2 &#8212;dport 993 -j SNAT &#8212;to-source 192.168.1.1<br> sudo iptables -A FORWARD -i eth1 -p tcp -d 10.41.0.2 &#8212;dport 993 -j ACCEPT<br># HTTP<br> sudo iptables -t nat -A PREROUTING -p tcp &#8212;in-interface eth1 &#8212;dport 80 -j DNAT &#8212;to-destination 10.41.0.2<br> sudo iptables -t nat -A POSTROUTING -p tcp &#8212;dst 10.41.0.2 &#8212;dport 80 -j SNAT &#8212;to-source 192.168.1.1<br> sudo iptables -A FORWARD -i eth1 -p tcp -d 10.41.0.2 &#8212;dport 80 -j ACCEPT<br> sudo iptables -t nat -A PREROUTING -p tcp &#8212;in-interface eth1 &#8212;dport 8800 -j DNAT &#8212;to-destination 10.41.0.2<br> sudo iptables -t nat -A POSTROUTING -p tcp &#8212;dst 10.41.0.2 &#8212;dport 8800j SNAT &#8212;to-source 192.168.1.1<br> sudo iptables -A FORWARD -i eth1 -p tcp -d 10.41.0.2 &#8212;dport 8800 -j ACCEPT<br># SHTTP<br> sudo iptables -t nat -A PREROUTING -p tcp &#8212;in-interface eth1 &#8212;dport 443 -j DNAT &#8212;to-destination 10.41.0.2<br> sudo iptables -t nat -A POSTROUTING -p tcp &#8212;dst 10.41.0.2 &#8212;dport 443 -j SNAT &#8212;to-source 192.168.1.1<br> sudo iptables -A FORWARD -i eth1 -p tcp -d 10.41.0.2 &#8212;dport 443 -j ACCEPT<br> sudo iptables -t nat -A PREROUTING -p tcp &#8212;in-interface eth1 &#8212;dport 8843 -j DNAT &#8212;to-destination 10.41.0.2<br> sudo iptables -t nat -A POSTROUTING -p tcp &#8212;dst 10.41.0.2 &#8212;dport 8843 -j SNAT &#8212;to-source 192.168.1.1<br> sudo iptables -A FORWARD -i eth1 -p tcp -d 10.41.0.2 &#8212;dport 8843 -j ACCEPT<br># \u0414\u043b\u044f VPN<br># OpenVPN<br> sudo iptables -N OpenVPN<br> sudo iptables -t nat -A PREROUTING -p udp &#8212;in-interface eth1 &#8212;dport 1194 -j DNAT &#8212;to-destination 10.41.0.2<br> sudo iptables -A FORWARD -i eth1 -p udp -d 10.41.0.2 &#8212;dport 1194 -j OpenVPN<br> sudo iptables -A OpenVPN -m recent &#8212;set &#8212;name OpenVPNH &#8212;rsource <br># sudo iptables -A OpenVPN -m recent &#8212;update &#8212;seconds 60 &#8212;hitcount 2 &#8212;name OpenVPNH &#8212;rsource -j LOG &#8212;log-prefix &#171;Anti OpenVPNH-Bruteforce: &#187; &#8212;log-level 6<br> sudo iptables -A OpenVPN -m recent &#8212;update &#8212;seconds 300 &#8212;hitcount 2 &#8212;name OpenVPNH &#8212;rsource -j DROP<br> sudo iptables -A OpenVPN -j ACCEPT<br># Microsoft VPN<br> sudo iptables -A FORWARD -p gre -j ACCEPT<br> sudo iptables -t nat -A PREROUTING &#8212;dst 192.168.1.1 -p tcp &#8212;dport 1723 -j DNAT &#8212;to-destination 10.41.0.2<br> sudo iptables -t nat -A POSTROUTING &#8212;dst 10.41.0.2 -p tcp &#8212;dport 1723 -j SNAT &#8212;to-source 10.41.0.11<br> sudo iptables -t nat -A OUTPUT &#8212;dst 185.97.115.98 -p tcp &#8212;dport 1723 -j DNAT &#8212;to-destination 10.41.0.2<br> sudo iptables -I FORWARD 1 -i eth1 -o eth0 -d 10.41.0.2 -p tcp -m tcp &#8212;dport 1723 -j ACCEPT<br><br># \u0411\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u043c \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435<br> sudo iptables -A INPUT -p tcp -m tcp -j DROP<br># \u0412\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u0430\u0432\u0442\u043e\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443<br> sudo echo &#171;#! \/sbin\/iptables-restore&#187; &gt; \/etc\/network\/if-up.d\/iptables-rules<br> sudo iptables-save &gt;&gt; \/etc\/network\/if-up.d\/iptables-rules<br> sudo chmod +x \/etc\/network\/if-up.d\/iptables-rules<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><br><\/p>\n\n\n\n<p><br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0417\u0434\u0435\u0441\u044c \u044f \u043d\u0435 \u0441\u0442\u0430\u043d\u0443 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u043e\u0431\u0449\u0438\u0439 \u043f\u0440\u0438\u043d\u0446\u0438\u043f, \u0442.\u043a. \u044d\u0442\u043e \u0442\u0435\u043c\u0430 \u043e\u0447\u0435\u043d\u044c \u043e\u0431\u0448\u0438\u0440\u043d\u0430\u044f, \u0430 \u0432\u044b\u043b\u043e\u0436\u0443 \u043b\u0438\u0448\u044c \u0443\u0436\u0435 \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u0441\u043a\u0440\u0438\u043f\u0442\u044b \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0439. \u0418 \u0442\u0430\u043a \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u0441\u0435 \u0442\u0430\u043a\u0438 \u0432\u043a\u043b\u044e\u0447\u0438\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0444\u043e\u0440\u0432\u0430\u0434\u0438\u043d\u0433\u0430 \u0442\u0440\u0430\u0444\u0438\u043a\u0430 \u0447\u0435\u0440\u0435\u0437 \u043c\u0430\u0448\u0438\u043d\u043a\u0443 \u043d\u0430 linux: sudo sed -i \u2018\/#net.ipv4.ip_forward=1\/s\/#net.ipv4.ip_forward=1\/net.ipv4.ip_forward=1\/g\u2019 \/etc\/sysctl.conf \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440. \u0421\u043a\u0440\u0438\u043f\u0442 \u043e\u0447\u0438\u0441\u0442\u043a\u0438 \u0444\u0430\u0439\u0435\u0440\u0432\u043e\u043b\u0430: !\/bin\/bash# \u0423\u0434\u0430\u043b\u044f\u0435\u043c \u0432\u0441\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 sudo iptables -F [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"_links":{"self":[{"href":"http:\/\/ast-1c.kz\/almasoft\/index.php?rest_route=\/wp\/v2\/posts\/746"}],"collection":[{"href":"http:\/\/ast-1c.kz\/almasoft\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/ast-1c.kz\/almasoft\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/ast-1c.kz\/almasoft\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/ast-1c.kz\/almasoft\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=746"}],"version-history":[{"count":7,"href":"http:\/\/ast-1c.kz\/almasoft\/index.php?rest_route=\/wp\/v2\/posts\/746\/revisions"}],"predecessor-version":[{"id":757,"href":"http:\/\/ast-1c.kz\/almasoft\/index.php?rest_route=\/wp\/v2\/posts\/746\/revisions\/757"}],"wp:attachment":[{"href":"http:\/\/ast-1c.kz\/almasoft\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=746"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/ast-1c.kz\/almasoft\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=746"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/ast-1c.kz\/almasoft\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=746"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}