{"id":4234,"date":"2014-05-08T13:18:33","date_gmt":"2014-05-08T10:18:33","guid":{"rendered":"http:\/\/skeletor.org.ua\/?p=4234"},"modified":"2022-03-14T16:12:18","modified_gmt":"2022-03-14T14:12:18","slug":"%d0%bf%d0%be%d0%b4%d0%ba%d0%bb%d1%8e%d1%87%d0%b5%d0%bd%d0%b8%d0%b5-%d0%ba-asterisk%d1%83-%d1%87%d0%b5%d1%80%d0%b5%d0%b7-vpn-%d1%82%d1%83%d0%bd%d0%b5%d0%bb%d1%8c","status":"publish","type":"post","link":"https:\/\/skeletor.org.ua\/?p=4234","title":{"rendered":"\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a asterisk&#8217;\u0443 \u0447\u0435\u0440\u0435\u0437 VPN \u0442\u0443\u043d\u043d\u0435\u043b\u044c"},"content":{"rendered":"<p>\u0421\u0445\u0435\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f:<\/p>\n<p><span style=\"color: #008000;\">\u043a\u043b\u0438\u0435\u043d\u0442 &#8212;&#8211; (external ip=1.1.1.1) SRV (openvpn ip=10.8.0.1) &#8212;- [openvpn tunnel] &#8212;&#8211; (openvpn ip=10.8.0.6) Asterisk (NO external IP)<\/span><\/p>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c,&nbsp;\u043a\u043b\u0438\u0435\u043d\u0442 \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u0445 <strong>SIP<\/strong>-\u0430\u043a\u043a\u0430\u0443\u043d\u0442\u0430 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0430 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 <strong>ip=1.1.1.1<\/strong> \u0438 \u0441\u043e\u0432\u0435\u0440\u0448\u0430\u0435\u0442 \u0437\u0432\u043e\u043d\u043a\u0438 \u0447\u0435\u0440\u0435\u0437 \u0441\u0435\u0440\u0432\u0435\u0440 \u0430\u0441\u0442\u0435\u0440\u0438\u0441\u043a\u0430, \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435\u0442 \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e IP (&#8220;\u0441\u043f\u0440\u044f\u0442\u0430\u043d&#8221; \u0432 \u043e\u0444\u0438\u0441\u0435)<\/p>\n<p>\u0420\u0430\u0437\u0434\u0435\u043b\u0438\u043c \u0437\u0430\u0434\u0430\u0447\u0443 \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e.<\/p>\n<p><!--more--><\/p>\n<p><strong><span style=\"color: #ff0000;\">1) \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 VPN&#8217;a.<\/span><\/strong><\/p>\n<p>\u041d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 <strong>SRV<\/strong> \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u0435\u043c \u0441\u0435\u0440\u0432\u0435\u0440 <strong>openvpn<\/strong>, \u0430 \u043d\u0430 <strong>asterisk<\/strong> &#8211; \u043a\u043b\u0438\u0435\u043d\u0442. \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043b\u044e\u0431\u0430\u044f (\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u043b\u043e\u0433\u0438\u043d\u044b\/\u043f\u0430\u0440\u043e\u043b\u0438,&#8230;), \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u044d\u0442\u043e &#8220;\u043f\u0440\u0438\u0432\u044f\u0437\u0430\u0442\u044c&#8221; \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u044b\u0439 IP \u043a\u043b\u0438\u0435\u043d\u0442\u0443 <strong>asterisk&#8217;a<\/strong>. \u042f \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u044e \u0447\u0435\u0440\u0435\u0437 \u043e\u043f\u0446\u0438\u044e<\/p>\n<p><code>client-config-dir \/etc\/openvpn\/ccd<\/code><\/p>\n<p>\u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0444\u0430\u0439\u043b\u0430 <strong>\/etc\/openvpn\/ccd\/asterisk<\/strong> \u0442\u0430\u043a\u043e\u0433\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u044f:<\/p>\n<p><code>ifconfig-push 10.8.0.6 10.8.0.5<\/code><\/p>\n<p>\u0442\u043e \u0435\u0441\u0442\u044c \u0443 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 <strong>asterisk<\/strong> \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 <strong>IP=10.8.0.6<\/strong><\/p>\n<p><strong><span style=\"color: #ff0000;\">2) \u0420\u0435\u0434\u0438\u0440\u0435\u043a\u0442 \u043f\u043e\u0440\u0442\u043e\u0432.<\/span><\/strong><\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0431\u044b <strong>asterisk<\/strong> \u0442\u0440\u0430\u0444\u0438\u043a \u043d\u0430\u043f\u0440\u0430\u044f\u0432\u043b\u044f\u043b \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0432 <strong>VPN<\/strong>-\u043a\u0430\u043d\u0430\u043b, \u0430 \u043d\u0435 \u0432 \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u044b\u0439 \u0448\u043b\u044e\u0437, \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u0432\u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 <strong>IP=10.8.0.1<\/strong> (\u044d\u0442\u043e ip \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 <strong>openvpn<\/strong>). \u0414\u043b\u044f \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b asterisk&#8217;a \u043f\u043e \u0442\u0430\u043a\u043e\u0439 \u0441\u0445\u0435\u043c\u0435, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0431\u0440\u043e\u0441\u0438\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u043f\u043e\u0440\u0442\u044b:<\/p>\n<p><em><strong><span style=\"color: #ff6600;\">5060\/udp<\/span><\/strong><\/em> &#8211; \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f<br \/>\n<em><strong><span style=\"color: #ff6600;\">10000-20000\/udp<\/span><\/strong><\/em> &#8211; \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043e\u0431\u0449\u0435\u043d\u0438\u0435 (\u0433\u043e\u043b\u043e\u0441).<\/p>\n<p>\u041f\u043e\u0440\u0442\u044b <strong>10000-20000<\/strong> \u0431\u0435\u0440\u0443\u0442\u0441\u044f \u0438\u0437 \u043a\u043e\u043d\u0444\u0438\u0433\u0430 <strong>\/etc\/asterisk\/rtp.conf<\/strong>:<\/p>\n<p><code>rtpstart=10000<br \/>\nrtpend=20000<\/code><\/p>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0434\u043b\u044f \u043f\u0440\u043e\u0431\u0440\u043e\u0441\u0430:<\/p>\n<p><code># iptables -t nat -A PREROUTING -p udp -d 1.1.1.1 -m multiport --dport 5060,10000:20000 -j DNAT --to-destination 10.8.0.6<\/code><\/p>\n<p>\u0418 \u043d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0435\u043c \u043f\u0440\u043e \u043d\u0430\u0442 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e:<\/p>\n<p><code># iptables --table nat --append POSTROUTING --out-interface tun0 -j SNAT --to 10.8.0.1<\/code><\/p>\n<p>\u0433\u0434\u0435 <strong>tun0<\/strong> &#8211; \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 openvpn&#8217;a<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0421\u0445\u0435\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f: \u043a\u043b\u0438\u0435\u043d\u0442 &#8212;&#8211; (external ip=1.1.1.1) SRV (openvpn ip=10.8.0.1) &#8212;- [openvpn tunnel] &#8212;&#8211; (openvpn ip=10.8.0.6) Asterisk (NO external IP) \u0422\u043e \u0435\u0441\u0442\u044c,&nbsp;\u043a\u043b\u0438\u0435\u043d\u0442 \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u0445 SIP-\u0430\u043a\u043a\u0430\u0443\u043d\u0442\u0430 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0430 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 ip=1.1.1.1 \u0438 \u0441\u043e\u0432\u0435\u0440\u0448\u0430\u0435\u0442 \u0437\u0432\u043e\u043d\u043a\u0438 \u0447\u0435\u0440\u0435\u0437 \u0441\u0435\u0440\u0432\u0435\u0440 \u0430\u0441\u0442\u0435\u0440\u0438\u0441\u043a\u0430, \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435\u0442 \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e IP (&#8220;\u0441\u043f\u0440\u044f\u0442\u0430\u043d&#8221; \u0432 \u043e\u0444\u0438\u0441\u0435) \u0420\u0430\u0437\u0434\u0435\u043b\u0438\u043c \u0437\u0430\u0434\u0430\u0447\u0443 \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,7],"tags":[],"class_list":["post-4234","post","type-post","status-publish","format-standard","hentry","category-linux","category-telephony"],"_links":{"self":[{"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=\/wp\/v2\/posts\/4234","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=4234"}],"version-history":[{"count":2,"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=\/wp\/v2\/posts\/4234\/revisions"}],"predecessor-version":[{"id":5850,"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=\/wp\/v2\/posts\/4234\/revisions\/5850"}],"wp:attachment":[{"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4234"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4234"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4234"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}