{"id":200636,"date":"2013-11-02T13:01:03","date_gmt":"2013-11-02T09:01:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=200636"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=200636","title":{"rendered":"<span class=\"post_title\">Asterisk + iptables \u2014 \u0441\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t\u0425\u043e\u0447\u0443 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432\u0430\u0448\u0435\u043c\u0443 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044e \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0438 \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0439 shell-\u0441\u043a\u0440\u0438\u043f\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0443\u0436\u043d\u043e \u043b\u0438\u0448\u044c \u0441\u043b\u0435\u0433\u043a\u0430 \u043f\u043e\u0434\u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u0437\u0430\u0442\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u2014 \u0438 \u0431\u0440\u0430\u043d\u0434\u043c\u0430\u0443\u044d\u0440 \u043d\u0430 \u0432\u0430\u0448\u0435\u043c asterisk-\u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d \u0431\u0435\u0437 \u043b\u0438\u0448\u043d\u0438\u0445 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439.<\/p>\n<p>  <a name=\"habracut\"><\/a><\/p>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 shell-\u0441\u043a\u0440\u0438\u043f\u0442 \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u044b\u043c (\u043d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c\u0442\u0435 chmod 755):<\/p>\n<pre><code class=\"bash\"># \u0421\u043e\u0437\u0434\u0430\u0451\u043c \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 iptables -P INPUT ACCEPT iptables -F iptables -A INPUT -i lo -j ACCEPT  # \u0415\u0441\u043b\u0438 \u043c\u044b \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0434\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0441\u0435\u0442\u0438, \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u043e\u0439 \u043a eth0 - \u0441\u0442\u0440\u043e\u0447\u043a\u0443 \u043d\u0438\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0441\u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c # iptables -A INPUT -i eth0 -j ACCEPT  # \u041d\u0435 \u0442\u0440\u043e\u0433\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\u0439 iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT  # \u0420\u0430\u0437\u0440\u0435\u0448\u0430\u0435\u043c SSH iptables -A INPUT -p tcp --dport 22 -j ACCEPT  # \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u043e - \u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0451 \u043a\u0440\u043e\u043c\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u043d\u0438\u0436\u0435 iptables -P INPUT DROP iptables -P FORWARD DROP iptables -P OUTPUT ACCEPT  # \u0420\u0430\u0437\u0440\u0435\u0448\u0430\u0435\u043c HTTPS (\u0435\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0430\u0434\u043c\u0438\u043d\u043a\u0443 \u0442\u0438\u043f\u0430 FreePBX) # iptables -A INPUT -p tcp --dport 443 -j ACCEPT  # \u0420\u0430\u0437\u0440\u0435\u0448\u0430\u0435\u043c SIP \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0445 \u0430\u0434\u0440\u0435\u0441\u043e\u0432 \u0438 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u043e\u0432 # iptables -A INPUT -p udp -m udp -s 123.123.123.123 --dport 5060 -j ACCEPT # iptables -A INPUT -p udp -m udp -s 125.125.125.125 --dport 5060 -j ACCEPT # iptables -A INPUT -p udp -m udp -s 192.168.0.0\/24 --dport 5060 -j ACCEPT  # \u041b\u0438\u0431\u043e \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u0435\u043c SIP \u0441 \u043b\u044e\u0431\u043e\u0433\u043e \u0430\u0434\u0440\u0435\u0441\u0430 # iptables -A INPUT -p udp -m udp --dport 5060 -j ACCEPT  # \u0420\u0430\u0437\u0440\u0435\u0448\u0430\u0435\u043c RTP iptables -A INPUT -p udp -m udp --dport 10000:20000 -j ACCEPT  # \u0420\u0430\u0437\u0440\u0435\u0448\u0430\u0435\u043c IAX2 \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0430\u0434\u0440\u0435\u0441\u0430 # iptables -A INPUT -p udp -m udp -s 192.168.1.1 --dport 4569 -j ACCEPT  # \u0418\u043b\u0438 \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u043c IAX2 \u0441 \u043b\u044e\u0431\u043e\u0433\u043e \u0430\u0434\u0440\u0435\u0441\u0430 # iptables -A INPUT -p udp -m udp --dport 4569 -j ACCEPT  # \u0417\u0430\u0449\u0438\u0442\u0430 \u043e\u0442 SIP flood iptables -A INPUT -p udp --dport 5060 -m recent --set --name SIP iptables -A INPUT -p udp --dport 5060 -m recent --update --seconds 2 --hitcount 20 --name SIP -j LOG --log-level INFO --log-prefix &quot;SIP flood detected: &quot;  <\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 CentOS \u043f\u043e\u0434\u043e\u0431\u043d\u0430\u044f \u041e\u0421 \u2014 \u0442\u043e \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u0431\u0440\u0430\u0442\u044c <br \/>  service iptables save<br \/>  service iptables start    \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/200636\/\"> http:\/\/habrahabr.ru\/post\/200636\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t\u0425\u043e\u0447\u0443 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432\u0430\u0448\u0435\u043c\u0443 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044e \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0438 \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0439 shell-\u0441\u043a\u0440\u0438\u043f\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0443\u0436\u043d\u043e \u043b\u0438\u0448\u044c \u0441\u043b\u0435\u0433\u043a\u0430 \u043f\u043e\u0434\u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u0437\u0430\u0442\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u2014 \u0438 \u0431\u0440\u0430\u043d\u0434\u043c\u0430\u0443\u044d\u0440 \u043d\u0430 \u0432\u0430\u0448\u0435\u043c asterisk-\u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d \u0431\u0435\u0437 \u043b\u0438\u0448\u043d\u0438\u0445 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-200636","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/200636","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=200636"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/200636\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=200636"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=200636"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=200636"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}