{"id":426,"date":"2013-09-27T22:53:22","date_gmt":"2013-09-27T14:53:22","guid":{"rendered":"http:\/\/blog.361.xxx\/?p=426"},"modified":"2013-09-27T22:53:22","modified_gmt":"2013-09-27T14:53:22","slug":"%e5%9f%ba%e4%ba%8eopenwrt%e8%b7%af%e7%94%b1%e5%99%a8%e7%9a%84ipv6-ssh-tunnel%e8%a7%a3%e5%86%b3%e6%96%b9%e6%a1%88","status":"publish","type":"post","link":"http:\/\/www.cyups.com\/?p=426","title":{"rendered":"\u57fa\u4e8eOpenWRT\u8def\u7531\u5668\u7684IPv6 SSH Tunnel\u89e3\u51b3\u65b9\u6848"},"content":{"rendered":"<p>\u5bd2\u5047\u7684\u65f6\u5019\u5165\u4e86\u4e00\u53f0<code>Linksys WRT54G<\/code>\uff0c\u5e76\u5c06\u5176\u5237\u6210\u4e86<code>OpenWRT<\/code>\u7cfb\u7edf\uff0c\u5f00\u5b66\u4e4b\u540e\u8003\u8651\u5230\u86cb\u75bc\u7684\u6821\u56ed\u7f51\u8ba4\u8bc1\u7cfb\u7edf\uff0c\u6253\u7b97\u5728\u8def\u7531\u5668\u4e0a\u642d\u5efa\u57fa\u4e8eIPv6\u7684SSH Tunnel\uff0c\u7528\u6765\u7ed9\u79fb\u52a8\u8bbe\u5907\u63d0\u4f9b\u7f51\u7edc\u63a5\u5165\u4ee5\u53ca\u5916\u7f51\u4ee3\u7406\u670d\u52a1\u3002<br \/>\n<img decoding=\"async\" alt=\"\" src=\"http:\/\/ichon.me\/uploads\/2012\/03\/openwrt-logo.png\" \/><\/p>\n<h2>\u51c6\u5907\u5de5\u4f5c<\/h2>\n<p><em>\u9700\u8981<\/em><\/p>\n<ul>\n<li>\u539f\u751fIPv6\u7f51\u7edc<\/li>\n<li>\u4e00\u53f0\u5237\u4e86OpenWRT\u7cfb\u7edf\u7684\u8def\u7531\u5668<\/li>\n<li>\u4e00\u53f0\u7c73\u56fd\u7684\u670d\u52a1\u5668\uff0c\u9700\u8981IPv6\u652f\u6301\u4ee5\u53caSSH\u5e10\u53f7<\/li>\n<\/ul>\n<p><!--more--><\/p>\n<h2>\u7ed9OpenWRT\u589e\u52a0IPv6\u652f\u6301<\/h2>\n<p>\u5173\u4e8eOpenWRT\u4e0a\u7684IPv6\u914d\u7f6e\uff0c\u53ef\u4ee5\u53c2\u8003OpenWRT\u7684\u5b98\u65b9wiki <a href=\"http:\/\/wiki.openwrt.org\/doc\/howto\/ipv6.essentials\" target=\"_blank\"  rel=\"nofollow\" >http:\/\/wiki.openwrt.org\/doc\/howto\/ipv6.essentials<\/a><br \/>\n\u7b80\u800c\u8a00\u4e4b\uff0c\u901a\u8fc7SSH\u767b\u5f55\u5230OpenWRT\uff0c\u7136\u540e\u4f7f\u7528opkg\u5b89\u88c5IPv6\u6a21\u5757<br \/>\n<code>root@OpenWrt:\/# opkg install kmod-ipv6<\/code><br \/>\n\u7136\u540e\u91cd\u542fnetwork\u670d\u52a1<br \/>\n<code>root@OpenWrt:\/# \/etc\/init.d\/network restart<\/code><br \/>\n\u8fd9\u65f6\uff0c\u4f7f\u7528<code>ifconfig<\/code>\u547d\u4ee4\u5e94\u8be5\u80fd\u591f\u770b\u5230\u6210\u529f\u83b7\u53d6IPv6\u5730\u5740\u4e86<\/p>\n<h2>\u914d\u7f6eSSH\u7684\u514d\u5bc6\u7801\u767b\u5f55<\/h2>\n<p>\u6709\u4e86IPv6\uff0c\u5e94\u8be5\u80fd\u901a\u8fc7SSH\u76f4\u63a5\u8fde\u63a5\u5230\u670d\u52a1\u5668\u800c\u4e0d\u7528\u7ecf\u8fc7\u6821\u56ed\u7f51\u7684\u8ba4\u8bc1\uff0c\u7136\u800c\uff0c\u4e3a\u4e86\u8ba9\u8def\u7531\u5668\u5b9e\u73b0\u81ea\u52a8\u767b\u5f55\uff0cSSH\u7684\u514d\u5bc6\u7801\u767b\u5f55\u5f53\u7136\u662f\u5fc5\u987b\u7684\u4e86\u3002<br \/>\n\u800cOpenWRT\u4e0a\u9ed8\u8ba4\u7684SSH\u662fDropbear\uff0c\u914d\u7f6e\u65b9\u6cd5\u548c\u901a\u5e38\u4f7f\u7528\u7684OpenSSH\u6709\u6240\u4e0d\u540c\u3002<\/p>\n<h3>\u4f7f\u7528Dropbear\u751f\u6210<code>Public Key<\/code><\/h3>\n<p><code>dropbearkey -t rsa -f \/etc\/dropbear\/dropbear_rsa_host_key &gt; id_rsa.pub<\/code><br \/>\n\u7136\u540e\u4f7f\u7528vi\u7f16\u8f91\u4e00\u4e0b\u751f\u6210\u7684<code>id_rsa.pub<\/code>\uff0c\u5220\u9664\u6389\u7b2c\u4e00\u884c\u548c\u7b2c\u4e09\u884c\uff0c\u53ea\u7559\u4e0b\u4ee5<code>ssh-rsa<\/code>\u5f00\u5934\u7684\u7b2c\u4e8c\u884c\uff0c\u8fd9\u624d\u662f\u6211\u4eec\u9700\u8981\u7684<code>Public Key<\/code><\/p>\n<h3>\u5c06<code>Public Key<\/code>\u4e0a\u4f20\u5230\u670d\u52a1\u5668<\/h3>\n<p><code>scp id_rsa.pub root@server:id_rsa.pub<\/code><\/p>\n<h3>\u5c06<code>Public Key<\/code>\u5bfc\u5165\u5230<code>authorized_keys<\/code><\/h3>\n<p>\u767b\u5f55\u5230\u670d\u52a1\u5668\uff0c\u7136\u540e\u6267\u884c<br \/>\n<code>cat id_rsa.pub &gt;&gt; ~\/.ssh\/authorized_keys<\/code><\/p>\n<h3>\u6d4b\u8bd5\u4e00\u4e0b\u514d\u5bc6\u7801\u767b\u5f55<\/h3>\n<p><code>ssh -i \/etc\/dropbear\/dropbear_rsa_host_key root@server<\/code><br \/>\n\u5982\u679c\u80fd\u591f\u76f4\u63a5\u767b\u5f55\u6210\u529f\uff0c\u5c31\u8bf4\u660e\u5df2\u7ecf\u914d\u7f6e\u6210\u529f<\/p>\n<h2>OpenWRT\u7aef\u7684\u7aef\u53e3\u8f6c\u53d1\u914d\u7f6e<\/h2>\n<p>\u65e2\u7136\u8981\u4f7f\u7528SSH Tunnel\u4f5c\u4e3asocks\u4ee3\u7406\uff0c\u7aef\u53e3\u8f6c\u53d1\u662f\u5fc5\u987b\u7684\u4e86\uff0c\u800cDropbear\u4e0d\u652f\u6301\u52a8\u6001\u7aef\u53e3\u8f6c\u53d1(Dynamic Port Forwarding)\uff0c\u6240\u4ee5\u4f7f\u7528\u9759\u6001\u7aef\u53e3\u8f6c\u53d1\u66ff\u4ee3<br \/>\n\u5728<code>\/etc\/init.d<\/code>\u91cc\u65b0\u5efa\u4e00\u4e2a\u670d\u52a1\uff0c\u547d\u540d\u4e3a<code>sockstunnel(\/etc\/init.d\/sockstunnel)<\/code>\uff0c\u5176\u4f5c\u7528\u662f\u5728192.168.1.1:70070\u8fdb\u884c\u76d1\u542c\uff0c\u7136\u540e\u5c06\u8fd9\u4e2a\u7aef\u53e3\u7684\u6240\u6709\u6570\u636e\u901a\u8fc7SSH Tunnel\u9759\u6001\u8f6c\u53d1\u5230\u670d\u52a1\u5668\u76847070\u7aef\u53e3<\/p>\n<pre>#!\/bin\/sh \/etc\/rc.common\nSTART=85\nSTOP=5\nDAEMON=\/usr\/bin\/ssh\nPIDFILE=\/var\/run\/sockstunnel.pid\nstart() {\necho -n \"Start Socks Tunnel Daemon: \"\nstart-stop-daemon -S -b -q -m -p $PIDFILE -x $DAEMON\n-- -i \/etc\/dropbear\/dropbear_rsa_host_key -g -N -L 192.168.1.1:7070:localhost:7070 root@server\necho -n \"Socks Tunnel Daemon Started.\"\n}\nstop() {\nif [ -f $PIDFILE ]; then\nPID=$(cat $PIDFILE)\nkill $PID\nwhile [ -d \/proc\/$PID ];\ndo\nsleep 1\ndone\nfi\nrm -rf $PIDFILE\necho -n \"Socks Tunnel Daemon Stoped.\"\n}<\/pre>\n<h2>\u670d\u52a1\u5668\u7aef\u7684\u7aef\u53e3\u8f6c\u53d1\u914d\u7f6e<\/h2>\n<p>sockstunnel\u7684\u4f5c\u7528\u4ec5\u4ec5\u662f\u5c06\u6570\u636e\u901a\u8fc7\u6211\u4eec\u5efa\u7acb\u7684SSH Tunnel\u9759\u6001\u8f6c\u53d1\u5230\u670d\u52a1\u5668\u76847070\u7aef\u53e3\uff0c\u800c\u7f51\u7edc\u5e94\u7528\u5374\u53ef\u80fd\u4f7f\u7528\u5230\u5404\u79cd\u7aef\u53e3\uff0c\u663e\u7136\u4e0d\u53ef\u80fd\u4e3a\u6bcf\u4e00\u4e2a\u5e94\u7528\u5355\u72ec\u914d\u7f6e\u7aef\u53e3\u8f6c\u53d1\uff0c\u56e0\u6b64\uff0c\u5c31\u8981\u4f7f\u7528\u5230\u670d\u52a1\u5668\u7aef\u7684\u52a8\u6001\u7aef\u53e3\u8f6c\u53d1\u3002<br \/>\n\u767b\u5f55\u5230\u670d\u52a1\u5668\uff0c\u6267\u884c\u547d\u4ee4<br \/>\n<code>ssh -qTfnN -D 7070 root@localhost<\/code><br \/>\n\u6548\u679c\u662f\u57287070\u7aef\u53e3\u8fdb\u884c\u76d1\u542c\uff0c\u5c06OpenWRT\u8def\u7531\u5668\u901a\u8fc7SSH Tunnel\u9759\u6001\u8f6c\u53d1\u7684\u6570\u636e\u518d\u52a8\u6001\u8f6c\u53d1\u51fa\u53bb\u3002<br \/>\n\u8fd9\u5176\u5b9e\u662f\u4e00\u79cd\u8fc2\u56de\u7684\u65b9\u6848\uff0c\u56e0\u4e3aOpenWRT\u4e0a\u7684Dropbear\u4e0d\u652f\u6301\u52a8\u6001\u7aef\u53e3\u8f6c\u53d1\uff0c\u5c31\u5148\u5c06\u6570\u636e\u901a\u8fc7SSH Tunnel\u9759\u6001\u8f6c\u53d1\u5230\u670d\u52a1\u5668\uff0c\u7136\u540e\u518d\u5728\u670d\u52a1\u5668\u8fdb\u884c\u52a8\u6001\u7aef\u53e3\u8f6c\u53d1\u3002<br \/>\n\u4e0b\u56fe\u5e94\u8be5\u53ef\u4ee5\u5f88\u597d\u5730\u89e3\u91ca\u5176\u4e2d\u7684\u539f\u7406\uff1a<br \/>\n<img decoding=\"async\" alt=\"\" src=\"http:\/\/ichon.me\/uploads\/2012\/03\/ssh_tunnel_with_openwrt.png\" \/><br \/>\n\u5982\u679c\u4f60\u7684OpenWRT\u8def\u7531\u5668Flash\u5b58\u50a8\u5668\u5bb9\u91cf\u8db3\u591f\u5927\uff0c\u5219\u5b8c\u5168\u53ef\u4ee5\u5728OpenWRT\u4e0a\u5b89\u88c5OpenSSH\u76f4\u63a5\u4f7f\u7528\u52a8\u6001\u8f6c\u53d1\uff0c\u800c\u6ca1\u5fc5\u8981\u50cf\u6211\u8fd9\u4e48\u505a\u4e86\u3002<\/p>\n<h2>\u542f\u52a8\/\u505c\u6b62SSH Tunnel<\/h2>\n<p>\u5728OpenWRT\u4e0a\u53ef\u4ee5\u5f88\u5bb9\u6613\u5730\u542f\u52a8SSH Tunnel\uff0c\u53ea\u9700\u8981\u6267\u884c<br \/>\n<code>\/etc\/init.d\/sockstunnel start<\/code><br \/>\n\u5982\u679c\u9700\u8981\u505c\u6b62\u7684\u8bdd\uff0c\u53ea\u9700\u8981\u6267\u884c<br \/>\n<code>\/etc\/init.d\/sockstunnel stop<\/code><\/p>\n<h2>\u5728\u7ec8\u7aef\u8bbe\u5907\u4e0a\u4f7f\u7528Socks\u4ee3\u7406<\/h2>\n<p>\u5982\u679c\u9700\u8981\u4f7f\u7528Socks\u4ee3\u7406\uff0c\u4ec5\u4ec5\u8fde\u63a5\u5230OpenWRT\u8def\u7531\u5668\u662f\u4e0d\u591f\u7684\uff0c\u8fd8\u9700\u8981\u5728\u8bbe\u5907\u4e0a\u914d\u7f6esocks\u4ee3\u7406\u3002<br \/>\n\u5982\u679c\u4f7f\u7528\u7684\u662f\u7535\u8111\uff0c\u53ea\u9700\u8981\u5c06\u6d4f\u89c8\u5668\u7684socks\u4ee3\u7406\u4fee\u6539\u4e3a\uff1a192.168.1.1:7070\uff0c\u4f46\u662f\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u8fd9\u91cc\u53ea\u80fd\u4f7f\u7528<code>Socks4<\/code>\uff0c\u5982\u679c\u4f7f\u7528Socks5\u5c06\u4f1a\u51fa\u73b0\u62d2\u7edd\u8fde\u63a5\u7684\u72b6\u51b5\u3002<br \/>\n\u5982\u679c\u4f7f\u7528\u7684\u662f\u624b\u673a\uff0c\u6bd4\u5982Android\uff0c\u63a8\u8350\u4f7f\u7528<code>ProxyDroid<\/code>\u8f6f\u4ef6(\u624b\u673a\u9700\u8981\u53d6\u5f97root\u6743\u9650)\uff0c\u53ef\u4ee5\u5f88\u65b9\u4fbf\u5730\u8bbe\u7f6esocks4\u4ee3\u7406\uff0c\u5e76\u4e14\u53ef\u4ee5\u6839\u636e\u5f53\u524d\u8fde\u63a5\u7684\u7f51\u7edc\u81ea\u52a8\u5f00\u542f\/\u5173\u95ed\u4ee3\u7406\uff0c\u5b9e\u73b0\u4e00\u8fde\u63a5\u5230\u8def\u7531\u5668\u4fbf\u81ea\u52a8\u5f00\u542f\u4ee3\u7406\u7684\u6548\u679c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5bd2\u5047\u7684\u65f6\u5019\u5165\u4e86\u4e00\u53f0Linksys WRT54G\uff0c\u5e76\u5c06\u5176\u5237\u6210\u4e86OpenWRT\u7cfb\u7edf\uff0c\u5f00\u5b66\u4e4b\u540e\u8003\u8651\u5230\u86cb\u75bc\u7684\u6821\u56ed\u7f51\u8ba4\u8bc1\u7cfb\u7edf\uff0c\u6253\u7b97\u5728\u8def\u7531\u5668\u4e0a &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"emotion":"","emotion_color":"","title_style":"","license":"","footnotes":""},"categories":[20],"tags":[82,131,193],"class_list":["post-426","post","type-post","status-publish","format-standard","hentry","category-ipv6jishu","tag-dropbear","tag-ipv6-ssh-tunnel","tag-openwrt"],"_links":{"self":[{"href":"http:\/\/www.cyups.com\/index.php?rest_route=\/wp\/v2\/posts\/426","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.cyups.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.cyups.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.cyups.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.cyups.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=426"}],"version-history":[{"count":0,"href":"http:\/\/www.cyups.com\/index.php?rest_route=\/wp\/v2\/posts\/426\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.cyups.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=426"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.cyups.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=426"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.cyups.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=426"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}