OpenWRT部署后优化
1.opkg源修改国内
系统——软件包——配置opkg
修改为 清华大学镜像源 (以23.05.4版本为例,别的版本也可以按需更改)
src/gz openwrt_core https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/23.05.4/targets/x86/64/packages
src/gz openwrt_base https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/23.05.4/packages/x86_64/base
src/gz openwrt_luci https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/23.05.4/packages/x86_64/luci
src/gz openwrt_packages https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/23.05.4/packages/x86_64/packages
src/gz openwrt_routing https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/23.05.4/packages/x86_64/routing
src/gz openwrt_telephony https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/23.05.4/packages/x86_64/telephony
替换保存后,点击:“更新列表”
1、在过滤器中搜索:luci-i18n-base-zh-cn
,安装后改成中文界面,刷新页面后显示中文。
2、卸载默认的dnsmasq ,安装dnsmasq-full(这一步必须先配置好源,因为clash需要完整的dnsmasq功能,所以要换)
下面的例子应该可以比较直观地看出来,一些基本的使用命令:
opkg update
opkg upgrade 软件包名1 软件包名2
opkg install dnsmasq
opkg install http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/hiawatha_7.7-2_ar71xx.ipk
opkg install /tmp/hiawatha_7.7-2_ar71xx.ipk
opkg install --force-depends dnsmasq
opkg remove 软件包名
opkg remove --force-depends example-package
opkg list
opkg list-installed
opkg list-upgradable
官方说明[OpenWrt Wiki] Opkg package manager
如果需要扩容,那么先执行扩容,扩容完成后,恢复固件也不会删除扩容空间,一劳永逸。推荐安装”不带efi的squashfs版本固件系统”
2.磁盘扩容
OpenWRT(x86_64)中squashfs固件磁盘空间扩容方法:Overlay扩容,带有efi的和不带efi的
3.网络优化
1、把wan、lan都编辑一遍,如果有wan ipv6接口,可以选择直接删除
先做一遍lan口操作,高级设置——委托iPv6前缀(取消)——iPv6分配长度(已禁用)
DHCP服务器——iPv6设置——RA服务(已禁用)——DHCPv6服务(已禁用)——NDP代理(已禁用)
LAN口配置完成,WAN口同样的地方也要配置一遍,并且这里有一处不同需要注意
最后,去DHCP/DNS里把iPv6的AAAA解析去掉
最后,在“限制”中把DNS缓存去掉,配置为“0”
配置后每一页,都应该设置“保存并应用”
4.辨别防火墙类型
不同的OpenWrt系统默认的防火墙类型不同,这里需要首先分辨openwrt防火墙类别(iptables or nftables)
通过ssh连接openwrt,执行相关命令判断:
iptables -L
如果能正常列出规则,则表示使用的是iptables
nft list ruleset
如果能正常列出规则,则表示使用的是nftables
iptable/nftables:
官方openwrt固件: OpenWrt 22.03系列专注于从基于iptables的防火墙3迁移到基于nftables的防火墙4
immortalwrt固件: 过渡版本两者共存 默认使用nftables 最新版也单独使用nftables
Lean固件: iptables
3代防火墙iptables安装这些依赖:
opkg update
opkg install coreutils-nohup bash iptables dnsmasq-full curl ca-certificates ipset ip-full iptables-mod-tproxy iptables-mod-extra libcap libcap-bin ruby ruby-yaml kmod-tun kmod-inet-diag unzip luci-compat luci luci-base
4代防火墙nftables安装这些依赖:
opkg update
opkg install coreutils-nohup bash dnsmasq-full curl ca-certificates ipset ip-full libcap libcap-bin ruby ruby-yaml kmod-tun kmod-inet-diag unzip kmod-nft-tproxy luci-compat luci luci-base
5.openclash
然后去官网下载完整安装包:luci-app-openclash_0.46.033-beta_all.ipk
然后到OpenWRT的web控制台,上传安装软件,安装成功后第一次需要重启OpenWRT,会出现服务中。
6.wifi driver
wifi模块不是什么卡都行的,建议大家看好无线网卡型号,推荐参考大神的推荐:
2024-9-9—官方源码—史上最全 驱动—支持无线AP模式— openwrt x86-64 23.05.4版
配置方法如下: 我尝试了新、老2张wifi网卡,都能正常驱动了