{"id":276474,"date":"2016-03-18T21:02:02","date_gmt":"2016-03-18T18:02:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=276474"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=276474","title":{"rendered":"\u0423\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f 2-\u0445 \u043a\u0430\u043d\u0430\u043b\u043e\u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0430 Mikrotik"},"content":{"rendered":"<p>       \u041e\u043a\u043e\u043b\u043e 2,5 \u043b\u0435\u0442 \u043d\u0430\u0437\u0430\u0434 \u043f\u0438\u0441\u0430\u043b <a href=\"https:\/\/habrahabr.ru\/post\/231565\/\">\u0441\u0442\u0430\u0442\u044c\u044e<\/a> \u043d\u0430 \u0442\u0435\u043c\u0443 <a href=\"https:\/\/habrahabr.ru\/post\/231565\/\">\u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a\u0430\u043d\u0430\u043b\u0430 \u0418\u043d\u0442\u0435\u0440\u043d\u0435\u0442 \u043d\u0430 \u0440\u0435\u0437\u0435\u0440\u0432\u043d\u044b\u0439<\/a>. \u0421\u043a\u0440\u0438\u043f\u0442, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u0438 \u043f\u043e \u0441\u0435\u0439 \u0434\u0435\u043d\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u00ab\u043d\u0430 \u043e\u0442\u043b\u0438\u0447\u043d\u043e\u00bb, \u043d\u043e \u0435\u0433\u043e \u0432\u043d\u0435\u0448\u043d\u0438\u0439 \u0432\u0438\u0434 \u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u044e\u0430\u043d\u0441\u044b\u2026<\/p>\n<p>  \u0418\u0442\u0430\u043a, \u0432\u0441\u0442\u0430\u043b\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u0441\u043a\u0440\u0438\u043f\u0442, \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0443\u0441\u0442\u0440\u0430\u043d\u0438\u0432 \u043f\u043e\u0431\u043e\u0447\u043d\u044b\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u044b. \u0427\u0442\u043e \u0436, \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/c2d\/db7\/1f2\/c2ddb71f2dc488bba7129684dc15c522.png\" alt=\"image\"\/><br \/>  <a name=\"habracut\"><\/a><br \/>  \u0412 \u043d\u0430\u0448\u0435\u043c \u0440\u0430\u0441\u043f\u043e\u0440\u044f\u0436\u0435\u043d\u0438\u0438 <b>Mikrotik RB850Gx2<\/b>, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043a\u0440\u0438\u043f\u0442 (\u0435\u0433\u043e \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d\u0430 \u043d\u0430 \u043c\u043e\u0434\u0435\u043b\u044f\u0445 <b>RB450G<\/b> \u0438 <b>RB951G-2HnD<\/b>).<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043d\u043e\u0432\u044b\u0439 \u0441\u043a\u0440\u0438\u043f\u0442<\/b><\/p>\n<div class=\"spoiler_text\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/8b7\/e2f\/1dc\/8b7e2f1dc38cb26ba8664b1d8b1fbb38.png\" alt=\"image\"\/><\/p>\n<p>  \u041f\u0440\u0438\u0441\u0432\u043e\u0439\u0442\u0435 \u0441\u043a\u0440\u0438\u043f\u0442\u0443 \u0438\u043c\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <b>script-check-inet<\/b>  <\/div>\n<\/div>\n<p>  \u0427\u0442\u043e \u0436\u0435 \u0431\u0443\u0434\u0435\u043c \u0432 \u043d\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c?<\/p>\n<p>  \u0418\u0442\u0430\u043a, \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435:<\/p>\n<pre><code class=\"bash\">:local firstInterface &quot;pppoe-rostelecom&quot;; :local secondInterface &quot;eth2-MTS&quot;; :local pingTo &quot;8.8.8.8&quot;; :local prefix &quot;&gt;&gt;&gt; &quot;; <\/code><\/pre>\n<p>  \u0433\u0434\u0435:<br \/>  <b>$firstInterface<\/b> \u2014 \u0438\u043c\u044f \u043d\u0430\u0448\u0435\u0433\u043e PPPoE-\u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043b\u0438\u043d\u0438\u0438 \u0441\u0432\u044f\u0437\u0438.<br \/>  <b>$secondInterface<\/b> \u2014 \u0438\u043c\u044f \u043d\u0430\u0448\u0435\u0433\u043e Ethernet-\u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0435\u0440\u0432\u043d\u043e\u0439 \u043b\u0438\u043d\u0438\u0438.<br \/>  <b>$pingTo<\/b> \u2014 IP-\u0430\u0434\u0440\u0435\u0441 \u0440\u0435\u0441\u0443\u0440\u0441\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u043c \u00ab\u043f\u0438\u043d\u0430\u0442\u044c\u00bb.<br \/>  <b>$prefix<\/b> \u2014 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u043b\u043e\u0433\u043e\u0432, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u043c \u0431\u044b\u043b\u043e \u0432\u0438\u0434\u0435\u043d \u043d\u0443\u0436\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442.<\/p>\n<p>  \u041f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0434\u0438\u0441\u0442\u0430\u043d\u0446\u0438\u0438 \u0440\u043e\u0443\u0442\u0430 \u0431\u0435\u0437 \u043e\u0447\u0438\u0441\u0442\u043a\u0438 ARP \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0431\u0443\u0434\u0443\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0438 \u0438 \u0442\u0430\u043a \u043a\u0430\u043a \u0432 \u043d\u0430\u0448\u0435\u043c \u043a\u043e\u0434\u0435 \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0441\u0442, \u043e\u0442\u043a\u0443\u0434\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u043e\u0447\u0438\u0441\u0442\u043a\u0443 \u0434\u0430\u043d\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u043e\u0444\u043e\u0440\u043c\u0438\u043c \u043a\u043e\u0434 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e:<\/p>\n<pre><code class=\"bash\">:local clearArp do={     :local dumplist [\/ip arp find]     :foreach i in=$dumplist do={         \/ip arp remove $i     }     :log info ($prefix . &quot;ARP cleaned&quot;); } <\/code><\/pre>\n<p>  \u0414\u0430\u043b\u0435\u0435, \u0434\u043b\u044f \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u044f \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u0434\u0430, \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e `\/ip route {}`, \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0435\u043b\u044c\u0437\u044f \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u0435 \u043a\u043e\u0440\u043d\u0435\u0432\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, `\/interface pppoe-client&#8230;`. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0435\u0449\u0435 \u043e\u0434\u043d\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0443\u044e \u0437\u0430 \u043f\u0435\u0440\u0435\u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 PPPoE-\u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"bash\"># Function to reconnect PPPoE connection :local reconnectPPPoE do={     \/interface pppoe-client set $nameInterface disable=yes;     :delay 1s;     \/interface pppoe-client set $nameInterface disable=no; } <\/code><\/pre>\n<p>  \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043b\u0438\u043d\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u00ab\u0420\u043e\u0441\u0442\u0435\u043b\u0435\u043a\u043e\u043c\u00bb, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u043c\u0435\u0435\u0442 \u00ab\u0444\u0438\u0448\u043a\u0443\u00bb \u0432 \u043f\u0435\u0440\u0438\u043e\u0434\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u0418\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0430 \u043f\u0440\u0438 \u0442\u043e\u043c, \u0447\u0442\u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u044f\u044f \u0438\u0445 \u043b\u0438\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0431\u0435\u0437 \u0441\u0431\u043e\u0435\u0432. \u042d\u0442\u043e \u0434\u043e\u0441\u0442\u0438\u0433\u043b\u0438 \u043e\u043f\u044b\u0442\u043d\u044b\u043c \u043f\u0443\u0442\u0435\u043c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f SIP-\u0441\u0435\u0440\u0432\u0435\u0440 \u043e\u0442 \u0420\u043e\u0441\u0442\u0435\u043b\u0435\u043a\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0442\u0430\u043a \u043d\u0438 \u0440\u0430\u0437\u0443 \u0438 \u043d\u0435 \u0443\u043f\u0430\u043b.<br \/>  \u0412 \u043e\u0431\u0449\u0435\u043c, \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u0435\u0440\u0435\u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f. \u0418\u0434\u0435\u043c \u0434\u0430\u043b\u044c\u0448\u0435.<\/p>\n<p>  \u041f\u0435\u0440\u0435\u0434 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u044c\u044e \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u00ab\u0437\u0430\u0449\u0438\u0442\u0443 \u043e\u0442 \u0434\u0443\u0440\u0430\u043a\u043e\u0432\u00bb. \u0412\u0434\u0440\u0443\u0433 \u0443 \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d, \u0438\u043b\u0438 \u0434\u0438\u0441\u0442\u0430\u043d\u0446\u0438\u044f \u043d\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u0430\u044f\u2026<\/p>\n<p>  \u0418\u0442\u0430\u043a, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0430\u043a\u0442\u0438\u0432\u043d\u044b \u043b\u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b \u0438 \u0435\u0441\u043b\u0438 \u043d\u0435\u0442 \u2014 \u0430\u043a\u0442\u0438\u0432\u0438\u0440\u0443\u0435\u043c \u0438\u0445:<\/p>\n<pre><code class=\"bash\"># Check FIRST interface \/interface pppoe-client {     :if ( [get $firstInterface disable] = true) do={         set $firstInterface disable=no;         :delay 5s;     } }  # Check SECOND interface \/interface ethernet {     :if ( [get $secondInterface disable] = true) do={         set $secondInterface disable=no;     } } <\/code><\/pre>\n<p>  \u041d\u043e \u044d\u0442\u043e \u0435\u0449\u0435 \u043d\u0435 \u0432\u0441\u0435! \u0414\u0430\u043b\u044c\u0448\u0435 \u043c\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u0434\u0438\u0441\u0442\u0430\u043d\u0446\u0438\u0438 \u0440\u043e\u0443\u0442\u043e\u0432:<\/p>\n<pre><code class=\"bash\">\/ip route {     # Set objects to variables     :set firstInterface [find gateway=$firstInterface];     :set secondInterface [find gateway=$secondInterface];      # Check routes     :if ( [get $firstInterface distance] != 2 ) do={         set $firstInterface distance=2;         :log info ($prefix . &quot;Distance for &quot; . [get $firstInterface gateway] . &quot; corrected&quot;);     }      :if ( [get $secondInterface distance] != 1 && [get $secondInterface distance] != 3) do={         set $secondInterface distance=3;         :log info ($prefix . &quot;Distance for &quot; . [get $secondInterface gateway] . &quot; corrected&quot;);     }  # ... body ... } <\/code><\/pre>\n<p>  \u0422\u0430\u043a \u043a\u0430\u043a \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432 `\/ip route`, \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u00ab\u0437\u0430\u0449\u0438\u0442\u0443 \u043e\u0442 \u0434\u0443\u0440\u0430\u043a\u043e\u0432\u00bb \u0432 \u0435\u0435 \u043d\u0430\u0447\u0430\u043b\u043e.<br \/>  \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c 2 \u0440\u043e\u0443\u0442\u0430 \u0441 `dst. address` \u0440\u0430\u0432\u043d\u044b\u043c `0.0.0.0\/0`, \u0448\u043b\u044e\u0437\u043e\u043c \u043f\u043e \u0438\u043c\u0435\u043d\u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u0438 \u00ab\u043a\u0430\u043a\u043e\u0439-\u0442\u043e\u00bb \u0434\u0438\u0441\u0442\u0430\u043d\u0446\u0438\u0435\u0439.<\/p>\n<p>  <b>\u0427\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0441\u043a\u0440\u0438\u043f\u0442:<\/b><\/p>\n<p>  \u0412\u043d\u0430\u0447\u0430\u043b\u0435 \u043e\u043d \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u0440\u043e\u0443\u0442\u043e\u0432, \u0447\u0442\u043e\u0431\u044b \u043c\u0435\u043d\u044c\u0448\u0435 \u043a\u043e\u0434\u0430 \u043f\u0438\u0441\u0430\u0442\u044c.<br \/>  \u0417\u0430\u0442\u0435\u043c, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0434\u0438\u0441\u0442\u0430\u043d\u0446\u0438\u044e \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e \u0440\u043e\u0443\u0442\u0430 (\u0420\u043e\u0441\u0442\u0435\u043b\u0435\u043a\u043e\u043c). \u041c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u00ab2\u00bb.<\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0434\u0438\u0441\u0442\u0430\u043d\u0446\u0438\u044e \u0437\u0430\u043f\u0430\u0441\u043d\u043e\u0433\u043e \u0440\u043e\u0443\u0442\u0430 \u2014 \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u0438\u0441\u0442\u0430\u043d\u0446\u0438\u0439 \u043b\u0438\u0431\u043e \u00ab1\u00bb, \u043b\u0438\u0431\u043e \u00ab3\u00bb. \u042d\u0442\u043e \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u0437\u0430\u0434\u0430\u0447\u0443 \u0441 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435\u043c \u0434\u0438\u0441\u0442\u0430\u043d\u0446\u0438\u0439, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0434\u0438\u0441\u0442\u0430\u043d\u0446\u0438\u044e \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e \u043a\u0430\u043d\u0430\u043b\u0430.<\/p>\n<p>  \u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043b\u0438 \u0434\u0438\u0441\u0442\u0430\u043d\u0446\u0438\u0438 \u0438 \u0432\u044b\u0441\u0442\u0430\u0432\u0438\u043b\u0438 \u043d\u0443\u0436\u043d\u044b\u0435. \u0427\u0442\u043e \u0434\u0430\u043b\u044c\u0448\u0435?<\/p>\n<h3>\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043f\u0438\u043d\u0433\u043e\u043c<\/h3>\n<p>  \u0422\u0430\u043a \u043a\u0430\u043a \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u0430\u043a\u0442\u0438\u0432\u0435\u043d, \u0442\u043e \u0432 \u043f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u043c \u0443\u0441\u043b\u043e\u0432\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043f\u0438\u043d\u0433\u0430, \u043d\u043e \u0438 \u0441\u0442\u0430\u0442\u0443\u0441\u0430 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430:<\/p>\n<pre><code class=\"bash\">\/ip route {     # ...     :if ( [get $firstInterface active] = false or [\/ping $pingTo interface=[get $firstInterface gateway] count=5] = 0) do={         # ...     }     # ... } <\/code><\/pre>\n<p>  \u0422\u043e \u0435\u0441\u0442\u044c, \u0435\u0441\u043b\u0438 \u0443 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <u>\u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d<\/u> \u0438\u043b\u0438 \u043d\u0438 \u043e\u0434\u0438\u043d \u043f\u0430\u043a\u0435\u0442 \u043f\u0438\u043d\u0433\u0430 <u>\u043d\u0435 \u043f\u0440\u043e\u0448\u0435\u043b<\/u> \u2014 \u0441\u0447\u0438\u0442\u0430\u0435\u043c, \u0447\u0442\u043e \u0418\u043d\u0442\u0435\u0440\u043d\u0435\u0442 \u043e\u0442\u0441\u043e\u0445:<\/p>\n<pre><code class=\"bash\">    :if ( [get $firstInterface active] = false or [\/ping $pingTo interface=[get $firstInterface gateway] count=5] = 0) do={         :log info ($prefix . &quot;FIRST NO INTERNET!!!&quot;);          # Change distance         :if ( [get $secondInterface distance] != 1 ) do={             set $secondInterface distance=1;             :log info ($prefix . &quot;Distance for &quot; . [get $secondInterface gateway] . &quot; changed&quot;);             $clearArp;         }          $reconnectPPPoE nameInterface=[get $firstInterface gateway];      } <\/code><\/pre>\n<p>  \u0412\u043d\u0430\u0447\u0430\u043b\u0435 \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u043b\u043e\u0433, \u0447\u0442\u043e \u0418\u043d\u0435\u0442\u0430 \u043d\u0435\u0442, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c \u0434\u0438\u0441\u0442\u0430\u043d\u0446\u0438\u044e \u0440\u0435\u0437\u0435\u0440\u0432\u043d\u043e\u0433\u043e \u043a\u0430\u043d\u0430\u043b\u0430 \u0438 \u0447\u0438\u0441\u0442\u0438\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 ARP, \u0432\u044b\u0437\u0432\u0430\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e.<br \/>  \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u0435\u0440\u0435\u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f PPPoE-\u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f. \u0422\u0430\u043a \u043a\u0430\u043a \u0438\u043c\u044f \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u043c\u044b \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0432 \u043e\u0434\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435 (\u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u043b\u043e\u0434\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435), \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0430 \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u043f\u0440\u0438\u043d\u044f\u0442\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0435\u0439 \u0438\u043c\u044f \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 `nameInterface` \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0438\u043c\u044f \u043d\u0443\u0436\u043d\u043e\u0433\u043e \u043d\u0430\u043c PPPoE-\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430.<\/p>\n<h3>\u0418\u043d\u0442\u0435\u0440\u043d\u0435\u0442 \u00ab\u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f\u00bb, \u0438\u043b\u0438 \u043a\u0430\u043a \u0432\u0441\u0435 \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u043d\u0430\u0437\u0430\u0434<\/h3>\n<p>  \u041d\u0430 \u044d\u0442\u043e\u043c-\u0442\u043e \u044d\u0442\u0430\u043f\u0435 \u043c\u044b \u0438 \u0437\u0430\u044e\u0437\u0430\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e `if else`:<\/p>\n<pre><code class=\"bash\">\/ip route {     # ...     :if ( [get $firstInterface active] = false or [\/ping $pingTo interface=[get $firstInterface gateway] count=5] = 0) do={         # ...     } else={         :log info ($prefix . &quot;FIRST INTERNET CONNECTED&quot;);          # Change distance         :if ( [get $secondInterface distance] != 3 ) do={             set $secondInterface distance=3;             :log info ($prefix . &quot;Distance for &quot; . [get $secondInterface gateway] . &quot; changed&quot;);             $clearArp;         }     }     # ... } <\/code><\/pre>\n<p>  \u041a\u0430\u043a \u0438 \u0432 \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0441\u0442\u0438 \u0441\u0435\u0442\u0438, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c \u0434\u0438\u0441\u0442\u0430\u043d\u0446\u0438\u044e \u0440\u0435\u0437\u0435\u0440\u0432\u043d\u043e\u0433\u043e \u043a\u0430\u043d\u0430\u043b\u0430 \u0438 \u0447\u0438\u0441\u0442\u0438\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 ARP.<\/p>\n<h3>\u041a\u0430\u043a \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c<\/h3>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u0448\u0435\u0434\u0443\u043b\u0435\u0440\u0435<\/b><\/p>\n<div class=\"spoiler_text\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/bbe\/a7e\/d01\/bbea7ed0136d9b9d7c37564830e15927.png\" alt=\"image\"\/><\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/c19\/9be\/766\/c199be7664f1b0b96eee66e5918f01d0.png\" alt=\"image\"\/>  <\/div>\n<\/div>\n<p>  \u0412 \u043f\u043e\u043b\u0435 `Name` \u0432\u0432\u0435\u0434\u0438\u0442\u0435 \u0438\u043c\u044f \u0437\u0430\u043f\u0438\u0441\u0438, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0437\u0430\u043f\u0443\u0442\u0430\u0442\u044c\u0441\u044f.<br \/>  \u041f\u043e\u043b\u0435 `Start Time` \u044f \u0432\u044b\u0441\u0442\u0430\u0432\u0438\u043b `00:00:00` \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0440\u043e\u0432\u043d\u043e \u0432 \u043f\u043e\u043b\u043d\u043e\u0447\u044c.<br \/>  \u0418\u043d\u0442\u0435\u0440\u0432\u0430\u043b \u2014 30 \u0441\u0435\u043a\u0443\u043d\u0434<br \/>  \u0412 \u043f\u043e\u043b\u0435 `On Event` \u0432\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0438\u043c\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u2014 `script-check-inet`<br \/>  \u0418 \u0436\u043c\u0435\u043c \u00ab\u041e\u041a\u00bb.<\/p>\n<p>  \u0412\u043e\u0442, \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0438 \u0432\u0441\u0435!<\/p>\n<p>  \u041d\u0438\u0436\u0435 \u043f\u043e\u0434 \u0441\u043f\u043e\u0439\u043b\u0435\u0440\u043e\u043c \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d \u043f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u0441\u043a\u0440\u0438\u043f\u0442\u0430.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u0441\u043a\u0440\u0438\u043f\u0442\u0430<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\"># Set local variables :local firstInterface &quot;pppoe-rostelecom&quot;; :local secondInterface &quot;eth2-MTS&quot;; :local pingTo &quot;8.8.8.8&quot;; :local prefix &quot;&gt;&gt;&gt; &quot;;  # Function to cleaning ARP table :local clearArp do={     :local dumplist [\/ip arp find]     :foreach i in=$dumplist do={         \/ip arp remove $i     }     :log info ($prefix . &quot;ARP cleaned&quot;); }  # Function to reconnect PPPoE connection :local reconnectPPPoE do={     \/interface pppoe-client set $nameInterface disable=yes;     :delay 1s;     \/interface pppoe-client set $nameInterface disable=no; }  :log info ($prefix . &quot;START PING to $pingTo&quot;);  # Check FIRST interface \/interface pppoe-client {     :if ( [get $firstInterface disable] = true) do={         set $firstInterface disable=no;         :delay 5s;     } }  # Check SECOND interface \/interface ethernet {     :if ( [get $secondInterface disable] = true) do={         set $secondInterface disable=no;     } }  \/ip route {     # Set objects to variables     :set firstInterface [find gateway=$firstInterface];     :set secondInterface [find gateway=$secondInterface];      # Check routes     :if ( [get $firstInterface distance] != 2 ) do={         set $firstInterface distance=2;         :log info ($prefix . &quot;Distance for &quot; . [get $firstInterface gateway] . &quot; corrected&quot;);     }      :if ( [get $secondInterface distance] != 1 && [get $secondInterface distance] != 3) do={         set $secondInterface distance=3;         :log info ($prefix . &quot;Distance for &quot; . [get $secondInterface gateway] . &quot; corrected&quot;);     }       # Check Internet     :if ( [get $firstInterface active] = false or [\/ping $pingTo interface=[get $firstInterface gateway] count=5] = 0) do={         :log info ($prefix . &quot;FIRST NO INTERNET!!!&quot;);          # Change distance         :if ( [get $secondInterface distance] != 1 ) do={             set $secondInterface distance=1;             :log info ($prefix . &quot;Distance for &quot; . [get $secondInterface gateway] . &quot; changed&quot;);             $clearArp;         }          $reconnectPPPoE nameInterface=[get $firstInterface gateway];      } else={         :log info ($prefix . &quot;FIRST INTERNET CONNECTED&quot;);          # Change distance         :if ( [get $secondInterface distance] != 3 ) do={             set $secondInterface distance=3;             :log info ($prefix . &quot;Distance for &quot; . [get $secondInterface gateway] . &quot; changed&quot;);             $clearArp;         }     } }  :log info ($prefix . &quot;END PING to $pingTo&quot;); <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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=\"https:\/\/habrahabr.ru\/post\/279567\/\"> https:\/\/habrahabr.ru\/post\/279567\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       \u041e\u043a\u043e\u043b\u043e 2,5 \u043b\u0435\u0442 \u043d\u0430\u0437\u0430\u0434 \u043f\u0438\u0441\u0430\u043b <a href=\"https:\/\/habrahabr.ru\/post\/231565\/\">\u0441\u0442\u0430\u0442\u044c\u044e<\/a> \u043d\u0430 \u0442\u0435\u043c\u0443 <a href=\"https:\/\/habrahabr.ru\/post\/231565\/\">\u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a\u0430\u043d\u0430\u043b\u0430 \u0418\u043d\u0442\u0435\u0440\u043d\u0435\u0442 \u043d\u0430 \u0440\u0435\u0437\u0435\u0440\u0432\u043d\u044b\u0439<\/a>. \u0421\u043a\u0440\u0438\u043f\u0442, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u0438 \u043f\u043e \u0441\u0435\u0439 \u0434\u0435\u043d\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u00ab\u043d\u0430 \u043e\u0442\u043b\u0438\u0447\u043d\u043e\u00bb, \u043d\u043e \u0435\u0433\u043e \u0432\u043d\u0435\u0448\u043d\u0438\u0439 \u0432\u0438\u0434 \u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u044e\u0430\u043d\u0441\u044b\u2026<\/p>\n<p>  \u0418\u0442\u0430\u043a, \u0432\u0441\u0442\u0430\u043b\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u0441\u043a\u0440\u0438\u043f\u0442, \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0443\u0441\u0442\u0440\u0430\u043d\u0438\u0432 \u043f\u043e\u0431\u043e\u0447\u043d\u044b\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u044b. \u0427\u0442\u043e \u0436, \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/c2d\/db7\/1f2\/c2ddb71f2dc488bba7129684dc15c522.png\" alt=\"image\"\/>  <\/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-276474","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/276474","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=276474"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/276474\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=276474"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=276474"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=276474"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}