{"id":5846,"date":"2022-03-14T13:21:20","date_gmt":"2022-03-14T11:21:20","guid":{"rendered":"https:\/\/skeletor.org.ua\/?p=5846"},"modified":"2022-09-09T14:55:55","modified_gmt":"2022-09-09T11:55:55","slug":"%d0%b7%d0%b0%d0%b2%d0%b5%d1%80%d0%bd%d1%83%d1%82%d1%8c-%d1%87%d0%b0%d1%81%d1%82%d1%8c-%d1%82%d1%80%d0%b0%d1%84%d0%b8%d0%ba%d0%b0-%d0%b2-openvpn-%d1%82%d1%83%d0%bd%d0%b5%d0%bb%d1%8c","status":"publish","type":"post","link":"https:\/\/skeletor.org.ua\/?p=5846","title":{"rendered":"\u0417\u0430\u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0447\u0430\u0441\u0442\u044c \u0442\u0440\u0430\u0444\u0438\u043a\u0430 \u0432 OpenVPN \u0442\u0443\u043d\u043d\u0435\u043b\u044c."},"content":{"rendered":"\n<p>\u0412\u0432\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435: 2 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 <strong>Linux<\/strong> \u0441\u0432\u044f\u0437\u0430\u043d\u044b \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439 \u0447\u0435\u0440\u0435\u0437 <strong>OpenVPN<\/strong> \u0442\u0443\u043d\u043d\u0435\u043b\u044c. \u041d\u0443\u0436\u043d\u043e \u0434\u043b\u044f \u0447\u0430\u0441\u0442\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u0437\u0430 \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u043a\u043e\u043d\u0446\u043e\u0432 <strong>VPN&#8217;a<\/strong> \u0437\u0430\u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0432\u0435\u0441\u044c \u0442\u0440\u0430\u0444\u0438\u043a \u0432 \u0442\u0443\u043d\u043d\u0435\u043b\u044c, \u0442\u043e \u0435\u0441\u0442\u044c, \u0447\u0442\u043e \u0431\u044b \u043e\u043d\u0438 \u0432\u044b\u0445\u043e\u0434\u0438\u043b\u0438 \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442 \u043d\u0435 \u0447\u0435\u0440\u0435\u0437 \u0441\u0432\u043e\u0439 <strong>GW<\/strong>, \u0430 \u0447\u0435\u0440\u0435\u0437 \u0443\u0434\u0430\u043b\u0451\u043d\u043d\u044b\u0439 <strong>GW<\/strong>, \u043f\u0440\u043e\u0439\u0434\u044f \u0447\u0435\u0440\u0435\u0437 <strong>VPN<\/strong>.<\/p>\n\n\n\n<p><em><mark style=\"background-color:rgba(0, 0, 0, 0);color:#dd770d\" class=\"has-inline-color\">UPD. \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0445\u0435\u043c\u0435 \u0435\u0441\u0442\u044c \u043d\u044e\u0430\u043d\u0441: \u043e\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c, \u0435\u0441\u043b\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u0438\u0435 \u043c\u0430\u0448\u0438\u043d\u044b \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0437\u0430 \u0445\u043e\u0441\u0442\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f OpenVPN-\u043a\u043b\u0438\u0435\u043d\u0442\u043e\u043c. \u0412 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043f\u0430\u043a\u0435\u0442\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u043a\u0438\u0434\u0430\u0442\u044c \u0445\u043e\u0441\u0442, \u0445\u043e\u0442\u044f \u0447\u0435\u0440\u0435\u0437 tcpdump \u0432\u044b \u0438\u0445 \u0431\u0443\u0434\u0435\u0442\u0435 \u0432\u0438\u0434\u0435\u0442\u044c. \u0421\u0432\u044f\u0437\u0430\u043d\u043e \u044d\u0442\u043e \u0441 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u0441\u0430\u043c\u043e\u0433\u043e OpenVPN&#8217;a. \u041f\u043e\u043a\u0430 \u043d\u0435 \u043d\u0430\u0448\u0451\u043b \u043a\u0430\u043a \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0448\u0438\u0442\u044c. \u041a\u0430\u043a workaround, \u043c\u043e\u0436\u043d\u043e \u043b\u0438\u0431\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0440\u043e\u043b\u0438 \u043a\u043b\u0438\u0435\u043d\u0442-\u0441\u0435\u0440\u0432\u0435\u0440, \u043b\u0438\u0431\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0442\u0443\u043d\u043d\u0435\u043b\u044c \u0438\u043b\u0438 \u0434\u0440\u0443\u0433\u043e\u0439 \u0442\u0438\u043f VPN&#8217;a.<\/mark><\/em><\/p>\n\n\n<p><!--more--><\/p>\n\n\n<p><strong><em><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-blue-color\">\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0430<\/mark><\/em><\/strong><\/p>\n\n\n\n<p>\u0412 client.conf <strong>OpenVPN&#8217;a<\/strong> \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0442\u0430\u043a\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443<\/p>\n\n\n\n<p><code>up \/etc\/openvpn\/client.sh<\/code><\/p>\n\n\n\n<p>\u0421\u0430\u043c <strong>client.sh<\/strong>:<\/p>\n\n\n<pre>#!\/bin\/sh\n\/sbin\/ip route add default via 10.6.11.1 proto static table T2<br \/>\/sbin\/ip route add 192.168.55.3 via 10.6.11.2 dev tun4<br \/>\/sbin\/ip route add 192.168.55.4 via 10.6.11.2 dev tun4<br \/>\/opt\/scripts\/remote_vpn.sh\n<\/pre>\n\n\n<p>\u0433\u0434\u0435 <strong>10.6.11.1<\/strong> &#8211; \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 <strong>IP<\/strong> \u0442\u0443\u043d\u0435\u043b\u044f \u0443\u0434\u0430\u043b\u0451\u043d\u043d\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u0442\u0430\u0431\u043b\u0438\u0446\u0430 <strong>T2<\/strong> \u043e\u043f\u0438\u0441\u0430\u043d\u0430 \u0432 \u0444\u0430\u0439\u043b\u0435 <strong>\/etc\/iproute\/rt_table<\/strong> \u0442\u0430\u043a:<\/p>\n\n\n\n<p><code>251 T2<\/code><\/p>\n\n\n\n<p>\u0421\u0430\u043c <strong>\/opt\/scripts\/remote_vpn.sh<\/strong> \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n\n\n<pre>#!\/bin\/sh\nIP=\/sbin\/ip\ntable=\"T2\"\n$IP rule del table $table\nwhile $IP rule delete from 0\/0 to 0\/0 table $table\ndo\n        true\ndone\n$IP rule add from 192.168.55.3\/32 to 0\/0 table $table\n$IP rule add from 192.168.55.4\/32 to 0\/0 table $table\n<\/pre>\n\n\n<p>\u041f\u043e\u0441\u043b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 (\u0432\u043d\u0435\u0441\u0435\u043d\u0438\u0435\/\u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043d\u043e\u0432\u044b\u0445 <strong>IP<\/strong>), \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u044d\u0442\u043e\u0442 \u0441\u043a\u0440\u0438\u043f\u0442.<\/p>\n\n\n\n<p><strong><em><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-blue-color\">\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430<\/mark><\/em><\/strong><\/p>\n\n\n\n<p>\u0422\u0443\u0442 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e, \u0442\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044c \u043a\u043b\u0438\u0435\u043d\u0442\u0430\u043c <strong>192.168.55.3<\/strong>,&#8230; \u0432\u044b\u0445\u043e\u0434\u0438\u0442\u044c \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442. \u0422\u043e \u0435\u0441\u0442\u044c, \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044c \u0434\u043b\u044f \u043d\u0438\u0445 <strong>NAT<\/strong> + \u043f\u0440\u0430\u0432\u0438\u043b\u0430 <strong>FireWall<\/strong>.<\/p>\n\n\n\n<p>====================================================================<\/p>\n\n\n\n<p><strong><em><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-blue-color\">\u0414\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435.<\/mark><\/em><\/strong><\/p>\n\n\n\n<p>\u0415\u0441\u043b\u0438 \u043f\u043e \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043f\u0440\u0438\u0447\u0438\u043d\u0435 \u044d\u0442\u043e \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0435\u0441\u0442\u044c \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0437\u0430\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0442\u044c \u043f\u0430\u043a\u0435\u0442\u044b \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u043c\u0435\u0442\u043e\u043a.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u041f\u0440\u0430\u0432\u0438\u043b\u043e \u0434\u043b\u044f \u0440\u043e\u0443\u0442\u0438\u043d\u0433\u0430 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043c\u0435\u0442\u043e\u043a:<\/li><\/ul>\n\n\n\n<p><code># ip rule add fwmark 0x3 lookup&nbsp;T2<\/code><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u041f\u0440\u0430\u0432\u0438\u043b\u043e \u0444\u0430\u0439\u0435\u0440\u0432\u043e\u043b\u0430 (\u0442\u0443\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 &#8220;\u043d\u0430\u0432\u0435\u0448\u0438\u0432\u0430\u043d\u0438\u044f&#8221; \u043c\u0435\u0442\u043e\u043a):<\/li><\/ul>\n\n\n\n<p><code># iptables -t mangle -A PREROUTING -i $int_if -p tcp -m multiport --dports 80,443 -j MARK --set-mark 0x3<\/code><\/p>\n\n\n\n<p><strong><em><mark style=\"background-color:rgba(0, 0, 0, 0);color:#f19a11\" class=\"has-inline-color\">UPD.<\/mark><\/em><\/strong><\/p>\n\n\n\n<p>\u0418\u043d\u043e\u0433\u0434\u0430, \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 <strong>multiport <\/strong>\u0447\u0430\u0441\u0442\u044c \u0442\u0440\u0430\u0444\u0438\u043a\u0430 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0435\u0442 \u0437\u0430\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0442\u044c\u0441\u044f. Workaround \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d &#8211; \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u0440\u0442\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0412\u0432\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435: 2 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 Linux \u0441\u0432\u044f\u0437\u0430\u043d\u044b \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439 \u0447\u0435\u0440\u0435\u0437 OpenVPN \u0442\u0443\u043d\u043d\u0435\u043b\u044c. \u041d\u0443\u0436\u043d\u043e \u0434\u043b\u044f \u0447\u0430\u0441\u0442\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u0437\u0430 \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u043a\u043e\u043d\u0446\u043e\u0432 VPN&#8217;a \u0437\u0430\u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0432\u0435\u0441\u044c \u0442\u0440\u0430\u0444\u0438\u043a \u0432 \u0442\u0443\u043d\u043d\u0435\u043b\u044c, \u0442\u043e \u0435\u0441\u0442\u044c, \u0447\u0442\u043e \u0431\u044b \u043e\u043d\u0438 \u0432\u044b\u0445\u043e\u0434\u0438\u043b\u0438 \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442 \u043d\u0435 \u0447\u0435\u0440\u0435\u0437 \u0441\u0432\u043e\u0439 GW, \u0430 \u0447\u0435\u0440\u0435\u0437 \u0443\u0434\u0430\u043b\u0451\u043d\u043d\u044b\u0439 GW, \u043f\u0440\u043e\u0439\u0434\u044f \u0447\u0435\u0440\u0435\u0437 VPN. UPD. \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0445\u0435\u043c\u0435 \u0435\u0441\u0442\u044c \u043d\u044e\u0430\u043d\u0441: \u043e\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c, \u0435\u0441\u043b\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u0438\u0435 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,10,12],"tags":[],"class_list":["post-5846","post","type-post","status-publish","format-standard","hentry","category-linux","category-others","category-routers"],"_links":{"self":[{"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=\/wp\/v2\/posts\/5846","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=5846"}],"version-history":[{"count":6,"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=\/wp\/v2\/posts\/5846\/revisions"}],"predecessor-version":[{"id":5984,"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=\/wp\/v2\/posts\/5846\/revisions\/5984"}],"wp:attachment":[{"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5846"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5846"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5846"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}