{"id":266083,"date":"2015-09-21T18:18:02","date_gmt":"2015-09-21T14:18:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=266083"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=266083","title":{"rendered":"Mikrotik. \u041f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 VPN \u0442\u0443\u043d\u043d\u0435\u043b\u0435\u0439 ipsec \u0441 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438 ip \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432"},"content":{"rendered":"<p>       \u0417\u0430\u043d\u0438\u043c\u0430\u043b\u0441\u044f \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u043e\u043c \u0441\u0435\u0442\u0438 \u0438\u0445 VPN \u0442\u0443\u043d\u043d\u0435\u043b\u0435\u0439 \u0441 \u043e\u0431\u043e\u0440\u0443\u0434\u043e\u0432\u0430\u043d\u0438\u044f D link DV 804 HV \u043d\u0430 Mikrotik. \u041f\u0440\u0438 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u043e\u0434\u0435\u043b\u044e\u0441\u044c \u0441 \u0412\u0430\u043c\u0438.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u041d\u043e \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u0432\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>  \u0414\u0430\u043d\u043e 192.168.0.0\/21 \u043c\u043e\u044f \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u0430\u044f \u0441\u0435\u0442\u044c; 192.168.112.0\/24 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u0430\u044f \u0441\u0435\u0442\u044c \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043e\u0444\u0438\u0441\u0430; y.y.y.y \u043c\u043e\u0439 \u0431\u0435\u043b\u044b\u0439 ip, \u0430 x.x.x.x \u0431\u0435\u043b\u044b\u0439 ip \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043e\u0444\u0438\u0441\u0430 (\u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0439).<br \/>  \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u041c\u0438\u043a\u0440\u043e\u0442\u0438\u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0430<br \/>  <code> \/ip ipsec peer  address.0.0.0\/0 port=500 auth-methodre-shared-key secret=&quot;12345678&quot;       generate-policy=no exchange-mode=main send-initial-contact=yes       nat-traversal=no my-id-user-fqdn=&quot;&quot; proposal-checkbey       hash-algorithm=sha1 enc-algorithm=3des dh-group=modp768 lifetime=1d       lifebytes dpd-interval=2m dpd-maximum-failures=5 <\/code><br \/>  \u041f\u043e\u043b\u0438\u0442\u043a\u0438<br \/>  <code> \/ip ipsec policy src-address=192.168.0.0\/21 src-port=any dst-address=192.168.112.0\/24 dst-port=any protocol=all action=encrypt level=require ipsec-protocols=esp tunnel=yes sa-src-address=y.y.y.y sa-dst-address=0.0.0.0 comment=pobug <\/code><\/p>\n<p>  \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u043e\u0434\u044b\u043c\u0430\u0435\u0442\u0441\u044f \u0442\u0443\u043d\u043d\u0435\u043b\u044c \u0441 \u0442\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0438 \u0432\u0438\u0436\u0443 3 installed-sa<br \/>  <code> 0 E  spi src-address=y.y.y.y dst-address=0.0.0.0 auth-algorithm=none        enc-algorithm=none replay state=larval add-lifetimes\/30s    1 E spi=0x2010010 src-address=y.y.y.y dst-address=z.z.z.z       auth-algorithm=sha1 enc-algorithm=3des replay=4 state=mature        auth-key=&quot;sss&quot;        enc-key=&quot;fff&quot;        addtime=jun\/10\/2013 12:42:47 expires-in=7h41m33s add-lifetime=6h24m\/8h        current-bytes=240      2 E  spixDBEA2D2 src-address=z.z.z.z dst-address=y.y.y.y       auth-algorithm=sha1 enc-algorithm=3des replay=4 state=mature        auth-key=&quot;sss&quot;        enc-key=&quot;fff&quot;        addtime=jun\/10\/2013 12:42:47 expires-in=7h41m33s add-lifetime=6h24m\/8h        current-bytes=3376  <\/code><br \/>  \u0418 \u043a\u0430\u043a \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0442\u0440\u0430\u0444\u0438\u043a \u0432 \u043e\u0431\u0440\u0430\u0442\u043d\u0443\u044e \u0441\u0442\u043e\u0440\u043e\u043d\u0443 \u0438\u0434\u0435\u0442 \u0447\u0435\u0440\u0435\u0437 \u0442\u0443\u043d\u043d\u0435\u043b\u044c \u0441 \u043d\u043e\u043c\u0435\u0440\u043e\u043c 0, \u0430 \u043d\u0435 \u0447\u0435\u0440\u0435\u0437 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0430. \u0414\u043b\u044f \u0441\u0435\u0431\u044f \u0440\u0435\u0448\u0438\u043b \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u043f\u0443\u0442\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f ddns \u0437\u0430\u043f\u0438\u0441\u0438 \u0443 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u044b\u0445 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0438\u0445 ip c \u043f\u043e\u0434\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u043e\u0439 \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0443\u044e \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0443. DDNS \u043d\u0430 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u044b\u0445 \u0440\u043e\u0443\u0442\u0435\u0440\u0430\u0445 \u0443 \u043c\u0435\u043d\u044f \u0431\u044b\u043b \u0443\u0436\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d.<\/p>\n<p>  \u0412\u043e\u0442 \u0441\u043a\u0440\u0438\u043f\u0442 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u0441\u0442\u0430\u0435\u0442 \u0438\u0437 \u0434\u0434\u043d\u0441 \u0438\u043c\u0435\u043d\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u0438\u0440\u0430 ip \u0430\u0434\u0440\u0435\u0441 \u0438 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0435\u0433\u043e \u0432 \u043d\u0443\u0436\u043d\u0443\u044e \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0443. \u0422\u0430\u043a \u043a\u0430\u043a \u043f\u043e\u043b\u0438\u0442\u0438\u043a \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u0441\u0435\u0442\u0435\u0439 \u0443\u0436\u0435 \u043d\u0435 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0442\u043e\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0438 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0431\u0443\u0434\u0435\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043d\u0443\u0436\u043d\u0443\u044e.<\/p>\n<p>  <code> :local nname pobug;  :log info  &quot;start $nname&quot;;  :local newip [:resolve &quot;lanlan69.zapto.org&quot;];  :local curip [\/ip ipsec policy get [\/ip ipsec policy find comment=$nname] sa-dst-address];  :log info &quot;newip = $newip&quot;;  :log info &quot;currentip = $curip&quot;;  :if ($newip != $curip) do={  :log info &quot;ip $nname is $curip not $newip&quot;;  \/ip ipsec policy set [\/ip ipsec policy find comment=$nname] sa-dst-address=$newip;  :log info &quot;end $nname&quot;; }<\/code><br \/>  \u0418 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u0432 \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0449\u0438\u043a<br \/>  <code> \/system scheduler add disabled=no interval=7m name=pobug on-event=lan112 policy=\\     read,write,policy,test,sensitivei start-date=jun\/12\/2013   start-time=08:11:19 <\/code><\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0440\u043e\u0443\u0442\u0435\u0440\u043e\u0432 \u0432 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u044b\u0445 \u043e\u0444\u0438\u0441\u0430\u0445 \u041c\u0438\u043a\u0440\u043e\u0442\u0438\u043a\u0438 \u0442\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c\u0438 \u0431\u0443\u0434\u0435\u0442 \u043f\u0430\u0440\u0430 \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432<br \/>  \u0421\u043a\u0440\u0438\u043f\u0442 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0430 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 ip \u0432 \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0443<br \/>  <code> :global lastip :local wanip :local wanif &quot;pppoe-out1&quot;  :if ([ :typeof $lastip ] = nil ) do={ :global lastip &quot;0&quot; }  :local wanip [ \/ip address get [\/ip address find interface=$wanif ] address ]  :if  ([ :typeof $wanip ] = nil ) do={ :log info (&quot;WANIP: no ip address on $wanif  .&quot;) } else= {  :for i from=( [:len $wanip] - 1) to=0 do={  :if ( [:pick $wanip $i] = &quot;\/&quot;) do={  :set wanip [:pick $wanip 0 $i]; :log info (&quot;wan ip now is $wanip&quot;) }  }  :if ($wanip != $lastip) do={ :log info (&quot;Renew ipsec Policy: $wanif -&gt; $wanip&quot;)  #\u041f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0443  ipsec  \/ip ipsec policy set 0  sa-src-address=$wanip  :global lastip $wanip } } <\/code><br \/>  \u041a\u0430\u043a \u043d\u0430 \u043c\u0438\u043a\u0440\u043e\u0442\u0438\u043a\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c No-ip.com \u0441\u0435\u0440\u0432\u0438\u0441 \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u0442\u0443\u0442 <br \/>  <a href=\"http:\/\/wiki.mikrotik.com\/wiki\/Dynamic_DNS_Update_Script_for_No-IP_DNS\">wiki.mikrotik.com\/wiki\/Dynamic_DNS_Update_Script_for_No-IP_DNS<\/a>               <\/p>\n<div class=\"clear\"><\/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\/267355\/\"> http:\/\/habrahabr.ru\/post\/267355\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       \u0417\u0430\u043d\u0438\u043c\u0430\u043b\u0441\u044f \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u043e\u043c \u0441\u0435\u0442\u0438 \u0438\u0445 VPN \u0442\u0443\u043d\u043d\u0435\u043b\u0435\u0439 \u0441 \u043e\u0431\u043e\u0440\u0443\u0434\u043e\u0432\u0430\u043d\u0438\u044f D link DV 804 HV \u043d\u0430 Mikrotik. \u041f\u0440\u0438 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u043e\u0434\u0435\u043b\u044e\u0441\u044c \u0441 \u0412\u0430\u043c\u0438.  <\/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-266083","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/266083","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=266083"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/266083\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=266083"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=266083"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=266083"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}