小米路由器r3d折腾记录

前言,

买这机子,看中他存储文件能力和牛逼的连接数量,最大卖点。

当然r3p更合适,毕竟便宜且支持第三方。

这R3D型号截止目前20200824还没第三方固件,

本来PandoraBox有可能出一款固件的,但团队被挖走了。

但其本身是openwrt 12.09-rc1老版本。

小米采用web端是sysapihttpd(nginx 1.2.2)基于nginx

小米美化的web界面(位于/usr/lib/lua/luci),其lua文件是加密的。

暂时我还不知道怎么修改去产生新折腾想法……脑子晕圈了一会!

自身是有opkg的,但是opkg安装源12.09-rc1版本太老

芯片用的是高通ipq8064,下面这源已经关闭。

https://archive.openwrt.org/attitude_adjustment/12.09-rc1/ipq806x/generic/packages

再者mt工具箱已停用,折腾的路又少了一条。

为了折腾目录开启开发版ssh,启用ipv6,去除卡慢,开opkg,开webdav代替samba老版本共享。

装备工具:putty 和 winscp,使用方法百度很多,自行脑补。

开ssh照着官方做,一定成功,手不要抖动,真的简单。

http://www1.miwifi.com/miwifi_download.html

记得备份好你的root密码,尽量也不必要修改,免得忘记,让小米给你记住就行了

一、开启IPv6

首先通过下面网址测试你的路由 ipv6 状态

https://www.test-ipv6.com

1.编辑第一步

vi /etc/config/ipv6

打开这样:
config ipv6 'settings'
        list if_off 'wan'
        list if_on 'ipv6'
        option enabled '1'

改成这样:
config ipv6 'settings'
        list if_on 'wan'
        option enabled '1'
        list if_on 'ipv6'
        option enabled '1'

2.编辑第二步,非必要

vi /etc/config/network

找到 config interface 'wan6'
看到这样:
config interface 'wan6'
        option ifname '@wan'
        option proto 'dhcpv6'

添加两行IPv6的DNS
config interface 'wan6'
        option ifname '@wan'
        option proto 'dhcpv6'
        list dns '240c::6666'
        list dns '240c::6644'

3.编辑第三步,启用ipv6外网访问

vi /etc/config/firewall

找到 config defaults,一般是开头那几行。
内容修改成下面这样:
config defaults
	option syn_flood '0'
	option input 'ACCEPT'
	option output 'ACCEPT'
	option forward 'ACCEPT'
	option drop_invalid '0'
	option disable_ipv6 '0'
添加代码,用于v6转发,非必要:
config rule 'mywebsite'
	option name 'Allow-v6-Forward'
	option src 'wan'
	option dest 'lan'
	option proto 'tcp'
	option family 'ipv6'
	option target 'ACCEPT'
或添加代码,仅限80口,非必要:
config rule
	option name 'Allow-v6-Forward'
	option src 'wan'
	option dest 'lan'
	option proto 'tcp'
	option dest_port '80'
	option family 'ipv6'
	option target 'ACCEPT'
	option enabled '1'

IPV6开启操作完毕

二、opkg功能

采用的是第三方entware,开启采用的是一键脚本,这脚本有个特点

安装后,新创一个/opt目录,并且软链接到你的机内硬盘存储(位于/userdisk/data/opt),所以并不占用路由器自身内存。其中/userdisk/data为你的机内硬盘路径。

一键安装命令

curl https://dco.gitee.io/file/openwrt/dco_entware_miwifi_R3D.sh | /bin/sh

以上因为自启动问题和dco.Path不明文件,所以弃用。

https://www.freebasic.cn/p/1522.html

安装完后,你可以使用 opkg install xxx(包名) 安装你要的功能,安装后的内容在opt环境下。

比如以前我们安装的配置文件在/etc/xxx里面,但是现在你安装的配置文件在

/opt/etc/xxx,如此类推,前面多一个opt根路径

有了这,我们接下来安装lighttpd实现webdav功能,我尽量简单地说

首先安装几个必要的包

opkg install lighttpd
opkg install lighttpd-mod-webdav
opkg install lighttpd-mod-auth
opkg install lighttpd-mod-authn_file

