TL-WDR4900v2使用OpenWRT

2024/07/09

OpenWRT 下载地址

https://openwrt.org/toh/hwdata/tp-link/tp-link_tl-wdr4900_v2

从这里可以选择历史固件 https://downloads.openwrt.org/releases/

https://downloads.x-wrt.com/rom/

问题记录

  • 固件 openwrt-23.05.0

    1. 安装空间不足,无法安装其他软件
  • 固件 X-WRT 24.04_b202407151335

    1. 只识别 exFat 格式的U盘,无法安装软件

挂载u盘

安装的插件

opkg install kmod-usb-ohci # 支持部分USB芯片的驱动
opkg install kmod-usb2 # usb2.0驱动
opkg install kmod-usb-storage # USB存储驱动
opkg install kmod-fs-ext4 # ext4 格式支持
opkg install block-mount # 挂载点 自动挂载 需重启

安装软件到U盘(不推荐)

注意:此方式安装软件后软件列表中显示未安装

vi /etc/opkg.conf

dest usb /mnt/sda1
dest root /
dest ram /tmp
lists_dir ext /var/opkg-lists
option overlay_root /overlay
option check_signature

vi /etc/profile

...
export LD_LIBRARY_PATH="/mnt/sda1/usr/lib:/mnt/sda1/lib"
export PATH="/usr/sbin:/usr/bin:/sbin:/bin:/mnt/sda1/usr/bin:/mnt/sda1/usr/sbin"
...

source /etc/profile

替换 / 目录(推荐)

  1. 挂载点中通过uuid挂载到/目录下
  2. 根据返回的提示执行以下语句

    mkdir -p /tmp/introot
    mkdir -p /tmp/extroot
    mount --bind / /tmp/introot
    tar -C /tmp/introot -cvf - . | tar -C /tmp/extroot -xf -
    umount /tmp/introot
    umount /tmp/extroot
    
  3. 以上脚本不报错。执行第一步的保存并应用
  4. 重启路由器

中文语言包

luci-i18n-base-zh-cn

DDNS 动态DNS

opkg update
opkg install luci-i18n-ddns-zh-cn

安装配置 AdGuard Home + smartdns 告别广告烦扰

参考网址2 https://www.iigeek.com/archives/905

安装 adguardhome

