屏蔽 quic 流量
最近在使用一些服务的时候发现流量没有正确的按照设定的规则走,发现部分网站已经优先支持 quic 也就是 http3 协议了,而这种协议目前一些客户端无法正确解析。解决方法就是将 quic 流量屏蔽掉,让那些网站强制走 http 或 http2 即可。
quic 协议走的是 udp 层,一般是 443 或 80 端口。
openwrt 或其他 linux 系统上使用 nftables 设置规则即可:
新建路由表
nft add table ip tabletest
# 局域网流量屏蔽
# 局域网流量目标地址是外部地址时传输路径为 prerouting -> forward -> postrouting hooks
nft add chain ip tabletest prerouting { type nat hook prerouting priority 0 \; policy accept \; }
nft add rule ip tabletest prerouting udp dport { 80, 443 } drop
# 本机网关流量屏蔽
# 本机网关流量目标地址时外部地址时传输路径为 本机 -> output -> postrouting hooks
nft add chain ip tabletest output { type nat hook output priority 0 \; policy accept \; }
nft add rule ip tabletest output udp dport { 80, 443 } drop
在 Chrome 中禁用 HTTP/3:
- 打开 Chrome 浏览器
- 在地址栏输入 chrome://flags 并按回车。
- 在搜索框中输入 quic。
- 将 Experimental QUIC protocol 设置为 Disabled。
- 重启浏览器。
在 Firefox 中禁用 HTTP/3:
- 打开 Firefox 浏览器。
- 在地址栏输入 about:config 并按回车。
- 接受风险提示。
- 搜索 network.http.http3.enabled。
-将其值设置为 false。
修改 pip 为国内源
一键替换命令:
# 清华源
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
# 阿里源
pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
# 腾讯源
pip config set global.index-url http://mirrors.cloud.tencent.com/pypi/simple
# 豆瓣源
pip config set global.index-url http://pypi.douban.com/simple/
# 换回默认源
pip config unset global.index-url
nftables 使用教程
新版本的 openwrt 使用 fw4 防火墙,默认已经从 iptables 切换到了 nftables,语法有了很大的变化,下面介绍 nftables 的使用方法。
通过 dnsmasq nftset 和 nftables 对域名流量的控制
最近升级路由器系统到 openwrt 23,发现 dnsmasq-full 已经默认不支持 ipset 转而支持 nftset 了,所以之前的教程:通过 dnsmasq ipset 和 iptables 对域名流量的控制 已经不适用新版本系统。
下面介绍如何通过 nfset 和 nftables 实现同样的功能。
首先查看 dnsmasq 版本是否支持 nftset:
root@OpenWrt:~# dnsmasq -v
Dnsmasq version 2.90 Copyright (c) 2000-2024 Simon Kelley
Compile time options: IPv6 GNU-getopt no-DBus UBus no-i18n no-IDN DHCP DHCPv6 no-Lua TFTP conntrack no-ipset nftset auth cryptohash DNSSEC no-ID loop-detect inotify dumpfile