{"id":12135,"date":"2024-11-25T17:51:01","date_gmt":"2024-11-26T01:51:01","guid":{"rendered":"https:\/\/www.xh86.me\/?p=12135"},"modified":"2024-11-25T17:51:28","modified_gmt":"2024-11-26T01:51:28","slug":"%e5%9c%a8-vultr-%e4%b8%8a%e9%83%a8%e7%bd%b2-mikrotik-%e8%b7%af%e7%94%b1%e5%99%a8%ef%bc%8c%e5%b9%b6%e4%bd%bf%e7%94%a8%e8%87%aa%e6%9c%89-asn-%e5%92%8c-ip-%e5%b9%bf%e6%92%ad%e7%9a%84%e6%9c%80%e4%bd%b3","status":"publish","type":"post","link":"https:\/\/www.xh86.me\/?p=12135","title":{"rendered":"\u5728 Vultr \u4e0a\u90e8\u7f72 MikroTik \u8def\u7531\u5668\uff0c\u5e76\u4f7f\u7528\u81ea\u6709 ASN \u548c IP \u5e7f\u64ad\u7684\u6700\u4f73\u5b9e\u8df5\u4e0e\u6280\u672f\u4f18\u5316\u624b\u518c"},"content":{"rendered":"<p>&nbsp;<\/p>\n<h2><strong>1. \u5148\u51b3\u6761\u4ef6<\/strong><\/h2>\n<h3><strong>1.1 \u51c6\u5907\u5de5\u4f5c<\/strong><\/h3>\n<ol>\n<li><strong>\u81ea\u6709 ASN\uff08Autonomous System Number\uff09<\/strong>\uff1a\n<ul>\n<li>\u4ece RIR\uff08\u4f8b\u5982 ARIN\u3001RIPE NCC\u3001APNIC\uff09\u83b7\u53d6\u81ea\u5df1\u7684 ASN\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u81ea\u6709 IP \u5730\u5740<\/strong>\uff1a\n<ul>\n<li>\u786e\u4fdd\u62e5\u6709\u6ce8\u518c\u7684 IP \u5730\u5740\u5757\uff0c\u5e76\u5728 RIR \u6570\u636e\u5e93\u4e2d\u6388\u6743 Vultr \u4f5c\u4e3a\u5176\u516c\u544a\u7684\u4e0a\u6e38\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>Vultr \u8d26\u6237\u548c\u73af\u5883<\/strong>\uff1a\n<ul>\n<li>\u5728 Vultr \u4e2d\u521b\u5efa\u4e00\u4e2a\u8d26\u6237\uff0c\u5e76\u83b7\u53d6\u4e91\u670d\u52a1\u5668\u8d44\u6e90\u3002<\/li>\n<li>\u63d0\u4ea4\u652f\u6301\u5de5\u5355\uff0c\u5c06\u81ea\u6709 ASN \u548c IP \u5730\u5740\u52a0\u5165 Vultr \u7684\u7f51\u7edc\u914d\u7f6e\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>MikroTik CHR<\/strong>\uff1a\n<ul>\n<li>\u51c6\u5907\u6700\u65b0\u7248\u672c\u7684 MikroTik Cloud Hosted Router \u6620\u50cf\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<hr \/>\n<h2><strong>2. \u90e8\u7f72 MikroTik CHR<\/strong><\/h2>\n<h3><strong>2.1 \u521b\u5efa Vultr \u5b9e\u4f8b<\/strong><\/h3>\n<ol>\n<li>\u767b\u5f55 Vultr \u63a7\u5236\u9762\u677f\u3002<\/li>\n<li>\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u4e91\u670d\u52a1\u5668\u5b9e\u4f8b\uff1a\n<ul>\n<li><strong>\u9009\u62e9\u64cd\u4f5c\u7cfb\u7edf<\/strong>\uff1a\u9009\u62e9 &#8220;Custom ISO&#8221; \u5e76\u4e0a\u4f20 MikroTik CHR \u7684 ISO\u3002<\/li>\n<li><strong>\u9009\u62e9\u6570\u636e\u4e2d\u5fc3\u4f4d\u7f6e<\/strong>\uff1a\u9009\u62e9\u63a5\u8fd1\u76ee\u6807\u5ba2\u6237\u7684\u533a\u57df\u3002<\/li>\n<li><strong>\u786c\u4ef6\u914d\u7f6e<\/strong>\uff1a\u9009\u62e9\u81f3\u5c11 2 \u6838 CPU\u30012 GB RAM \u548c 20 GB SSD\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u542f\u52a8\u5b9e\u4f8b\u5e76\u901a\u8fc7\u63a7\u5236\u53f0\u5b89\u88c5 MikroTik CHR\u3002<\/li>\n<\/ol>\n<hr \/>\n<h3><strong>2.2 \u521d\u59cb\u5316 MikroTik CHR<\/strong><\/h3>\n<ol>\n<li>\u767b\u5f55 MikroTik CHR\uff1a\n<ul>\n<li>\u901a\u8fc7 Vultr \u63d0\u4f9b\u7684\u63a7\u5236\u53f0\u8bbf\u95ee MikroTik CLI\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u8bbe\u7f6e\u521d\u59cb\u914d\u7f6e\uff1a\n<pre><code class=\"language-bash\">\/system identity set name=\"Vultr-MikroTik\"\r\n\/ip address add address=192.168.1.2\/24 interface=ether1 network=192.168.1.0\r\n\/ip route add gateway=192.168.1.1\r\n\/ip dns set servers=8.8.8.8,8.8.4.4\r\n<\/code><\/pre>\n<\/li>\n<li>\u6fc0\u6d3b MikroTik CHR \u8bb8\u53ef\u8bc1\uff1a\n<ul>\n<li>\u767b\u5f55 MikroTik Winbox \u6216 Webfig\u3002<\/li>\n<li>\u5bfc\u822a\u5230 <strong>System &gt; License<\/strong>\uff0c\u6fc0\u6d3b <strong>P1<\/strong> \u6216\u66f4\u9ad8\u7684\u8bb8\u53ef\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<hr \/>\n<h2><strong>3. \u914d\u7f6e BGP Peer<\/strong><\/h2>\n<h3><strong>3.1 \u8bf7\u6c42 Vultr \u914d\u7f6e<\/strong><\/h3>\n<ol>\n<li>\u5411 Vultr \u63d0\u4ea4\u5de5\u5355\uff0c\u63d0\u4f9b\u4ee5\u4e0b\u4fe1\u606f\uff1a\n<ul>\n<li>\u81ea\u6709 ASN\u3002<\/li>\n<li>\u8981\u5e7f\u64ad\u7684 IP \u5730\u5740\u5757\u3002<\/li>\n<li>\u671f\u671b\u7684 BGP Peer \u914d\u7f6e\u3002<\/li>\n<\/ul>\n<\/li>\n<li>Vultr \u652f\u6301\u56e2\u961f\u5c06\u63d0\u4f9b\u4ee5\u4e0b\u4fe1\u606f\uff1a\n<ul>\n<li>Vultr \u7684 ASN\u3002<\/li>\n<li>Vultr \u7684 BGP Peer \u5730\u5740\u3002<\/li>\n<li>BGP \u4f1a\u8bdd\u53c2\u6570\uff08\u5982\u5bc6\u7801\uff09\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<hr \/>\n<h3><strong>3.2 MikroTik BGP \u914d\u7f6e<\/strong><\/h3>\n<ol>\n<li><strong>\u6dfb\u52a0 BGP \u5b9e\u4f8b<\/strong>\uff1a\n<pre><code class=\"language-bash\">\/routing bgp instance add name=\"BGP-Vultr\" as=&lt;YOUR_ASN&gt; router-id=&lt;YOUR_ROUTER_IP&gt;\r\n<\/code><\/pre>\n<\/li>\n<li><strong>\u914d\u7f6e BGP Peer<\/strong>\uff1a\n<pre><code class=\"language-bash\">\/routing bgp peer add name=\"VultrPeer\" remote-address=&lt;VULTR_PEER_IP&gt; remote-as=&lt;VULTR_ASN&gt; instance=\"BGP-Vultr\" password=&lt;PEER_PASSWORD&gt;\r\n<\/code><\/pre>\n<\/li>\n<li><strong>\u6dfb\u52a0\u7f51\u7edc\u516c\u544a<\/strong>\uff1a\n<ul>\n<li>\u5e7f\u64ad\u81ea\u6709 IP \u5757\u3002<\/li>\n<\/ul>\n<pre><code class=\"language-bash\">\/routing bgp network add network=&lt;YOUR_IP_BLOCK&gt;\r\n<\/code><\/pre>\n<\/li>\n<li><strong>\u9a8c\u8bc1 BGP \u4f1a\u8bdd<\/strong>\uff1a\n<ul>\n<li>\u68c0\u67e5 BGP \u4f1a\u8bdd\u72b6\u6001\uff1a\n<pre><code class=\"language-bash\">\/routing bgp peer print\r\n<\/code><\/pre>\n<\/li>\n<li>\u786e\u8ba4\u72b6\u6001\u4e3a <code>established<\/code>\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<hr \/>\n<h2><strong>4. \u4f18\u5316\u7f51\u7edc\u6027\u80fd<\/strong><\/h2>\n<h3><strong>4.1 \u914d\u7f6e BGP \u7b56\u7565<\/strong><\/h3>\n<ol>\n<li><strong>\u5165\u7ad9\u8fc7\u6ee4<\/strong>\uff1a\n<ul>\n<li>\u9650\u5236\u63a5\u6536\u7684\u8def\u7531\u6570\u91cf\uff0c\u907f\u514d\u5168\u8868\u8def\u7531\u5bfc\u81f4\u8bbe\u5907\u8d1f\u8f7d\u8fc7\u9ad8\u3002<\/li>\n<\/ul>\n<pre><code class=\"language-bash\">\/routing filter add chain=bgp-in prefix=&lt;VULTR_PREFIX&gt; action=accept\r\n\/routing filter add chain=bgp-in action=discard\r\n<\/code><\/pre>\n<\/li>\n<li><strong>\u51fa\u7ad9\u7b56\u7565<\/strong>\uff1a\n<ul>\n<li>\u5e7f\u64ad\u7279\u5b9a\u7684 IP \u524d\u7f00\u3002<\/li>\n<\/ul>\n<pre><code class=\"language-bash\">\/routing filter add chain=bgp-out prefix=&lt;YOUR_IP_BLOCK&gt; action=accept\r\n\/routing filter add chain=bgp-out action=discard\r\n<\/code><\/pre>\n<\/li>\n<li><strong>\u5e94\u7528\u8fc7\u6ee4\u89c4\u5219<\/strong>\uff1a\n<pre><code class=\"language-bash\">\/routing bgp peer set VultrPeer in-filter=bgp-in out-filter=bgp-out\r\n<\/code><\/pre>\n<\/li>\n<\/ol>\n<hr \/>\n<h3><strong>4.2 \u6027\u80fd\u8c03\u4f18<\/strong><\/h3>\n<ol>\n<li><strong>MTU \u8c03\u6574<\/strong>\uff1a\n<ul>\n<li>\u8bbe\u7f6e\u96a7\u9053\u63a5\u53e3\u548c\u4ee5\u592a\u7f51\u63a5\u53e3\u7684 MTU\uff0c\u907f\u514d\u5206\u7247\uff1a\n<pre><code class=\"language-bash\">\/interface ethernet set ether1 mtu=1500\r\n<\/code><\/pre>\n<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u542f\u7528\u591a\u7ebf\u7a0b<\/strong>\uff1a\n<ul>\n<li>\u5982\u679c\u8bbe\u5907\u652f\u6301\u591a\u6838\uff0c\u542f\u7528\u591a\u7ebf\u7a0b\u52a0\u901f BGP \u6027\u80fd\uff1a\n<pre><code class=\"language-bash\">\/routing bgp instance set BGP-Vultr multithread=yes\r\n<\/code><\/pre>\n<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u6d41\u91cf\u4f18\u5148\u7ea7<\/strong>\uff1a\n<ul>\n<li>\u4f7f\u7528 QoS \u4f18\u5316\u5173\u952e\u4e1a\u52a1\u6d41\u91cf\uff1a\n<pre><code class=\"language-bash\">\/queue simple add name=\"PriorityTraffic\" target=&lt;YOUR_IP_BLOCK&gt; priority=1 max-limit=100M\/100M\r\n<\/code><\/pre>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<hr \/>\n<h3><strong>4.3 \u9ad8\u53ef\u7528\u6027<\/strong><\/h3>\n<ol>\n<li><strong>\u914d\u7f6e\u5907\u7528 Peer<\/strong>\uff1a\n<ul>\n<li>\u6dfb\u52a0 Vultr \u7684\u5176\u4ed6 BGP Peer\uff0c\u6784\u5efa\u5197\u4f59\uff1a\n<pre><code class=\"language-bash\">\/routing bgp peer add name=\"BackupPeer\" remote-address=&lt;VULTR_BACKUP_IP&gt; remote-as=&lt;VULTR_ASN&gt; instance=\"BGP-Vultr\"\r\n<\/code><\/pre>\n<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u5065\u5eb7\u76d1\u6d4b<\/strong>\uff1a\n<ul>\n<li>\u914d\u7f6e Netwatch \u68c0\u6d4b Peer \u72b6\u6001\uff0c\u81ea\u52a8\u5207\u6362\u8def\u7531\uff1a\n<pre><code class=\"language-bash\">\/tool netwatch add host=&lt;VULTR_PEER_IP&gt; up-script=\"\/routing bgp peer enable VultrPeer\" down-script=\"\/routing bgp peer disable VultrPeer\"\r\n<\/code><\/pre>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<hr \/>\n<h2><strong>5. \u5b89\u5168\u6027\u4f18\u5316<\/strong><\/h2>\n<h3><strong>5.1 \u9650\u5236\u7ba1\u7406\u8bbf\u95ee<\/strong><\/h3>\n<ol>\n<li><strong>\u9632\u706b\u5899\u89c4\u5219<\/strong>\uff1a\n<ul>\n<li>\u7981\u6b62\u672a\u7ecf\u6388\u6743\u7684\u7ba1\u7406\u8bbf\u95ee\uff1a\n<pre><code class=\"language-bash\">\/ip firewall filter add chain=input protocol=tcp dst-port=22,8291 src-address=&lt;TRUSTED_IP&gt; action=accept\r\n\/ip firewall filter add chain=input action=drop\r\n<\/code><\/pre>\n<\/li>\n<\/ul>\n<\/li>\n<li><strong>BGP \u4f1a\u8bdd\u52a0\u5bc6<\/strong>\uff1a\n<ul>\n<li>\u4f7f\u7528\u5bc6\u7801\u4fdd\u62a4 BGP \u4f1a\u8bdd\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<hr \/>\n<h3><strong>5.2 DDoS \u9632\u62a4<\/strong><\/h3>\n<ol>\n<li><strong>\u9650\u901f SYN \u6d41\u91cf<\/strong>\uff1a\n<pre><code class=\"language-bash\">\/ip firewall filter add chain=input protocol=tcp tcp-flags=syn action=add-src-to-address-list address-list=ddos_attackers address-list-timeout=10m\r\n\/ip firewall filter add chain=input src-address-list=ddos_attackers action=drop\r\n<\/code><\/pre>\n<\/li>\n<li><strong>\u9650\u5236 ICMP \u6d41\u91cf<\/strong>\uff1a\n<pre><code class=\"language-bash\">\/ip firewall filter add chain=input protocol=icmp limit=50\/second action=accept\r\n\/ip firewall filter add chain=input protocol=icmp action=drop\r\n<\/code><\/pre>\n<\/li>\n<\/ol>\n<hr \/>\n<h2><strong>6. \u76d1\u63a7\u4e0e\u7ef4\u62a4<\/strong><\/h2>\n<h3><strong>6.1 \u5b9e\u65f6\u76d1\u63a7<\/strong><\/h3>\n<ol>\n<li>\u4f7f\u7528 <code>The Dude<\/code> \u6216\u5176\u4ed6\u5de5\u5177\u76d1\u63a7\u7f51\u7edc\u72b6\u6001\u3002<\/li>\n<li>\u5728 MikroTik \u4e0a\u67e5\u770b BGP \u6d41\u91cf\uff1a\n<pre><code class=\"language-bash\">\/tool graphing interface add interface=ether1\r\n<\/code><\/pre>\n<\/li>\n<\/ol>\n<hr \/>\n<h3><strong>6.2 \u5b9a\u671f\u7ef4\u62a4<\/strong><\/h3>\n<ol>\n<li><strong>\u5907\u4efd\u914d\u7f6e<\/strong>\uff1a\n<pre><code class=\"language-bash\">\/export file=config-backup\r\n<\/code><\/pre>\n<\/li>\n<li><strong>\u66f4\u65b0\u8f6f\u4ef6<\/strong>\uff1a\n<ul>\n<li>\u5b9a\u671f\u68c0\u67e5\u5e76\u66f4\u65b0 MikroTik CHR \u5230\u6700\u65b0\u7248\u672c\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; 1. \u5148\u51b3\u6761\u4ef6 1.1 \u51c6\u5907\u5de5\u4f5c \u81ea\u6709 ASN\uff08Autonomous System Number [&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,2],"tags":[],"class_list":["post-12135","post","type-post","status-publish","format-standard","hentry","category-mikrotik","category-network"],"_links":{"self":[{"href":"https:\/\/www.xh86.me\/index.php?rest_route=\/wp\/v2\/posts\/12135","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=12135"}],"version-history":[{"count":2,"href":"https:\/\/www.xh86.me\/index.php?rest_route=\/wp\/v2\/posts\/12135\/revisions"}],"predecessor-version":[{"id":12137,"href":"https:\/\/www.xh86.me\/index.php?rest_route=\/wp\/v2\/posts\/12135\/revisions\/12137"}],"wp:attachment":[{"href":"https:\/\/www.xh86.me\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=12135"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xh86.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=12135"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xh86.me\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=12135"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}