创建机内硬盘为存储目录,其中wwwroot你可自定义

mkdir /userdisk/data/wwwroot

mkdir /userdisk/data/wwwroot/dav

修改权限,机内硬盘默认是777,非必要

chown www-data.www-data /userdisk/data/wwwroot

设置一个备份

cp /opt/etc/lighttpd/lighttpd.conf /opt/etc/lighttpd/lighttpd.conf.bak

cp /opt/etc/lighttpd/conf.d/20-auth.conf /opt/etc/lighttpd/conf.d/20-auth.conf.bak

编辑配置lighttpd.conf

vi /opt/etc/lighttpd/lighttpd.conf

直接用下面的内容,端口用的是8023,你可以自定义其它

server.document-root        = "/userdisk/data/wwwroot/"
server.upload-dirs          = ("/userdisk/data/tmp/")
server.errorlog             = "/opt/var/log/lighttpd/error.log"
server.pid-file             = "/var/run/lighttpd.pid"
#server.max-request-size      = 2097152000
index-file.names = ( "index.php", "index.html", "index.htm", "default.htm" )
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )
server.port                 = 8023
server.errorlog-use-syslog  = "enable"
### Use IPv6 if available
#include_shell "/opt/share/lighttpd/use-ipv6.pl"
dir-listing.encoding        = "utf-8"
server.dir-listing          = "enable"
include "/opt/etc/lighttpd/mime.conf"
include "/opt/etc/lighttpd/conf.d/*.conf"

编辑conf.d/20-auth.conf

vi /opt/etc/lighttpd/conf.d/20-auth.conf

直接用下面的内容,其中dav是要开放webdav的子目录

server.modules += ( "mod_auth" )

auth.backend                 = "plain"
auth.backend.plain.userfile  = "/opt/etc/lighttpd/lighttpd.user"

auth.require = ( "/dav" =>
                               (
                                 "method"  => "digest",
								 # "method"  => "basic",
                                 # "realm"   => "Webdav Server",
								 "realm"   => "Webdav",
                                 "require" => "valid-user"
                               ),
                             )

创建用于webdav访问的授权文件

touch /opt/etc/lighttpd/lighttpd.user

vi /opt/etc/lighttpd/lighttpd.user

新增内容,添两个用户和密码,你可定义其它

admin1:12345678

admin2:12345678

编辑conf.d/30-webdav.conf

vi /opt/etc/lighttpd/conf.d/30-webdav.conf

直接用下面的内容,其中dav为指定的webdav路径

server.modules += ( "mod_webdav" )
$HTTP["url"] =~ "^/dav($|/)" {
  dir-listing.activate = "enable"
  webdav.activate = "enable"
  webdav.is-readonly = "disable"
  #webdav.log-xml = "disable"
  webdav.sqlite-db-name = "/userdisk/data/webdav.db"
}

然后重启httpd

/opt/etc/init.d/S80lighttpd restart

开放防火墙临时端口

iptables -A INPUT -i ppp0 -p tcp --dport 8023 -j ACCEPT

iptables -A INPUT -i ppp0 -p udp --dport 8023 -j ACCEPT

或者永久端口

vi /etc/config/firewall

添加内容

config rule 'lighttpdwan'
option src 'wan'
option dest_port '8023'
option proto 'tcp'
option target 'ACCEPT'
option name 'lighttpd webdav'

重新启动防火墙

/etc/init.d/firewall

或重启路由

reboot

防问地址

http://192.168.31.1:8023/dav

本示例 帐号admin1密码12345678

win10中映射网络磁盘为X,就像操作本机硬盘一样,执行CMD命令

net use X: http://192.168.31.1:8023/dav /user:admin1 /persistent:YES 12345678

如果创建不了,请参考 /archives/1321

其它可用软件查看entware镜像

http://bin.entware.net/armv7sf-k3.2/

将在其它文章 小米优化和远程办公方案,暂时结案。

不明白或可改进的地方请留言讨论!

点赞

发表评论

电子邮件地址不会被公开。必填项已用 * 标注