(黑名单推荐)[https://www.cnblogs.com/ynas/p/17151266.html]

opkg update
opkg install adguardhome
#启动
/etc/init.d/adguardhome start
/etc/init.d/adguardhome enable
#查看
root@OpenWrt:~# ps| grep AdGuardHome
 5101 root     1233m S    /usr/bin/AdGuardHome -c /etc/adguardhome.yaml -w /var/adguardhome --no-check-update
#查看端口
root@OpenWrt:~# netstat  -antlp| grep AdGuardHome
tcp        0      0 :::3000                 :::*                    LISTEN      5101/AdGuardHome

安装smartdns

smartdns luci-app-smartdns luci-i18n-smartdns-zh-cn

国内DNS查询地址 https://dns.ip.cn/

# 国内

114公共DNS:114.114.114.114,114.114.115.115 类型选择:UDP
阿里公共DNS:223.5.5.5,223.6.6.6 类型选择:UDP
阿里加密DNS:aliDNS_ip/DNS-query 类型选择:https
阿里加密DNS:http://DNS.aliDNS.com/DNS-query 类型选择:https
腾讯公共DNS+:119.29.29.29 类型选择:UDP
腾讯加密DNS:doh.pub/DNS-query 类型选择:https
腾讯加密DNS:sm2.doh.pub/DNS-query 类型选择:https
百度公共DNS:180.76.76.76 类型选择:UDP
华为云公共DNS :122.112.208.1,139.9.23.90 类型选择:UDP
DNS派 电信 / 移动 / 铁通:101.226.4.6,218.30.118.6 类型选择:UDP
DNS派 联通:123.125.81.6,140.207.198.6 类型选择:UDP

# 国外

Google DNS:8.8.8.8,8.8.4.4 类型选择:tls(UDPTCP也可以加入)
Google加密DNS:dns.google/dns-query 类型选择:https
Google加密DNS:dns.google 类型选择:tls
IBM Quad9:9.9.9.9类型选择:tls(UDPTCP也可以加入)
IBM Quad9:http://doh.opendns.com/dns-query 类型选择:https
Norton ConnectSafe:199.85.126.10 199.85.127.10 类型选择:UDP
威瑞信:64.6.64.6 64.6.65.6 类型选择:UDP
Comodo安全DNS: 8.26.56.2 类型选择:UDP
OpenDNS:208.67.222.222,208.67.220.220类型选择:tls(UDPTCP也可以加入)
韩国电信DNS:168.126.63.1,168.126.63.2类型选择:tls(UDPTCP也可以加入)

hosts文件去广告

Hosts 是每个系统都会有的一个文件,它的作用就是将域名指向指定 IP,如果把广告域名指向一个无法访问的 IP,是不是就可以达到过滤广告的需求了。

优点:占用空间少,不需要依赖,可以过滤大多数网盟和视频广告

缺点:容易误杀(有些域名不一定都是广告),过滤视频广告效果不是 100%,无法去除广告占位符。

适用于一些低性能和剩余空间不多的设备,根据小山测试,可以过滤掉手机端大多数视频广告、PC 端可能还会被检测出来。

配置方法

  1. 输入 cp /etc/hosts /etc/hosts.bak 备份原有 Hosts
  2. 输入 wget https://raw.githubusercontent.com/vokins/yhosts/master/hosts -O /etc/hosts --no-check-certificate 下载屏蔽广告 Hosts
  3. 输入 /etc/init.d/dnsmasq restart 重启 Dnsmasq 使 Hosts 生效
  4. 浏览器打开路由器管理页面,依次点击 [系统] → [计划任务],在新的一行填写 0 4 * * * wget https://raw.githubusercontent.com/vokins/yhosts/master/hosts -O /etc/hosts --no-check-certificate && /etc/init.d/dnsmasq restart # 每天4点自动更新 Hosts
  5. 如果你固件的 wget 不支持 HTTPS,那么 Hosts 会下载失败。

解决方法

  1. 输入 opkg update && opkg install wget 安装完整 wget 重新执行上面的命令。
  2. 将下载源替换为小山的镜像,这个镜像不是缓存,是 cURL 源地址,同时可以加速下载,GitHub 在国内速度并不是多好,地址:http://x.mivm.cn/Hosts/?URL=https://raw.githubusercontent.com/vokins/yhosts/master/hosts ,支持 HTTPS。
  3. 这个方法就比较麻烦了,在电脑上下载好 Hosts 上传至路由器。
  4. 下载 https://raw.githubusercontent.com/vokins/yhosts/master/hosts ,然后将文件复制到跟 pscp.exe 相同的位置,就是上面下载的 PuTTY 里面附带的 pscp.exe ,接着在 PuTTY 文件夹窗口按住 Shift 键点击鼠标右键,点击 [在此处打开命令窗口],然后输入 pscp -scp -l root hosts 192.168.1.1:/etc/hosts 接着输入密码,即可上传至路由器。

删除 Hosts 屏蔽

输入命令 mv /etc/hosts.bak /etc/hosts 还原 Hosts,接着删除计划任务的任务即可。

这种方法有一定几率误杀也可能导致某些网站打不开或者显示错误。

参考网站

ac2100刷openwrt 2.4g wifi只有130m速率

openwrt 无线测速只能达到20Mbps

页面配置40Mhz,在/etc/config/wireless文件中的wifi-device下增加option noscan ‘1’

OpenWRT的无线设置注意事项——从2.4G到5G

OPENWRT后如何同时开启2.4G和5G无线

/etc/config/wireless

config wifi-device 'radio0'
        option type 'mac80211'
        option hwmode '11ng'
        option path 'platform/ar934x_wmac'
        option htmode 'HT40+'
        list ht_capab 'LDPC'
        list ht_capab 'SHORT-GI-20'
        list ht_capab 'SHORT-GI-40'
        list ht_capab 'TX-STBC'
        list ht_capab 'RX-STBC1'
        list ht_capab 'DSSS_CCK-40'
        option noscan '1'
        option channel '7'
        option txpower '27'
        option country 'CN'

config wifi-iface
        option device 'radio0'
        option network 'lan'
        option mode 'ap'
        option ssid 'openwrt_25g'
        option encryption 'psk-mixed'
        option key '11111111'

config wifi-device 'radio1'
        option type 'mac80211'
        option hwmode '11na'
        option path 'pci0000:00/0000:00:00.0'
        list ht_capab 'LDPC'
        list ht_capab 'SHORT-GI-20'
        list ht_capab 'SHORT-GI-40'
        list ht_capab 'TX-STBC'
        list ht_capab 'RX-STBC1'
        list ht_capab 'DSSS_CCK-40'
        option htmode 'HT40+'
        option country 'CN'
        option noscan '1'
        option txpower '17'
        option channel '149'

config wifi-iface
        option device 'radio1'
        option network 'lan'
        option mode 'ap'
        option ssid 'openwrt_5g'
        option encryption 'psk-mixed'
        option key '11111111'

目录