{"id":1873,"date":"2023-03-01T15:01:26","date_gmt":"2023-03-01T07:01:26","guid":{"rendered":"http:\/\/iqotom.com\/?p=1873"},"modified":"2024-09-30T17:27:41","modified_gmt":"2024-09-30T09:27:41","slug":"openwrt%e5%ae%89%e8%a3%85%e9%85%8d%e7%bd%aetailscale","status":"publish","type":"post","link":"http:\/\/iqotom.com\/?p=1873","title":{"rendered":"OpenWrt\u5b89\u88c5\u914d\u7f6eTailscale\u5b9e\u73b0\u5185\u7f51\u7a7f\u900f\uff0c\u5f02\u5730\u7ec4\u7f51"},"content":{"rendered":"\n<p><\/p>\n\n\n\n<p>\u5f53\u524d\u5bf9\u5bb6\u5ead\u5bbd\u5e26\u800c\u8a00\uff0c\u53ef\u4ee5\u4f7f\u7528\u7684IPv4\u516c\u7f51IP\u8d8a\u6765\u8d8a\u5c11\uff0c\u8bbf\u95ee\u5bb6\u5ead\u5185\u7f51\u7684\u8d44\u6e90\u5c06\u4f1a\u53d8\u5f97\u8d8a\u6765\u8d8a\u56f0\u96be\u3002\u90e8\u5206\u7f51\u53cb\u53ef\u80fd\u4f1a\u9009\u62e9\u4f7f\u7528frp\u7b49\u9488\u5bf9\u7279\u5b9a\u534f\u8bae\u548c\u7aef\u53e3\u7684\u5185\u7f51\u7a7f\u900f\u65b9\u6848\uff0c\u4f46\u8fd9\u79cd\u65b9\u6848\u4e0d\u662f\u5341\u5206\u5b8c\u7f8e\uff0c\u65e0\u6cd5\u8bbf\u95ee\u5bb6\u5ead\u5185\u7f51\u4efb\u610f\u8bbe\u5907\u7684\u4efb\u610f\u7aef\u53e3\u3002\u6700\u4f73\u7684\u9009\u62e9\u8fd8\u662f\u901a\u8fc7VPN\u6765\u7ec4\u5efa\u5927\u5185\u7f51\u3002\u5c31\u5f53\u524d\u6280\u672f\u53d1\u5c55\u800c\u8a00\uff0c\u6beb\u65e0\u7591\u95ee\u5fc5\u987b\u9009\u62e9WireGuard\uff0cWireGuard\u5c31\u662fVPN\u7684\u672a\u6765\u3002<\/p>\n\n\n\n<p>WireGuard\u76f8\u6bd4\u4e8e\u4f20\u7edfVPN\u7684\u6838\u5fc3\u4f18\u52bf\u662f\u6ca1\u6709VPN\u7f51\u5173\uff0c\u6240\u6709\u8282\u70b9\u4e4b\u95f4\u90fd\u53ef\u4ee5\u70b9\u5bf9\u70b9\uff08P2P\uff09\u8fde\u63a5\uff0c\u6548\u7387\u9ad8\uff0c\u901f\u5ea6\u5feb\uff0c\u6210\u672c\u4f4e\u3002<\/p>\n\n\n\n<p>\u4f46WireGuard\u76ee\u524d\u6700\u5927\u7684\u75db\u70b9\u5c31\u662f\u4e0a\u5c42\u5e94\u7528\u7684\u529f\u80fd\u4e0d\u591f\u5065\u5168\uff0cWireGuard\u672c\u8eab\u53ea\u662f\u4e00\u4e2a\u5185\u6838\u7ea7\u522b\u7684\u6a21\u5757\uff0c\u5b83\u53ea\u662f\u4e00\u4e2a\u6570\u636e\u5e73\u9762\uff0c\u81f3\u4e8e\u4e0a\u5c42\u7684\u66f4\u9ad8\u7ea7\u7684\u529f\u80fd\uff0c\u6bd4\u5982\u79d8\u94a5\u4ea4\u6362\u673a\u5236\uff0cUDP\u6253\u6d1e\uff0cACL\u7b49\uff0c\u9700\u8981\u901a\u8fc7\u7528\u6237\u7a7a\u95f4\u7684\u5e94\u7528\u6765\u5b9e\u73b0\u3002<\/p>\n\n\n\n<p>Tailscale\u5c31\u662f\u57fa\u4e8eWireguard\u7684\u4e00\u4e2a\u8054\u7f51\u5de5\u5177\uff0c\u65e0\u9700\u516c\u7f51\u5730\u5740\uff0c\u901a\u8fc7\u53bb\u4e2d\u5fc3\u5316\uff0c\u5b9e\u73b0\u5404\u4e2a\u8282\u70b9\u4e4b\u95f4\u70b9\u5bf9\u70b9\u7684\u8fde\u63a5\u3002\u914d\u7f6e\u7b80\u5355\u53cb\u597d\uff0c\u652f\u6301\u7684\u5404\u7c7b\u5e73\u53f0\u548c\u5ba2\u6237\u7aef\u3002\u4e0b\u9762\u4ecb\u7ecd\u5728OpenWrt\u4e0a\u7684\u914d\u7f6e\u8fc7\u7a0b\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"548\" src=\"http:\/\/iqotom.com\/wp-content\/uploads\/2023\/03\/image-1024x548.png?v=1678262899\" alt=\"\" class=\"wp-image-1880\" srcset=\"http:\/\/iqotom.com\/wp-content\/uploads\/2023\/03\/image-1024x548.png?v=1678262899 1024w, http:\/\/iqotom.com\/wp-content\/uploads\/2023\/03\/image-300x160.png?v=1678262899 300w, http:\/\/iqotom.com\/wp-content\/uploads\/2023\/03\/image-768x411.png?v=1678262899 768w, http:\/\/iqotom.com\/wp-content\/uploads\/2023\/03\/image-660x353.png?v=1678262899 660w, http:\/\/iqotom.com\/wp-content\/uploads\/2023\/03\/image.png?v=1678262899 1634w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><strong>1\u3001\u4e0b\u8f7d\u8f6f\u4ef6<\/strong><\/p>\n\n\n\n<p>\u5c06Tailscale\u8f6f\u4ef6\u5305\u4e0b\u8f7d\u5230\u6307\u5b9a\u76ee\u5f55\u3002\u5355\u51fb<a href=\"https:\/\/github.com\/adyanth\/openwrt-tailscale-enabler\">\u8fd9\u91cc<\/a>\uff0c\u627e\u5230\u6700\u65b0\u7684\u8f6f\u4ef6\u5305\uff0c\u4e0b\u8f7d\u5230\u672c\u5730\u3002\u7136\u540e\u4f7f\u7528Winscp\u5de5\u5177\u5c06\u4e0b\u8f7d\u7684\u8f6f\u4ef6\u4e0a\u4f20\u5230OpenWrt\u7684\/tmp\u76ee\u5f55\u4e0b\uff0c\u4e5f\u53ef\u4ee5\u627e\u5230\u4e0b\u8f7d\u94fe\u63a5\uff0c\u76f4\u63a5\u4f7f\u7528wget\u547d\u4ee4\u4e0b\u8f7d\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">wget https:\/\/github.com\/adyanth\/openwrt-tailscale-enabler\/releases\/download\/v1.36.1-fb2f6cf-autoupdate\/openwrt-tailscale-enabler-v1.36.1-fb2f6cf-autoupdate.tgz<\/code><\/pre>\n\n\n\n<p><strong>2\u3001\u89e3\u538b\u7f29\u8f6f\u4ef6<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">tar x -zvC \/ -f openwrt-tailscale-enabler-v1.36.1-fb2f6cf-autoupdate.tgz<\/code><\/pre>\n\n\n\n<p><strong>3\u3001\u5b89\u88c5\u4f9d\u8d56\u5305<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">opkg update\nopkg install libustream-openssl ca-bundle kmod-tun<\/code><\/pre>\n\n\n\n<p><strong>4\u3001\u8bbe\u7f6e\u5f00\u673a\u542f\u52a8\uff0c\u9a8c\u8bc1\u5f00\u673a\u542f\u52a8<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">\/etc\/init.d\/tailscale enable\nls \/etc\/rc.d\/S*tailscale*<\/code><\/pre>\n\n\n\n<p><strong>5\u3001\u542f\u52a8tailscale<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">\/etc\/init.d\/tailscale start<\/code><\/pre>\n\n\n\n<p><strong>6\u3001\u83b7\u53d6\u767b\u5f55\u94fe\u63a5\uff0c\u914d\u7f6e\u8def\u7531<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">tailscale up<\/code><\/pre>\n\n\n\n<p>\u590d\u5236\u663e\u793a\u7684\u5730\u5740\uff0c\u5e76\u5728\u6d4f\u89c8\u5668\u4e2d\u6253\u5f00\uff0c\u4f7f\u7528\u8c37\u6b4c\u6216\u5fae\u8f6f\u5e10\u53f7\u767b\u5f55Tailscale\u7684\u7ba1\u7406\u4e3b\u9875\u8fdb\u884c\u9a8c\u8bc1\u3002<\/p>\n\n\n\n<p><strong>7\u3001\u5f00\u542f\u5b50\u7f51\u7f51\u8def\u7531<\/strong><\/p>\n\n\n\n<p>\u5728OpenWrt\u4e0a\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff0c\u6253\u5f00\u672c\u5730\u5b50\u8def\u7531\u3002\u5b50\u7f51\u5730\u5740\u662fOpenWrt\u7684lan\u7f51\u7edc\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">tailscale up --accept-routes --accept-dns=false --advertise-routes=192.168.100.0\/24 <\/code><\/pre>\n\n\n\n<ul>\n<li><code>--netfilter-mode=off<\/code>&nbsp;\u5173\u95ed\u81ea\u52a8\u6dfb\u52a0\u9632\u706b\u5899\u529f\u80fd\uff0c\u56e0\u4e3a\u8be5\u529f\u80fd\u4f1a\u5f71\u54cd\u65b0\u7248\u672c\u7684\u9632\u706b\u5899\u914d\u7f6e\u3002<\/li>\n\n\n\n<li><code>--accept-dns=false<\/code>&nbsp;\u5173\u95ed\u63a5\u53d7 dns \u901a\u544a\uff0c\u4e0d\u63a5\u53d7\u670d\u52a1\u5668\u7684dns\u3002<\/li>\n\n\n\n<li><code>--accept-routes<\/code>\u63a5\u53d7\u5176\u4ed6\u5b50\u7f51\u8def\u7531\u5668\u4ee5\u53ca\u4f5c\u4e3a\u5b50\u7f51\u8def\u7531\u5668\u7684\u4efb\u4f55\u5176\u4ed6\u8282\u70b9\u7684\u901a\u544a\u8def\u7531\u3002<\/li>\n\n\n\n<li><code>--advertisse-routes<\/code>&nbsp;\u5c06\u7269\u7406\u5b50\u7f51\u8def\u7531\u516c\u5f00\u5230\u6574\u4e2a Tailscale \u7f51\u7edc\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u5728Tailscale\u7684\u7ba1\u7406\u9875\u9762\u4e0a\uff0c\u5355\u51fb\u8bbe\u5907\u5217\u8868\u53f3\u4fa7\u7684\u66f4\u591a\u56fe\u6807\uff0c\u7981\u7528\u5bc6\u94a5\u8fc7\u671f\uff0c\u5e76\u6253\u5f00\u5b50\u7f51\u8def\u7531\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"163\" src=\"http:\/\/iqotom.com\/wp-content\/uploads\/2023\/03\/tailscale_01-1024x163.jpg\" alt=\"\" class=\"wp-image-1934\" srcset=\"http:\/\/iqotom.com\/wp-content\/uploads\/2023\/03\/tailscale_01-1024x163.jpg 1024w, http:\/\/iqotom.com\/wp-content\/uploads\/2023\/03\/tailscale_01-300x48.jpg 300w, http:\/\/iqotom.com\/wp-content\/uploads\/2023\/03\/tailscale_01-768x122.jpg 768w, http:\/\/iqotom.com\/wp-content\/uploads\/2023\/03\/tailscale_01-660x105.jpg 660w, http:\/\/iqotom.com\/wp-content\/uploads\/2023\/03\/tailscale_01.jpg 1144w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"506\" height=\"262\" src=\"http:\/\/iqotom.com\/wp-content\/uploads\/2023\/03\/tailscale_01_1.jpg\" alt=\"\" class=\"wp-image-1935\" srcset=\"http:\/\/iqotom.com\/wp-content\/uploads\/2023\/03\/tailscale_01_1.jpg 506w, http:\/\/iqotom.com\/wp-content\/uploads\/2023\/03\/tailscale_01_1-300x155.jpg 300w\" sizes=\"(max-width: 506px) 100vw, 506px\" \/><\/figure>\n\n\n\n<p class=\"has-medium-font-size\"><strong>\u8fd9\u6b65\u5b8c\u6210\u540e\u6b63\u5e38\u7684\u8bdd\u8282\u70b9\u4e4b\u95f4\u5df2\u7ecf\u4e92\u901a\u4e86\uff0c\u4e0d\u901a\u7684\u540c\u5b66\u53ef\u4ee5\u5c1d\u8bd5\u7ee7\u7eed\u8bbe\u7f6e\u7b2c8\u30019\u6b65\u3002<\/strong><\/p>\n\n\n\n<p><strong>8\u3001\u6dfb\u52a0\u63a5\u53e3<\/strong><\/p>\n\n\n\n<p>\u5728OpenWrt\u4e0a\u65b0\u5efa\u4e00\u4e2a\u63a5\u53e3\uff0c\u534f\u8bae\u9009\u9759\u6001\u5730\u5740\uff0c\u8bbe\u5907\u9009tailscale0\uff0c\u5730\u5740\u4e3aTaliscale\u7ba1\u7406\u9875\u9762\u4e0a\u5206\u914d\u7684\u5730\u5740\uff0c\u63a9\u7801255.0.0.0\u3002\u9632\u706b\u5899\u533a\u57df\u9009lan\u533a\u57df\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"686\" height=\"529\" src=\"http:\/\/iqotom.com\/wp-content\/uploads\/2023\/03\/tailscale_02_1.jpg\" alt=\"\" class=\"wp-image-1940\" srcset=\"http:\/\/iqotom.com\/wp-content\/uploads\/2023\/03\/tailscale_02_1.jpg 686w, http:\/\/iqotom.com\/wp-content\/uploads\/2023\/03\/tailscale_02_1-300x231.jpg 300w, http:\/\/iqotom.com\/wp-content\/uploads\/2023\/03\/tailscale_02_1-660x509.jpg 660w\" sizes=\"(max-width: 686px) 100vw, 686px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"987\" height=\"216\" src=\"http:\/\/iqotom.com\/wp-content\/uploads\/2023\/03\/tailscale_04.jpg\" alt=\"\" class=\"wp-image-1938\" srcset=\"http:\/\/iqotom.com\/wp-content\/uploads\/2023\/03\/tailscale_04.jpg 987w, http:\/\/iqotom.com\/wp-content\/uploads\/2023\/03\/tailscale_04-300x66.jpg 300w, http:\/\/iqotom.com\/wp-content\/uploads\/2023\/03\/tailscale_04-768x168.jpg 768w, http:\/\/iqotom.com\/wp-content\/uploads\/2023\/03\/tailscale_04-660x144.jpg 660w\" sizes=\"(max-width: 987px) 100vw, 987px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"778\" height=\"216\" src=\"http:\/\/iqotom.com\/wp-content\/uploads\/2023\/03\/tailscale_03.jpg\" alt=\"\" class=\"wp-image-1937\" srcset=\"http:\/\/iqotom.com\/wp-content\/uploads\/2023\/03\/tailscale_03.jpg 778w, http:\/\/iqotom.com\/wp-content\/uploads\/2023\/03\/tailscale_03-300x83.jpg 300w, http:\/\/iqotom.com\/wp-content\/uploads\/2023\/03\/tailscale_03-768x213.jpg 768w, http:\/\/iqotom.com\/wp-content\/uploads\/2023\/03\/tailscale_03-660x183.jpg 660w\" sizes=\"(max-width: 778px) 100vw, 778px\" \/><\/figure>\n\n\n\n<p><strong>9\u3001\u6dfb\u52a0\u9632\u706b\u5899\u89c4\u5219<\/strong><\/p>\n\n\n\n<p>\u5c06\u4ee5\u4e0b\u5185\u5bb9\uff0c\u52a0\u5230\u9632\u706b\u5899\u7684\u81ea\u5b9a\u4e49\u89c4\u5219\u5f53\u4e2d\uff0c\u5e76\u91cd\u542f\u9632\u706b\u5899\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">iptables -I FORWARD -i tailscale0 -j ACCEPT\niptables -I FORWARD -o tailscale0 -j ACCEPT\niptables -t nat -I POSTROUTING -o tailscale0 -j MASQUERADE<\/code><\/pre>\n\n\n\n<p>\n\n\u73b0\u5728\u5404\u4e2aTailscale\u8282\u70b9\u4e4b\u95f4\u5df2\u7ecf\u53ef\u4ee5\u6b63\u5e38\u4e92\u8bbf\u4e86\u3002\n\n<\/p>\n\n\n\n<p class=\"has-medium-font-size\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u9047\u5230\u7684\u4e00\u4e9b\u9519\u8bef\uff0c\u53ca\u89e3\u51b3<\/h2>\n\n\n\n<p>1\u3001\u5b89\u88c5kmod-tun\u5931\u8d25\uff0c\u7248\u672c\u4e0e\u5185\u6838\u4e0d\u5339\u914d\uff0c\u4e00\u822c\u53ef\u4ee5\u4e0d\u5fc5\u7406\u4f1a\uff0c\u7cfb\u7edf\u81ea\u5e26\uff0c\u5efa\u8bae\u56fa\u4ef6\u7248\u672c\u4e0d\u8981\u592a\u8001<\/p>\n\n\n\n<p>2\u3001\u670d\u52a1\u542f\u52a8\u4e0d\u4e86<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">failed to connect to local tailscaled (which appears to be running as tailscaled, pid 9773). Got error: Failed to connect to local Tailscale daemon for \/localapi\/v0\/status; not running? Error: dial unix \/var\/run\/tailscale\/tailscaled.sock: connect: no such file or directory<\/code><\/pre>\n\n\n\n<p>\u53ef\u4ee5\u6740\u6b7b\u8fdb\u7a0b\uff0c\u6216\u8005\u6267\u884c\u4ee5\u4e0b\u6307\u4ee4 tailscale down\uff0c tailscale logout\uff0c\u7136\u540e\u91cd\u65b0\u542f\u52a8tailscale up<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>\u8f6c\u81ea\uff1a <a href=\"https:\/\/pfschina.org\/wp\/?p=9151\">OpenWrt\u5b89\u88c5\u914d\u7f6eTailscale | \u9435\u8840\u7537\u5152\u7684BLOG (pfschina.org)<\/a> <\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5f53\u524d\u5bf9\u5bb6\u5ead\u5bbd\u5e26\u800c\u8a00\uff0c\u53ef\u4ee5\u4f7f\u7528\u7684IPv4\u516c\u7f51IP\u8d8a\u6765\u8d8a\u5c11\uff0c\u8bbf\u95ee\u5bb6\u5ead\u5185\u7f51\u7684\u8d44\u6e90\u5c06\u4f1a\u53d8\u5f97\u8d8a\u6765\u8d8a\u56f0\u96be\u3002\u90e8\u5206\u7f51\u53cb\u53ef\u80fd\u4f1a\u9009\u2026 <span class=\"read-more\"><a href=\"http:\/\/iqotom.com\/?p=1873\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":1875,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,6],"tags":[133,134],"_links":{"self":[{"href":"http:\/\/iqotom.com\/index.php?rest_route=\/wp\/v2\/posts\/1873"}],"collection":[{"href":"http:\/\/iqotom.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/iqotom.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/iqotom.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/iqotom.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1873"}],"version-history":[{"count":15,"href":"http:\/\/iqotom.com\/index.php?rest_route=\/wp\/v2\/posts\/1873\/revisions"}],"predecessor-version":[{"id":2051,"href":"http:\/\/iqotom.com\/index.php?rest_route=\/wp\/v2\/posts\/1873\/revisions\/2051"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/iqotom.com\/index.php?rest_route=\/wp\/v2\/media\/1875"}],"wp:attachment":[{"href":"http:\/\/iqotom.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1873"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/iqotom.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1873"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/iqotom.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1873"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}