{"id":10999,"date":"2022-10-12T14:21:23","date_gmt":"2022-10-12T21:21:23","guid":{"rendered":"https:\/\/www.xh86.me\/?p=10999"},"modified":"2022-10-12T14:21:23","modified_gmt":"2022-10-12T21:21:23","slug":"bird-%e6%9e%84%e5%bb%ba%e8%87%aa%e5%b7%b1%e7%9a%84-anycast-%e7%bd%91%e7%bb%9c","status":"publish","type":"post","link":"https:\/\/www.xh86.me\/?p=10999","title":{"rendered":"Bird \u6784\u5efa\u81ea\u5df1\u7684 Anycast \u7f51\u7edc"},"content":{"rendered":"<p>\u9996\u5148\u4f60\u9700\u8981\uff1a<\/p>\n<ol>\n<li>\u4e00\u5bb6\u53ef\u4ee5\u8ba9\u4f60\u8dd1 BGP \u7684\u670d\u52a1\u5546\uff0c\u8fd9\u8fb9\u63a8\u8350\u8fd9\u4e24\u5bb6\u00a0<a href=\"https:\/\/www.vultr.com\/?ref=7101394\">Vultr<\/a>\uff0c<a href=\"https:\/\/app.misaka.io\/iaas\/vm\/\">Misaka<\/a><\/li>\n<li>\u4e00\u6bb5\u6709RPKI+IRR\u7684 IPv4 , IPv6\u6211\u5efa\u8bae\u4f60\u522b\u8dd1Anycast\u4e86\uff0c\u8c03\u8d77\u6765\u5934\u5927<\/li>\n<li>\u4e00\u4e2a\u81ea\u5df1\u7684ASN<\/li>\n<\/ol>\n<p><strong>\u5b89\u88c5bird\uff1a<\/strong><\/p>\n<p>\u7cfb\u7edf\u6211\u63a8\u8350\u4f7f\u7528debian 10\uff0c\u5b89\u88c5bird \u53ea\u9700\u8981<\/p>\n<p>apt install bird -y<\/p>\n<p>\u8bbe\u7f6e\u5f00\u673a\u81ea\u542f\u52a8<\/p>\n<p>systemctl enable bird<\/p>\n<p><strong>\u4fee\u6539bird \u914d\u7f6e<\/strong>\uff1a<\/p>\n<p>\u8fd9\u8fb9\u8d34\u4e00\u4e2a\u914d\u7f6e\u6587\u4ef6\u4f9b\u53c2\u8003<\/p>\n<pre class=\"wp-block-code\"><code>#\u5b9a\u4e49 router ID\r\nrouter id 100.127.70.25; \r\n#\u5b9a\u4e49\u81ea\u6709\u7f51\u7edc\uff0c\u8fd9\u662ffilter policy\r\nfunction is_own_network() {\r\n  return net ~ [\r\n    10.0.0.0\/22{22,24}     # Anycast DNS\r\n  ];\r\n}\r\n\r\n# The Kernel protocol is not a real routing protocol. Instead of communicating\r\n# with other routers in the network, it performs synchronization of BIRD's\r\n# routing tables with the OS kernel.\r\nprotocol kernel {\r\n        scan time 60;\r\n        import none;\r\n#       export all;   # Actually insert routes into the kernel routing table\r\n}\r\n\r\n# The Device protocol is not a real routing protocol. It doesn't generate any\r\n# routes and it only serves as a module for getting information about network\r\n# interfaces from the kernel. \r\nprotocol device {\r\n        scan time 60;\r\n}\r\n\r\nprotocol static static4 {\r\n  route 10.0.0.0\/24 reject;\r\n}\r\n\r\nprotocol bgp vultr\r\n{\r\n    # substitute with your AS or Vultr's private AS\r\n    local as xxxx;\r\n    import all;\r\n    export filter {\r\n    if is_own_network() &amp;&amp; source ~ [RTS_STATIC, RTS_BGP] then {\r\n      accept;\r\n    }\r\n    reject;\r\n    };\r\n    graceful restart on;\r\n    multihop 2;\r\n    neighbor 169.254.169.254 as 64515;\r\n    password \"\";\r\n}<\/code><\/pre>\n<p>\u4e0a\u9762\u7684\u914d\u7f6e\u6587\u4ef6\u6211\u7b80\u5355\u8bb2\u4e00\u4e0b\u51e0\u4e2a\u70b9\uff0cVultr\u5b98\u65b9\u7ed9\u51fa\u7684\u914d\u7f6e\u6587\u4ef6\u662fexport all\uff0c\u5176\u5b9e\u8fd9\u79cd\u5bf9\u4e8e\u7f51\u7edc\u67b6\u6784\u6765\u8bf4\u975e\u5e38\u4e0d\u8d1f\u8d23\u4efb\uff0c\u4f60\u8fd9\u6837100%\u4f1a\u5bfc\u81f4\u8def\u7531\u4fa7\u6f0f\u4ece\u800c\u5f15\u8d77BGP Session\u88ab\u6390\u65ad\u3002\u6240\u4ee5\u6211\u5199\u4e86\u4e00\u4e2a\u5b9a\u4e49\u6765\u786e\u4fdd\u4e0d\u4f1a\u6f0f\u522b\u4eba\u7684\u8def\u7531\u7ed9\u4e0a\u6e38\u3002<\/p>\n<p>\u5982\u679c\u4f60\u60f3\u8981\u4f7f\u7528\u4e00\u4e9bcommunity\uff08\u5176\u5b9e\u5728Anycast\u4e2d\u662f\u5fc5\u987b\u8981\u7684\uff09\u6765\u4fee\u6539\u8def\u5f84\u7684\u8bdd\uff0c\u4f60\u53ef\u4ee5\u5728 protocol static static4 \u4e0b\u6539\uff0c\u53ef\u4ee5\u53c2\u8003\u4e0b\u56fe\uff1a<\/p>\n<pre class=\"wp-block-code\"><code>route 10.0.0.0\/24 reject {\r\n    bgp_community.add((48024,666));\r\n    bgp_community.add((48024,6666));<\/code><\/pre>\n<p>\u6ce8\u610f\u4e00\u4e0b\uff0c\u4e00\u884c\u4e00\u4e2a\uff0c\u5e76\u4e14\u548ccisco\u4e0d\u4e00\u6837\u7684\u5730\u65b9\u662f\u4ed6\u662f\u7528,\u800c\u4e0d\u662f:\u7684\u3002<\/p>\n<p>community\u4e5f\u53ef\u4ee5\u5b9a\u4e49\uff0c\u53ef\u4ee5\u81ea\u5df1\u53bb\u7814\u7a76\u4e0b<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9996\u5148\u4f60\u9700\u8981\uff1a \u4e00\u5bb6\u53ef\u4ee5\u8ba9\u4f60\u8dd1 BGP \u7684\u670d\u52a1\u5546\uff0c\u8fd9\u8fb9\u63a8\u8350\u8fd9\u4e24\u5bb6\u00a0Vultr\uff0cMisaka \u4e00\u6bb5\u6709RPKI+IR [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,3],"tags":[],"class_list":["post-10999","post","type-post","status-publish","format-standard","hentry","category-linux","category-system"],"_links":{"self":[{"href":"https:\/\/www.xh86.me\/index.php?rest_route=\/wp\/v2\/posts\/10999","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=10999"}],"version-history":[{"count":1,"href":"https:\/\/www.xh86.me\/index.php?rest_route=\/wp\/v2\/posts\/10999\/revisions"}],"predecessor-version":[{"id":11000,"href":"https:\/\/www.xh86.me\/index.php?rest_route=\/wp\/v2\/posts\/10999\/revisions\/11000"}],"wp:attachment":[{"href":"https:\/\/www.xh86.me\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10999"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xh86.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10999"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xh86.me\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10999"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}