{"id":3381,"date":"2021-11-17T14:38:05","date_gmt":"2021-11-17T22:38:05","guid":{"rendered":"https:\/\/www.xh86.me\/?p=3381"},"modified":"2021-11-17T14:38:05","modified_gmt":"2021-11-17T22:38:05","slug":"dd-mikrotik%e7%b3%bb%e7%bb%9f","status":"publish","type":"post","link":"https:\/\/www.xh86.me\/?p=3381","title":{"rendered":"DD Mikrotik\u7cfb\u7edf"},"content":{"rendered":"<p><strong>\u51c6\u5907\u6761\u4ef6\uff1a<\/strong><\/p>\n<p>\u7eaf\u51c0centos7 \u7cfb\u7edf\uff08debian\/ubuntu16\u901a\u8fc7\u7c7b\u4f3c\uff09<br \/>\n\u66f4\u65b0\u7cfb\u7edf\uff1ayum update<br \/>\n\u5b89\u88c5wget : yum install wget -y<br \/>\n\u5173\u95edfirewalld\uff1a systemctl stop firewalld.service &amp;&amp; systemctl disable firewalld.service<\/p>\n<h2 id=\"pk-menu-0\">\u4e00\u3001\u901a\u7528\u5355\u7f51\u5361\u65b9\u6848 (\u9002\u5e94\u4e8e\u7edd\u5927\u591a\u6570VPS)<\/h2>\n<p><strong>\u4e0b\u8f7d\u955c\u50cf<\/strong><br \/>\nwget https:\/\/download.mikrotik.com\/routeros\/6.48.3\/chr-6.48.3.img.zip -O chr.img.zip<\/p>\n<p><strong>\u89e3\u538b\u7f29<\/strong><br \/>\ngunzip -c chr.img.zip &gt; chr.img<\/p>\n<p><strong>\u6302\u8f7d\u955c\u50cf<\/strong><br \/>\n#\u6ce8\u610f\uff1a\u5148\u7528\u547d\u4ee4 fdisk -lu chr.img \u67e5\u770bstart\u503c\u662f\u5426\u4e3a1\uff0c\u4e0d\u662f\uff0c\u5219\u7528\u5f53\u524d\u6570\u5b57 *512\uff0c\u66ff\u6362\u4e0b\u9762\u547d\u4ee4\u4e2d\u7684offse\u503c<br \/>\nmount -o loop,offset=512 chr.img \/mnt<\/p>\n<p><strong>\u83b7\u53d6\u5730\u5740\u4e0e\u7f51\u5173 \u4e0e \u8d4b\u5165\u53d8\u91cf<\/strong><br \/>\n#<strong>\u6709\u7684\u7f51\u5361\u4e0d\u662feth0 \u53ef\u4ee5\u7528ifconfig\u547d\u4ee4\u67e5\u770b\u6216\u8005ip addr \u67e5\u770b\uff0c\u4f7f\u7528\u5bf9\u5e94\u7f51\u5361\u547d\u4ee4\u5373\u53ef<\/strong><\/p>\n<pre class=\"wp-block-code hljs sql\">ADDR0=`ip addr <span class=\"hljs-keyword\">show<\/span> eth0 | grep <span class=\"hljs-keyword\">global<\/span> | cut -d<span class=\"hljs-string\">' '<\/span> -f <span class=\"hljs-number\">6<\/span> | <span class=\"hljs-keyword\">head<\/span> -n <span class=\"hljs-number\">1<\/span><span class=\"hljs-string\">`\r\nADDR0=`<\/span>ip addr <span class=\"hljs-keyword\">show<\/span> ens3 | grep <span class=\"hljs-keyword\">global<\/span> | cut -d<span class=\"hljs-string\">' '<\/span> -f <span class=\"hljs-number\">6<\/span> | <span class=\"hljs-keyword\">head<\/span> -n <span class=\"hljs-number\">1<\/span><span class=\"hljs-string\">`<\/span><\/pre>\n<pre class=\"wp-block-code hljs ini\"><span class=\"hljs-attr\">GATE0<\/span>=`ip route list | grep default | cut -d<span class=\"hljs-string\">' '<\/span> -f <span class=\"hljs-number\">3<\/span>`<\/pre>\n<pre class=\"wp-block-code hljs nginx\"><span class=\"hljs-attribute\">mkdir<\/span> -p \/mnt\/rw<\/pre>\n<pre class=\"wp-block-code hljs bash\">\\<span class=\"hljs-built_in\">echo<\/span> <span class=\"hljs-string\">\"\/ip address add address=<span class=\"hljs-variable\">$ADDR0<\/span> interface=[\/interface ethernet find where name=ether1]\r\n\/ip route add gateway=<span class=\"hljs-variable\">$GATE0<\/span>\r\n\"<\/span> &gt; \/mnt\/rw\/autorun.scr<\/pre>\n<p><strong>\u5378\u8f7d\u955c\u50cf<\/strong><\/p>\n<p>umount \/mnt<\/p>\n<p><strong>\u7acb\u5373\u91cd\u65b0\u6302\u8f7d\u6240\u6709\u7684\u6587\u4ef6\u7cfb\u7edf\u4e3a\u53ea\u8bfb<\/strong><\/p>\n<p>echo u &gt; \/proc\/sysrq-trigger<\/p>\n<p><strong>DD ros\u955c\u50cf<\/strong>\uff08\u6709\u7684\u673a\u5668\u786c\u76d8\u5e76\u4e0d\u662f\/dev\/sda\u800c\u662f\/dev\/vda\uff0c\u9700\u8981\u63d0\u524d\u4f7f\u7528fdisk -lu\uff09<\/p>\n<p>dd if=chr.img bs=1024 of=\/dev\/vda<br \/>\nreboot<br \/>\n\uff08reboot\u5931\u6548\u53ef\u7528\u4e0b\u9762\u547d\u4ee4\uff09<br \/>\n<strong>\u7acb\u5373\u91cd\u65b0\u542f\u52a8\u673a\u5668<\/strong><\/p>\n<p>echo b &gt; \/proc\/sysrq-trigger<\/p>\n<p>\u5b89\u88c5\u597d\u4e4b\u540e\u7528\u6709vnc\u7684\u53ef\u4ee5\u767b\u5f55console\u770b\u5230\u5b89\u88c5\u754c\u9762\uff0c\u9ed8\u8ba4\u8d26\u53f7\u662fadmin\uff0c\u9ed8\u8ba4\u5bc6\u7801\u662f\u7a7a\u3002<strong>\u5c3d\u5feb\u767b\u5f55\u4fee\u6539\u5bc6\u7801<\/strong>\u3002<\/p>\n<p><strong>\u4e00\u952e\u811a\u672c<\/strong><\/p>\n<pre class=\"wp-block-code hljs properties\"><span class=\"hljs-attr\">wget<\/span> <span class=\"hljs-string\">https:\/\/download.mikrotik.com\/routeros\/6.48.3\/chr-6.48.3.img.zip -O chr.img.zip &amp;&amp; \\\r\ngunzip -c chr.img.zip &gt; chr.img &amp;&amp; \\\r\nmount -o loop,offset=512 chr.img \/mnt &amp;&amp; \\\r\nADDR0=`ip addr show eth0 | grep global | cut -d' ' -f 6 | head -n 1` &amp;&amp; \\\r\nGATE0=`ip route list | grep default | cut -d' ' -f 3` &amp;&amp; \\\r\nmkdir -p \/mnt\/rw &amp;&amp; \\\r\necho \"\/ip address add address=$ADDR0 interface=[\/interface ethernet find where name=ether1]<\/span>\r\n<span class=\"hljs-meta\">\/ip<\/span> <span class=\"hljs-string\">route add gateway=$GATE0<\/span>\r\n<span class=\"hljs-meta\">\"<\/span> <span class=\"hljs-string\">&gt; \/mnt\/rw\/autorun.scr &amp;&amp; \\\r\numount \/mnt &amp;&amp; \\\r\necho u &gt; \/proc\/sysrq-trigger &amp;&amp; \\\r\ndd if=chr.img bs=1024 of=\/dev\/vda &amp;&amp; reboot<\/span><\/pre>\n<p><strong>\u5e38\u89c1\u95ee\u9898\uff1a<\/strong><br \/>\n\u6709\u4e9bD\u5b8c\u6b7b\u6d3b\u542f\u4e0d\u52a8\u8fde\u4e0d\u4e0a \u662f\u56e0\u4e3aUEFI\u7684\u7f18\u6545\uff0c\u8ddf\u811a\u672c\u65e0\u5173 \u8bf7\u6539\u7528 ROS7.0Beta \u7248\u672c \u652f\u6301UEFI\u542f\u52a8<br \/>\nwget https:\/\/download.mikrotik.com\/routeros\/7.0beta5\/chr-7.0beta5.img.zip -O chr.img.zip<\/p>\n<p><strong>Ros \u6388\u6743\u76f8\u5173<\/strong><\/p>\n<p>Ros \u7cfb\u7edf\u662f\u5546\u4e1a\u8f6f\u4ef6 \uff0c\u672c\u8eab\u662f\u9700\u8981\u6388\u6743\u7684\uff0c\u5728\u6ca1\u6709\u6388\u6743\u7684\u60c5\u51b5\u4e0b\u4f7f\u7528\uff0c\u7f51\u5361\u9650\u5236\u901f\u7387(<strong>1Mbps<\/strong>)\uff0c\u4e0d\u8fc7Ros CHR\u7248\u672c\u662f\u652f\u6301\u514d\u8d39\u8bd5\u7528\u7684\uff0c\u53ea\u9700\u8981\u53bb\u5b98\u65b9\u7f51\u7ad9\u00a0<a href=\"https:\/\/mikrotik.com\/client\" target=\"_blank\" rel=\"nofollow noopener\">https:\/\/mikrotik.com\/client<\/a>\u00a0\u6ce8\u518c\u4e00\u4e2a\u5e10\u53f7\uff0c\u7136\u540e\u53bb\u90ae\u7bb1\u83b7\u53d6\u5e10\u53f7\u901a\u8fc7\u9a8c\u8bc1\uff0c\u63a5\u7740\u8fd4\u56de\u5230Ros\u7cfb\u7edf\u00a0 \u8fdb\u5165 System &gt; License\u00a0&gt; generate new id \u586b\u5165\u4f60\u521a\u521a\u6ce8\u518c\u7684\u5e10\u53f7\u767b\u5f55\u5373\u53ef\uff0c\u8bd5\u7528\u671f\u662f\u4e24\u4e2a\u6708\u65f6\u957f\uff0c\u53ea\u8981\u7cfb\u7edf\u4e0d\u8fdb\u884c\u66f4\u65b0\uff0c\u662f\u53ef\u4ee5\u4e00\u76f4\u514d\u8d39\u8bd5\u7528\u4e0b\u53bb\u7684\uff0c\u529f\u80fd\u4e0d\u53d7\u9650\u5236\u3002<\/p>\n<p><strong>SSH\u767b\u5f55<\/strong><br \/>\n\u4e00\u822cNAT\u5c0f\u9e21DD\u5b8cros\u540e\u4f1a\u81ea\u52a8\u8bbe\u7f6e\u597d\u7f51\u7edc\u8fd9\u4e9b\uff0c\u53ea\u9700\u8981\u91cd\u542f\u673a\u5668\uff0c\u7136\u540e\u4f7f\u7528xshell or putty \uff0c\u8fde\u63a5NAT\u7684IP\uff0cSSH\u7aef\u53e3\u53f7\uff0c\u7528\u6237\u540d\u4e3aadmin\uff0c\u5bc6\u7801\u4e3a\u7a7a\uff1b\u767b\u5f55\u5230ros\u8def\u7531\u7ba1\u7406\u754c\u9762\uff0c\u8f93\u5165\/ip service set winbox port=\u6620\u5c04\u7aef\u53e3\uff0c\u00a0\u53ef\u91cd\u65b0\u6620\u5c04winbox\u7aef\u53e3\uff1b<\/p>\n<p><strong>\u4f7f\u7528winbox\u767b\u5f55ros\u7cfb\u7edf<\/strong>\u00a0<strong>\u5e76\u4fee\u6539\u9ed8\u8ba4\u7528\u6237<\/strong>\uff08ssh\u5ba2\u6237\u7aef\u767b\u5f55\u4e3aIP\u5730\u5740\uff0cssh\u7aef\u53e3\u53f7\uff0c\u521d\u59cb\u7528\u6237\u540d\u548c\u5bc6\u7801\uff09<\/p>\n<p>winbox\u00a0<a href=\"https:\/\/download.mikrotik.com\/winbox\/3.28\/winbox64.exe\" target=\"_blank\" rel=\"nofollow noopener\">\u4e0b\u8f7d\u94fe\u63a5<\/a><br \/>\n\u9ed8\u8ba4\u767b\u5f55\u540d\u4e3a\uff1aadmin \u9ed8\u8ba4\u5bc6\u7801\u4e3a\uff1a \u7a7a<br \/>\n\u767b\u5f55\u4e4b\u540e\u5c3d\u5feb\u4fee\u6539\u6743\u9650\uff0c\u53ef\u65b0\u589e\u7528\u6237\uff08system&gt;users add\uff09,\u7136\u540e\u7981\u7528\u539fadmin\u7528\u6237\uff1b\u6216\u4fee\u6539\u5fc5\u8981\u7aef\u53e3\uff08IP&gt;firewall&gt;service ports\uff09<br \/>\n<strong>\u5982\u679c\u4f60\u4f7f\u7528\u7684MAC\u5730\u5740\u767b\u5f55\u7684\u8bdd\uff0c\u4e0d\u9700\u8981\u8f93\u5165\u7aef\u53e3<\/strong>\u3002<\/p>\n<figure class=\"wp-block-image size-large\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/maobuni.com\/wp-content\/uploads\/2021\/06\/image-5.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" class=\"wp-image-175\" title=\"centos7\" data-original=\"https:\/\/maobuni.com\/wp-content\/uploads\/2021\/06\/image-5.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" sizes=\"auto, (max-width: 757px) 100vw, 757px\"  alt=\"centos7\" width=\"757\" height=\"542\" \/><\/div><\/figure>\n<h2 id=\"pk-menu-1\"><strong>ROS \u5e38\u7528\u547d\u4ee4\uff1a<\/strong><\/h2>\n<p>1\u3001\u67e5\u770b\u7f51\u5361\u63a5\u53e3\uff1a \/interface\u00a0 print<\/p>\n<p>2\u3001\u7ed9\u7f51\u53e3\u6dfb\u52a0IP\u5730\u5740\uff1a \/ip address add address=192.168.1.254\/24 interface=ether1<\/p>\n<p>3\u3001\u79fb\u9664\u63a5\u53e3IP\u5730\u5740\uff1a\u3000 \/ip address remove 0<\/p>\n<p>4\u3001\u91cd\u542f\u7cfb\u7edf\uff1a\u3000\u3000\/system reboot<\/p>\n<p>5\u3001\u5173\u95ed\u7cfb\u7edf\uff1a\u3000\u3000\/system shutdown<\/p>\n<p>6\u3001\u6062\u590d\u539f\u59cb\u72b6\u6001\uff1a\u3000\u3000\/system reset<\/p>\n<p>7\u3001\u67e5\u770bIP\u914d\u7f6e\uff1a\u3000\u3000\/ip export\u3000\u3000\u3000\u3000\u6216\u00a0 \/ip address print<\/p>\n<p>8\u3001\u67e5\u770b\u6388\u6743\uff1a\u3000\u3000\/system license print<\/p>\n<p>9\u3001\u91cd\u65b0\u6620\u5c04winbox\u7aef\u53e3\uff1a \/ip service set winbox port=\u6620\u5c04\u7aef\u53e3<\/p>\n<p>10\u3001\u67e5\u770b\u7f51\u5361\u540d\u79f0\uff1a interface print<\/p>\n<p>11\u3001\u914d\u7f6eIP\u5730\u5740\u548c\u7f51\u5173\uff1a \/ip address add address=IP\u5730\u5740\/\u63a9\u7801 interface=\u7f51\u5361\u540d<\/p>\n<p>\/ip route add gateway=\u7f51\u5173\u5730\u5740<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u51c6\u5907\u6761\u4ef6\uff1a \u7eaf\u51c0centos7 \u7cfb\u7edf\uff08debian\/ubuntu16\u901a\u8fc7\u7c7b\u4f3c\uff09 \u66f4\u65b0\u7cfb\u7edf\uff1ayum update [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-3381","post","type-post","status-publish","format-standard","hentry","category-mikrotik"],"_links":{"self":[{"href":"https:\/\/www.xh86.me\/index.php?rest_route=\/wp\/v2\/posts\/3381","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xh86.me\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xh86.me\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xh86.me\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xh86.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3381"}],"version-history":[{"count":1,"href":"https:\/\/www.xh86.me\/index.php?rest_route=\/wp\/v2\/posts\/3381\/revisions"}],"predecessor-version":[{"id":3382,"href":"https:\/\/www.xh86.me\/index.php?rest_route=\/wp\/v2\/posts\/3381\/revisions\/3382"}],"wp:attachment":[{"href":"https:\/\/www.xh86.me\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3381"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xh86.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3381"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xh86.me\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3381"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}