{"id":266033,"date":"2015-09-21T12:09:02","date_gmt":"2015-09-21T08:09:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=266033"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=266033","title":{"rendered":"Mikrotik RouterOS + PHP \u0441\u043a\u0440\u0438\u043f\u0442 \u043d\u0430 \u0441\u0430\u0439\u0442\u0435. \u0420\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439"},"content":{"rendered":"<p>       \u0412\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0430 ROS 5.x \u0431\u044b\u043b\u0430 \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u0442\u044c \u0442\u0443\u043d\u043d\u0435\u043b\u044c \u043a \u0440\u043e\u0443\u0442\u0435\u0440\u0443 \u0441 \u0431\u0435\u043b\u044b\u043c \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0430\u0434\u0440\u0435\u0441\u043e\u043c. \u0412 ROS 5 \u043c\u044b \u0437\u0430\u0434\u0430\u0432\u0430\u043b\u0438 \u043d\u0435 \u0438\u043c\u044f, \u0430 IP-\u0430\u0434\u0440\u0435\u0441. \u0412\u0430\u0440\u0438\u0430\u043d\u0442\u0430 2: \u0441\u0435\u0440\u0432\u0438\u0441 DDNS, \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0432\u043a\u0440\u0430\u0442\u0446\u0435 \u0438 \u0432\u0442\u043e\u0440\u043e\u0439 \u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0438 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0441\u0441\u043a\u0430\u0437. <br \/>  <a name=\"habracut\"><\/a><br \/>  \u041f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u0438\u0434\u0435\u044f \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0446\u0435\u043d\u0442\u0440 \u043a\u0443\u0434\u0430 \u0431\u044b \u0440\u043e\u0443\u0442\u0435\u0440\u044b \u0440\u0430\u043f\u043e\u0440\u0442\u043e\u0432\u0430\u043b\u0438 \u0441\u0432\u043e\u0438 \u0430\u0434\u0440\u0435\u0441\u0430, \u0438 \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u043b\u0438 \u0430\u0434\u0440\u0435\u0441\u0430 \u0434\u0440\u0443\u0433\u0438\u0445. \u0420\u0435\u0448\u0435\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u043e\u0439\u0442\u0438 \u043f\u0443\u0442\u0435\u043c \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0433\u043e \u0441\u043e\u043f\u0440\u043e\u0442\u0438\u0432\u043b\u0435\u043d\u0438\u044f \u2013 \u0441\u0430\u0439\u0442 \u043d\u0430 \u0420\u041d\u0420. <\/p>\n<p>  \u041d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043e \u043f\u0430\u0440\u0443 \u043d\u0435\u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0432\u0435\u0449\u0435\u0439.<\/p>\n<h4>\u041e\u0433\u043b\u0430\u0448\u0435\u043d\u0438\u0435 \u0441\u0432\u043e\u0435\u0433\u043e \u0430\u0434\u0440\u0435\u0441\u0430<\/h4>\n<p>  \u0420\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043e \u0447\u0435\u0440\u0435\u0437 \u0437\u0430\u043f\u0440\u043e\u0441 \u043a \u0441\u043a\u0440\u0438\u043f\u0442\u0443 \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0435\u043c \u0441\u0432\u043e\u0435\u0433\u043e (\u0440\u043e\u0443\u0442\u0435\u0440\u0430) \u0438\u043c\u0435\u043d\u0438 \u0438 \u043f\u0430\u0440\u043e\u043b\u044f:<\/p>\n<pre><code>:local number &quot;ROUTER_NUMBER&quot;; :local pass &quot;PASSWORD&quot;; \/tool fetch url=&quot;http:\/\/whoami.ho.ua\/adr.php\\?i=$number&p=$pass&quot; mode=http <\/code><\/pre>\n<p>  \u0418\u043c\u044f \u0438 \u043f\u0430\u0440\u043e\u043b\u044c \u043d\u0443\u0436\u043d\u044b \u0447\u0442\u043e \u0431\u044b \u043d\u0438\u043a\u0442\u043e \u043d\u0435 \u043c\u043e\u0433 \u0437\u0430\u043c\u0430\u0441\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u043e\u0434 \u0432\u0430\u0441 \u0438 \u043d\u0435 \u0438\u043d\u0438\u0446\u0438\u0438\u0440\u043e\u0432\u0430\u043b \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0432\u0430\u0448\u0435\u0433\u043e \u0440\u043e\u0443\u0442\u0435\u0440\u0430 \u043a \u0441\u0432\u043e\u0435\u043c\u0443 \u0438\u043b\u0438 \u043d\u0435 \u043c\u043e\u0433 \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0430\u0434\u0440\u0435\u0441 \u0432\u0430\u0448\u0435\u0433\u043e \u0440\u043e\u0443\u0442\u0435\u0440\u0430. \u0427\u0435\u0440\u0435\u0437 \u0443\u0442\u0438\u043b\u0438\u0442\u0443 fetch \u043c\u044b \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u043d\u0443\u0436\u043d\u044b\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u0438 \u0447\u0435\u0440\u0435\u0437 GET \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0438\u043c\u044f \u0438 \u043f\u0430\u0440\u043e\u043b\u044c. \u0421\u043a\u0440\u0438\u043f\u0442 \u0436\u0435 \u0447\u0435\u0440\u0435\u0437 $_SERVER[&#8216;REMOTE_ADDR&#8217;] \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0432\u043d\u0435\u0448\u043d\u0438\u0439 \u0430\u0434\u0440\u0435\u0441 \u0440\u043e\u0443\u0442\u0435\u0440\u0430 \u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0435\u0433\u043e \u0432 \u0411\u0414.<\/p>\n<h4>\u0421\u0447\u0438\u0442\u044b\u0432\u0430\u043d\u0438\u0435 \u0447\u0443\u0436\u043e\u0433\u043e \u0430\u0434\u0440\u0435\u0441\u0430<\/h4>\n<p>  \u041e\u043f\u044f\u0442\u044c \u0436\u0435 \u0447\u0435\u0440\u0435\u0437 \u0442\u0443 \u0436\u0435 \u0443\u0442\u0438\u043b\u0438\u0442\u0443 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u0432\u0435\u0431-\u0441\u043a\u0440\u0438\u043f\u0442:<\/p>\n<pre><code>:local number &quot;ROUTER_NUMBER&quot;; :local pass &quot;PASSWORD&quot;; \/tool fetch url=&quot;http:\/\/whoami.ho.ua\/getadr.php\\?i=$number&p=$pass&quot; mode=http dst-path=&quot;adr.txt&quot;  :global routeradr [\/file get adr.txt contents] <\/code><\/pre>\n<p>  dst-path=\u00abadr.txt\u00bb \u2013 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u0432 \u0444\u0430\u0439\u043b. \u041d\u0430 \u0441\u0430\u043c\u043e\u0439 \u0432\u0435\u0431-\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u0443 \u043d\u0430\u0441 \u0441\u0443\u0433\u0443\u0431\u043e \u0442\u0435\u043a\u0441\u0442 \u0441 \u0430\u0434\u0440\u0435\u0441\u043e\u043c \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u0440\u043e\u0443\u0442\u0435\u0440\u0430:<\/p>\n<p>  $query=\u00abSELECT address FROM table_routers WHERE ((id=&#8217;$_GET[i]&#8217;) AND (password=&#8217;$_GET[p]&#8217;))\u00bb;<br \/>  $adr=mysql_query($query) or die (mysql_error());<br \/>  $router=mysql_fetch_assoc($adr);<br \/>  echo $router[address];<\/p>\n<p>  :global routeradr [\/file get adr.txt contents] \u2013 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430. \u041f\u043e\u0442\u043e\u043c \u044d\u0442\u0443 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438 \u043c\u0435\u043d\u044f\u0442\u044c \u043f\u043e \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u0438 \u0438 \u0436\u0435\u043b\u0430\u043d\u0438\u044e.<\/p>\n<h4>\u0421\u0447\u0438\u0442\u044b\u0432\u0430\u043d\u0438\u0435 \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u0438\u0437 \u0411\u0414<\/h4>\n<p>  <\/p>\n<pre><code>:local number &quot;ROUTER_NUMBER&quot;; :local pass &quot;PASSWORD&quot;; \/tool fetch url=&quot;http:\/\/whoami.ho.ua\/getscript.php\\?i=$number&p=$pass&quot; mode=http dst-path=&quot;script.rsc&quot;  import file-name=script.rsc \/file remove script.rsc <\/code><\/pre>\n<p>  \u0412\u0441\u0451 \u0442\u0430\u043a \u0436\u0435 \u043a\u0430\u043a \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c \u0441\u043a\u0440\u0438\u043f\u0442\u0435, \u043d\u043e \u0444\u0430\u0439\u043b \u043c\u044b \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0432 \u043a\u043e\u043d\u0444\u0438\u0433 \u0440\u043e\u0443\u0442\u0435\u0440\u0430, \u0430 \u043f\u043e\u0442\u043e\u043c \u0443\u0434\u0430\u043b\u044f\u0435\u043c \u044d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b.<\/p>\n<p>  \u0414\u043b\u044f \u0447\u0435\u0433\u043e \u044d\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e? \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0412\u044b \u043f\u043e \u043d\u0435\u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043e\u0431\u0440\u0435\u0437\u0430\u043b\u0438 \u0441\u0435\u0431\u0435 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0440\u043e\u0443\u0442\u0435\u0440\u0443 \u0432 \u0444\u0430\u0435\u0440\u0432\u043e\u043b\u0435. \u0422\u043e\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u0430 \u0441\u0430\u0439\u0442\u0435 \u0441\u043a\u0440\u0438\u043f\u0442 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0440\u043e\u0443\u0442\u0435\u0440\u0430 \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0435 \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0444\u0430\u0435\u0440\u0432\u043e\u043b\u0430. \u0420\u043e\u0443\u0442\u0435\u0440 \u0441\u043b\u0435\u0434\u0443\u044f \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u0438\u044e \u043a\u043e\u043d\u0435\u043a\u0442\u0438\u0442\u0441\u044f \u043a \u0441\u0430\u0439\u0442\u0443, \u0442\u0430\u043c \u0420\u041d\u0420 \u0441\u043c\u043e\u0442\u0440\u0438\u0442 \u0435\u0441\u0442\u044c \u043b\u0438 \u0432 \u0411\u0414 \u043d\u0435\u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u043a\u0440\u0438\u043f\u0442\u044b \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0440\u043e\u0443\u0442\u0435\u0440\u0430:<\/p>\n<pre><code class=\"php\">SELECT id FROM table_routers WHERE ((id='$_GET[i]') AND (password='$_GET[p]')) $adr=mysql_query($query) or die (mysql_error()); $router=mysql_fetch_assoc($adr); $query=&quot;SELECT script, id FROM table_scripts WHERE ((router='$router[id]') AND (executed='N')) ORDER BY id ASC LIMIT 1&quot;; <\/code><\/pre>\n<p>  \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043c\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0432\u0435\u0440\u043d\u043e \u043b\u0438 \u0437\u0430\u0434\u0430\u043d\u044b \u043f\u0430\u0440\u043e\u043b\u044c \u0438 \u043d\u043e\u043c\u0435\u0440 \u0440\u043e\u0443\u0442\u0435\u0440\u0430 (\u0447\u0442\u043e\u0431\u044b \u043d\u0438\u043a\u0442\u043e \u0434\u0440\u0443\u0433\u043e\u0439 \u043d\u0435 \u043c\u043e\u0433 \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0432\u0430\u0448 \u0441\u043a\u0440\u0438\u043f\u0442, \u043c\u043e\u0436\u0435\u0442 \u0432\u044b \u0442\u0430\u043c \u043f\u0430\u0440\u043e\u043b\u0438 \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0435 \u043c\u0435\u043d\u044f\u0435\u0442\u0435), \u0430 \u043f\u043e\u0442\u043e\u043c \u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u043a\u043e\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 \u0441\u0442\u043e\u0438\u0442 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u043d\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0440\u043e\u0443\u0442\u0435\u0440\u0430.<\/p>\n<p>  \u042d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u043d\u0435 \u0440\u0435\u0448\u0430\u0435\u0442 \u0412\u041e\u0417\u041d\u0418\u041a\u0428\u0418\u0415 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b, \u043e\u043d \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0438\u0445 \u043f\u0440\u0435\u0434\u043e\u0442\u0432\u0440\u0430\u0442\u0438\u0442\u044c. \u0422\u043e \u0435\u0441\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u00ab\u043f\u043e\u0434\u0441\u0442\u0435\u043b\u0438\u0442\u044c \u0441\u043e\u043b\u043e\u043c\u043a\u0438\u00bb \u0438 \u0437\u0430\u0431\u0438\u0442\u044c \u0432 scheduler \u0440\u0430\u0437 \u0432 \u0425 \u043c\u0438\u043d\u0443\u0442\/\u0447\u0430\u0441\u043e\u0432 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u0440\u043e\u0443\u0442\u0435\u0440\u043e\u043c \u043d\u0430\u043b\u0438\u0447\u0438\u044f \u043d\u043e\u0432\u044b\u0445 \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432 \u0434\u043b\u044f \u043d\u0435\u0433\u043e. <\/p>\n<p>  \u0422\u0430\u043a \u0436\u0435 \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0445\u043e\u0440\u043e\u0448, \u043a\u043e\u0433\u0434\u0430 \u0440\u043e\u0443\u0442\u0435\u0440 \u0438\u043c\u0435\u0435\u0442 \u0441\u0435\u0440\u0443\u044e \u0430\u0439\u043f\u0438\u0448\u043a\u0443, \u0430 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043d\u0435\u043c\u0443 \u043d\u0430\u0434\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u0437 \u0432\u043d\u0435. \u0417\u0430\u0431\u0438\u0432\u0430\u0435\u043c \u0441\u043a\u0440\u0438\u043f\u0442 \u043f\u043e\u0434\u043d\u044f\u0442\u0438\u044f \u0412\u041f\u041d-\u0442\u0443\u043d\u043d\u0435\u043b\u044f \u043a \u0441\u0432\u043e\u0435\u0439 \u0431\u0435\u043b\u043e\u0439 \u0430\u0439\u043f\u0438\u0448\u043a\u0435 \u0438 \u0447\u0435\u0440\u0435\u0437 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0438\u043c\u0435\u0435\u043c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0443 \u0434\u0430\u0436\u0435 \u0437\u0430 10-\u044e \u041d\u0410\u0422\u0430\u043c\u0438.<\/p>\n<p>  \u0412\u043e\u0442 \u0442\u0430\u043a\u0430\u044f \u0432\u043e\u0442 \u043a\u043e\u0440\u043e\u0442\u0435\u043d\u044c\u043a\u0430\u044f \u0438\u0441\u0442\u043e\u0440\u0438\u044f. \u0411\u0443\u0434\u0443 \u0440\u0430\u0437 \u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u044f\u043c \u0438 \u0438\u0434\u0435\u044f\u043c \u0447\u0442\u043e \u0435\u0449\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u043a\u0440\u0443\u0442\u0438\u0442\u044c \u043a \u0442\u0430\u043a\u043e\u043c\u0443 \u0441\u0435\u0440\u0432\u0438\u0441\u0443. \u0412 \u043f\u043b\u0430\u043d\u0430\u0445 \u0435\u0449\u0435 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430 \u2013 \u0447\u0442\u043e \u0431\u044b \u0440\u043e\u0443\u0442\u0435\u0440 \u0441\u043b\u0438\u0432\u0430\u043b \u0432 \u0411\u0414 \u043f\u0430\u0440\u0443 \u0441\u0432\u043e\u0438\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u0443, \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 \u0438 \u043f\u0440\u043e\u0447\u0438\u0435. <\/p>\n<p>  \u041a\u0430\u043a \u0431\u043e\u043d\u0443\u0441 \u043a\u0443\u0441\u043e\u043a \u0433\u043e\u0442\u043e\u0432\u044b\u0445 \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432, \u043e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u044f \u043f\u0438\u0441\u0430\u043b \u0432 \u043d\u0430\u0447\u0430\u043b\u0435, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f ip \u0441 \u0438\u043c\u0435\u043d\u0438 \u0445\u043e\u0441\u0442\u0430 \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0435\u0433\u043e \u0432 \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0443 IPsec.<\/p>\n<p>  \u041f\u043b\u044e\u0441 \u0432 \u0442\u043e\u043c \u0447\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432 \u0441\u0432\u044f\u0437\u043a\u0435 Mikrotik + \u043c\u044b\u043b\u044c\u043d\u0438\u0446\u044b \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442 ddns \u0438 ipsec (Dlink 804 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440). \u0421\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:<\/p>\n<pre><code class=\"php\">:local nname RHost1; :log info  &quot;start $nname&quot;; :local newip [:resolve &quot;rmotehost1.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><\/pre>\n<p>  \u0418 \u0441\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 ipsec:<\/p>\n<pre><code class=\"php\">: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><\/pre>\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\/267293\/\"> http:\/\/habrahabr.ru\/post\/267293\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       \u0412\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0430 ROS 5.x \u0431\u044b\u043b\u0430 \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u0442\u044c \u0442\u0443\u043d\u043d\u0435\u043b\u044c \u043a \u0440\u043e\u0443\u0442\u0435\u0440\u0443 \u0441 \u0431\u0435\u043b\u044b\u043c \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0430\u0434\u0440\u0435\u0441\u043e\u043c. \u0412 ROS 5 \u043c\u044b \u0437\u0430\u0434\u0430\u0432\u0430\u043b\u0438 \u043d\u0435 \u0438\u043c\u044f, \u0430 IP-\u0430\u0434\u0440\u0435\u0441. \u0412\u0430\u0440\u0438\u0430\u043d\u0442\u0430 2: \u0441\u0435\u0440\u0432\u0438\u0441 DDNS, \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0432\u043a\u0440\u0430\u0442\u0446\u0435 \u0438 \u0432\u0442\u043e\u0440\u043e\u0439 \u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0438 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0441\u0441\u043a\u0430\u0437.   <\/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-266033","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/266033","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=266033"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/266033\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=266033"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=266033"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=266033"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}