OpenWrt/LEDE更换为中国大陆镜像软件源方法和相关镜像站

OpenWrt/LEDE更换为中国大陆镜像软件源方法和相关镜像站

Vanish
2020-09-02 / 0 评论 / 3 阅读 / 正在检测是否收录...

因为OpenWrt官方网站速度太慢了,从中国大陆部分地区访问很不稳定,使用opkg命令时经常失败。考虑更换为国内的镜像源,依然推荐依然是中科大和清华的开源软件镜像。

OpenWrt的OPKG命令软件源的配置文件有以下两个:

/etc/opkg/customfeeds.conf:用户自定义源,建议把新增的软件源写在该文件中,格式为:src/gz 源名称 源地址
/etc/opkg/distfeeds.conf:发行版官方源,不建议更改,如果替换了同名称的源,可以将其内容注释掉以便恢复。
从OpenWrt/LEDE的web界面中就可以找到更改这两个文件的入口:System-Software-Configure opkg…

当然也可以SSH到路由器中编辑上述两个文件。

添加SSL支持
替换源之前需要注意一个问题:官方源是http协议的,但是国内的镜像源经常是https的,而OpenWrt的官方发行版固件中并没有添加对wget的SSL支持,因此如果直接替换为https的源,执行opkg命令后会收到错误消息:

wget: SSL support not available, please install one of the libustream-.*[ssl|tls] packages as well as the ca-bundle and ca-certificates packages.
*** Failed to download the package list from https://***

解决方法也很简答,可以在替换源之前先用官方源安装下面两个包:

opkg update
opkg install ca-certificates luci-ssl-openssl

如果你完全无法访问官方源,连上述两个包也下载不了,那么可以先把镜像源的https改为http试试,实测中科大的镜像源https地址改为http也可以使用。再或者你也可以手动用浏览器(从镜像源)下载上面两个包(及其依赖),上传到路由器/tmp目录下用opkg install命令先安装。

customfeeds替换为中科大(清华)镜像源
先将 /etc/opkg/distfeeds.conf 中的所有条目复制到 /etc/opkg/customfeeds.conf 中,然后注释掉 distfeeds.conf 中的内容。

再将 customfeeds.conf 文件中的 http://downloads.openwrt.org/ 替换为 https://mirrors.ustc.edu.cn/lede/ 或者 https://mirrors.tuna.tsinghua.edu.cn/openwrt/ 即可。

替换后的 customfeeds.conf 文件如下,本文以替换OpenWrt Release 19.07.3,ath79架构为例,抄作业的话注意改为你自己路由器的发行版和架构。

# USTC
src/gz openwrt_core https://mirrors.ustc.edu.cn/openwrt/releases/19.07.3/targets/x86/generic/packages
src/gz openwrt_kmods https://mirrors.ustc.edu.cn/openwrt/releases/19.07.3/targets/x86/generic/kmods/4.14.180-1-a1300ca9e381f341b39d355566868f0c/
src/gz openwrt_base https://mirrors.ustc.edu.cn/openwrt/releases/19.07.3/packages/x86_64/base
src/gz openwrt_luci https://mirrors.ustc.edu.cn/openwrt/releases/19.07.3/packages/x86_64/luci
src/gz openwrt_packages https://mirrors.ustc.edu.cn/openwrt/releases/19.07.3/packages/x86_64/packages
src/gz openwrt_routing https://mirrors.ustc.edu.cn/openwrt/releases/19.07.3/packages/x86_64/routing
src/gz openwrt_telephony https://mirrors.ustc.edu.cn/openwrt/releases/19.07.3/packages/x86_64/telephony

或者:

# Tsinghua
src/gz openwrt_core https://mirrors.tuna.tsinghua.edu.cn/lede/releases/19.07.3/targets/ath79/generic/packages
src/gz openwrt_kmods https://mirrors.tuna.tsinghua.edu.cn/lede/releases/19.07.3/targets/ath79/generic/kmods/4.14.171-1-b84a5a29b1d5ae1dc33ccf9ba292ca1d
src/gz openwrt_base https://mirrors.tuna.tsinghua.edu.cn/lede/releases/19.07.3/packages/mips_24kc/base
src/gz openwrt_luci https://mirrors.tuna.tsinghua.edu.cn/lede/releases/19.07.3/packages/mips_24kc/luci
src/gz openwrt_packages https://mirrors.tuna.tsinghua.edu.cn/lede/releases/19.07.3/packages/mips_24kc/packages
src/gz openwrt_routing https://mirrors.tuna.tsinghua.edu.cn/lede/releases/19.07.3/packages/mips_24kc/routing
src/gz openwrt_telephony https://mirrors.tuna.tsinghua.edu.cn/lede/releases/19.07.3/packages/mips_24kc/telephony

直接修改distfeeds.conf(懒省事儿的方法)
以替换为清华镜像源为例,执行:

sed -i 's_downloads.openwrt.org_mirrors.tuna.tsinghua.edu.cn/openwrt_' /etc/opkg/distfeeds.conf

参考资料:
1[1]

2[2]

0

评论

博主关闭了所有页面的评论