上次介绍过小米 WR30U 今年百元价位最有性价比的路由器,搭载了 MT7981B 双核 1.3Ghz 的CPU、128M 的闪存和 256M 的内存,另外信号也非常好,不刷机直接做 Mesh 的 AP 就很好用。今天看到 openwrt 社区分享了免拆机解锁 SSH 的方法,就写个教程分享下。
在开始前还是先感谢下:
- openwrt 社区:lee320 提供的解锁 SSH 方案
- 恩山论坛: 不死uboot
- 恩山论坛:lean 提供的固件
- 恩山论坛:hank9999 恢复官方教程
准备工作
- 小米 WR30U 路由器
- Windows 电脑(需要同时有网口和无线Wi-Fi)
- 安装 python(推荐在 Windows 商店安装,就不用手动配置环境变量了)
- 下载需要的文件(uboot、python 脚本、openwrt 固件、winSCP)
解锁 SSH
配置准备 wr30u
wr30u 先不需要插网线,电脑提示没有网络没有影响,打开 192.168.31.1 后台,在常用设置-上网设置里分别设置:
- 上网设置 DHCP,自动配置 DNS
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F365fa24c-ed03-4409-838e-c71f747dba6e%2FSnipaste_2023-05-18_00-42-15.png?table=block&id=73a7080c-99bf-4fb8-9e36-bc1025166327&cache=v2)
- 启动与智能网关无线配置同步(会重启)
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F3905a55c-0f3e-4c47-8b8c-cd45294f6089%2FSnipaste_2023-05-18_00-42-55.png?table=block&id=558b3d9d-495b-4fe8-8963-4b68f5aa0370&cache=v2)
- 固定 WAN 口为 1 (会重启)
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F6f1f9a6c-7fa8-48fd-9d8b-abb3d669b001%2FSnipaste_2023-05-18_00-44-20.png?table=block&id=1d363deb-fbbb-43c0-8349-f2afa60f9472&cache=v2)
配置准备电脑
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2Ff289c200-a7bc-471a-ba26-9786795fc78f%2F%25E6%2588%25AA%25E5%25B1%258F2023-05-18_%25E4%25B8%258B%25E5%258D%25885.13.08.jpg?table=block&id=c516b386-24da-496a-a474-99a2f099fbe9&cache=v2)
电脑连接家里已有的能正常上网的 WiFi(不是解锁的 wr30u 的 WiFi),然后将电脑用网线与 wr30u 连接。
打开控制面板-网络和 Internet-网络和共享中心-选择WLAN-点击属性-共享-勾选第一个允许-确认。这个时候 wr30u 应该能连接网络,指数灯也会从黄灯变为蓝色。
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F45c7478b-8722-4fea-825b-6659274e0919%2FSnipaste_2023-05-18_01-03-47.png?table=block&id=b416ece8-6d45-463d-830d-b22edb734cde&cache=v2)
运行脚本解锁
打开系统自带的终端,先输入命令安装下 pycryptodomepip install pycryptodome
再运行脚本,输入 python 再将解压好的 server_emulator.py 文件拖进终端即可,回车执行。python server_emulator.py
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F9e94874f-0198-4628-88c1-d182ecf3abe6%2FSnipaste_2023-05-18_01-24-06.png?table=block&id=54e2b0fb-c7a2-4e61-8a09-4f2de3f28446&cache=v2)
执行需要等待一分钟左右,看到 Device information 和 finish 就完成了,现在 wr30 就打开了 ssh,默认的用户名是 root 密码是 admin。
尝试 ssh 连接
现在可以把 wr30u 和电脑间的网线断开,电脑连接 wr30u 的WiFi 即可,不要断电重启 wr30u 不然目前 ssh 会掉需要重新执行脚本。
在终端里尝试 ssh 连接 wr30ussh root@192.168.31.1
如果有“WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!”提示,是你之前连接过别的小米路由器的记录,执行下这个即可。ssh-keygen -R 192.168.31.1
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2Ff02e95d8-238a-4d4c-b4e8-73e1d00b72a3%2FSnipaste_2023-05-18_02-15-59.png?table=block&id=ada28659-f760-4817-8ad0-f7501073beb4&cache=v2)
输入密码不会显示,输完直接回车执行即可,就能看到熟悉的 ARE U OK 了,如果需要固化 ssh 可以执行以下命令(wr30u 需要联网),不然重启后 SSH 会掉,直接刷 openwrt 的话就可以跳过。mkdir /data/auto_ssh && cd /data/auto_ssh curl -O https://cdn.jsdelivr.net/gh/lemoeo/AX6S@main/auto_ssh.sh chmod +x auto_ssh.sh uci set firewall.auto_ssh=include uci set firewall.auto_ssh.type='script' uci set firewall.auto_ssh.path='/data/auto_ssh/auto_ssh.sh' uci set firewall.auto_ssh.enabled='1' uci commit firewall
刷入 uboot
可以选择手动用 WinSCP 上传 uboot,或者 wr30u 联网执行脚本。二选一
手动上传刷入 uboot
下载安装好 WinSCP 打开,我们要将下载的 uboot 文件上传到路由器的 /tmp 路径。选择新建会话,文件协议 SCP,主机名:192.168.31.1,端口 22,用户名:root,选择登录。会让你输入密码:password。
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F90ffb3ee-c3e4-4cdd-ad1f-ff43cb04a5c4%2FSnipaste_2023-05-18_02-49-47.png?table=block&id=ff9ebc7c-ac5d-42bd-ad54-21d6556bd5dd&cache=v2)
然后左边是你的电脑右边是路由器,将下载好的 mt7981_xiaomi_wr30u-u-boot.fip 文件从左边电脑拖进右边路由器的 /tmp 文件夹路径。
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F31a383b1-c6e6-4fcd-b83b-44680353c1db%2FSnipaste_2023-05-18_02-50-48.png?table=block&id=84e79c40-c8cc-4936-8f66-851273754522&cache=v2)
再到终端里执行以下命令(图片里的 mtd5 优化为了 FIP,按文字版的命令运行即可)cd /tmp mtd write mt7981_xiaomi_wr30u-u-boot.fip FIP
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F9346df7f-1aff-448e-a897-b91e08b5c949%2FSnipaste_2023-05-18_02-48-16.png?table=block&id=27fc41a3-4333-4dff-8b8b-dc77a8c3ec70&cache=v2)
看到如图所示的结果就说明刷入 uboot 成功了。
联网刷入 uboot
或者将 WR30U 联网直接执行下面脚本,就能完成 uboot 的下载刷入。cd /tmp curl -L https://share.qust.me/d/%E8%B7%AF%E7%94%B1%E5%99%A8/WR30U/mt7981_xiaomi_wr30u-u-boot.fip -o mt7981_xiaomi_wr30u-u-boot.fip mtd write mt7981_xiaomi_wr30u-u-boot.fip FIP
如图:
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F7ac06dde-e3b8-45cc-bc3e-5fe0fe4cd5e1%2FSnipaste_2023-05-18_16-20-51.png?table=block&id=efda9816-47db-4040-8cea-7244f7df66f1&cache=v2)
刷入 openwrt 固件
路由器断电后,用针按住 reset 不放,再接上电源,等待 10s 左右松开,就能进入 uboot。电脑用网线和 wr30u 的网口1连接,电脑在网络设置里将以太网设置为静态。IP地址:192.168.1.2,子网掩码:255.255.255.0,网关:192.168.1.1,首选 DNS:192.168.1.1,最后保存。
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2Fb6918e2a-a4c0-4d1b-88c7-e8b424880c00%2FSnipaste_2023-05-18_16-40-52.png?table=block&id=bb2fe35f-e2a9-4c0a-a9f2-90938f594a32&cache=v2)
现在就能打开 192.168.1.1 uboot 的后台。
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F27387e6a-c304-46d4-9ee9-913459ebf9ec%2FSnipaste_2023-05-18_16-41-12.png?table=block&id=07e5a1ab-cca9-4743-aa27-526346478b2e&cache=v2)
现在选择下载好的 openwrt 固件,upload 后 update 更新即可,刷写完成系统会重启进入 openwrt 的系统。(如果没有重启可以尝试重新上传刷入)
新的系统默认 WiFi 是 QWRT,没有密码,后台是 192.168.1.1,默认用户名:root,密码:passwrod。
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2Fc164389b-b4c9-490f-91f2-7938ca9ade89%2FSnipaste_2023-05-18_16-48-03.png?table=block&id=f529a4f6-0c75-4055-81bd-3a0184c05a53&cache=v2)
当然别的 openwrt 固件也可以同样在 uboot 下刷入。
OPENWRT 基本设置
如果你的光猫或上级路由器后台也是 192.168.1.1 需要在 openwrt 的后台-网络-接口-LAN修改,将192.168.1.1 修改为 192.168.6.1(当然6可以是1-255 之间你喜欢的数)
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F1c210c17-0b3d-446f-85ba-750b9dbcbbc7%2FSnipaste_2023-05-18_16-51-21.png?table=block&id=1b14b959-f6d6-44bb-bd12-2d5607c23973&cache=v2)
WiFi 的名字和密码在网络-无线-修改里,按照图示例即可修改:
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F599dbe6f-6fac-4875-bb8f-75ba912eaa90%2FSnipaste_2023-05-18_16-54-15.png?table=block&id=5f5bf3f4-c61f-485e-a66f-696d82177ac2&cache=v2)
如果需要拨号上网:在网络-接口-wan修改-协议改为 PPPoE,并填写上账户和密码即可:
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F981e4196-0a4b-42ac-9b3d-48ef265f5f6f%2FSnipaste_2023-05-18_16-58-21.png?table=block&id=1f440157-bb9b-43ee-8b43-adaf32074dd2&cache=v2)
刷回官方
刷完上面的 uboot 后会变为大分区,刷回官方需要先刷兼容原厂分区的 uboot,再从 uboot 刷入官方的固件。
在 openwrt 的 TTYD 终端里执行(不联网也可以手动下载上传刷入):cd /tmp curl -L https://share.qust.me/d/%E8%B7%AF%E7%94%B1%E5%99%A8/WR30U/%E5%88%B7%E5%9B%9E%E5%AE%98%E6%96%B9/mt7981_xiaomi_wr30u-fip-stock-fixed-parts.bin -o mt7981_xiaomi_wr30u-fip-stock-fixed-parts.bin mtd write mt7981_xiaomi_wr30u-fip-stock-fixed-parts.bin FIP
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F07c45226-0173-427b-90a2-7ef55c928b2b%2FScreenshot_2023-05-25_at_5.20.28_PM.jpg?table=block&id=45376872-8b4d-40e3-95da-d465f83f7fa6&cache=v2)
就完成了官方分区 uboot 的输入,再进入 uboot,上传下载的 mtd8 固件刷入即可。
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F3d403ca8-d1ed-4272-b75e-835af48a01ce%2FScreenshot_2023-05-25_at_5.25.21_PM.jpg?table=block&id=989b8032-4766-48b8-9f35-b517b340885f&cache=v2)
最后,在官方固件里推荐恢复下出厂设置。
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F61d33703-72ea-42a2-bd60-524af882c809%2FScreenshot_2023-05-25_at_5.30.00_PM.jpg?table=block&id=00345c8b-9689-4784-b081-bce19a0845bd&cache=v2)
总结
wr30u 和 360t7 配置几乎一模一样,但做工更好也能免拆刷机,不过渠道上 wr30u 价格要贵好几十,如果追求极致性价比 360t7 当然更值得买。