unblockneteasemusic与OP不兼容的解决方案

先放代码

先把现在的nft表备份到root目录下
nft list ruleset > /root/nft_backup_$(date +%s).txt

#查找到你的op软件handle数,类似于序号
nft –handle list chain inet fw4 dstnat

例如我的是1336
# IPv4
nft insert rule inet fw4 dstnat handle 1336 ip daddr @neteasemusic counter jump netease_cloud_music_redir

# IPv6
nft insert rule inet fw4 dstnat handle 1336 ip6 daddr @neteasemusic6 counter jump netease_cloud_music_redir

# 建链(如果已经有则会报错,可忽略)
nft add chain inet fw4 netease_cloud_music_redir { type nat hook prerouting priority dstnat + 5\; }

# 重定向到 Unblockneteasemusic 的端口 默认是5200和5201
nft add rule inet fw4 netease_cloud_music_redir tcp dport 80 redirect to :5200
nft add rule inet fw4 netease_cloud_music_redir tcp dport 443 redirect to :5201

前置条件:op选redirectHost模式,umn开启ntfset劫持,网易云音乐Windows版本3.0以下(不包含3.0),android APP8.0以下(不包含8.0,比如7.2,6.x实测可以)uwp 1.4.1.0及以下,需要解除代理环路

原因是op在重启的时候会清除掉nftables里unm的路由链

可以通过nft monitor trace或者在 nft –handle list chain inet fw4 dstnat 中查看 ip daddr @neteasemusic counter packets X bytes Y 的 packets

开机自动配置: OP->插件设置->开发者选项 添加这个脚本,这个脚本会在程序启动后执行 #!/bin/sh . /usr/share/openclash/log.sh . /lib/functions.sh LOG_OUT “Start Add Custom Firewall Rules for UnblockNeteaseMusic…” nft add chain inet fw4 netease_cloud_music_redir ‘ { type nat hook prerouting priority dstnat + 5; }’ 2>/dev/null || true nft add chain inet fw4 netease_cloud_music ‘ { type filter hook prerouting priority -150; }’ 2>/dev/null || true # 添加重定向规则(HTTP→5200,HTTPS→5201) nft add rule inet fw4 netease_cloud_music_redir tcp dport 80 redirect to :5200 2>/dev/null || true nft add rule inet fw4 netease_cloud_music_redir tcp dport 443 redirect to :5201 2>/dev/null || true # 将 IP 集合跳转到 redir 链(如果已存在则忽略) nft add rule inet fw4 netease_cloud_music ip daddr @neteasemusic counter jump netease_cloud_music_redir 2>/dev/null || true # 自动检测 OP handle,并插入在其前面 h=$(nft –handle list chain inet fw4 dstnat | grep “jump openclash” | awk -F’# handle ‘ ‘{print $2}’ | tr -d ‘ \r\n’) if [ -n “$h” ]; then nft insert rule inet fw4 dstnat handle “$h” ip daddr @neteasemusic counter jump netease_cloud_music_redir 2>/dev/null || true nft insert rule inet fw4 dstnat handle “$h” ip6 daddr @neteasemusic6 counter jump netease_cloud_music_redir 2>/dev/null || true fi exit 0

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注