table inet symmetric {
chain prerouting {
type filter hook prerouting priority mangle -150; policy accept;
# 连接标记处理
ct state new meta mark set ct mark
meta mark != 0 accept
# 基于入站接口打标记
iifname "$WAN1_IF" meta mark set 1 ct mark set 1
iifname "$WAN2_IF" meta mark set 2 ct mark set 2
}
chain postrouting {
type nat hook postrouting priority srcnat; policy accept;
# 出站NAT
oifname "$WAN1_IF" masquerade
oifname "$WAN2_IF" masquerade
}
}
table inet symmetric {
chain prerouting {
type filter hook prerouting priority mangle -150; policy accept;
# 连接标记处理
ct state new meta mark set ct mark
meta mark != 0 accept
# 基于入站接口打标记
iifname "eth0.1" meta mark set 1 ct mark set 1
iifname "eth0.2" meta mark set 2 ct mark set 2
}
chain postrouting {
type nat hook postrouting priority srcnat; policy accept;
oifname "eth0.1" masquerade
oifname "eth0.2" masquerade
}
}
# 1. 检查规则是否生效
ip rule list
# 2. 验证nftables标记
nft list table inet symmetric -a
# 3. 跟踪实时路由决策
nft monitor trace | grep "mark set"
您可能会喜欢的进阶功能:
# 基于时间的路由策略(添加至nftables)
chain time-based {
meta hour >= "09:00" && meta hour < "18:00" meta mark set 1
meta hour >= "18:00" meta mark set 2
}
# 智能DNS配置(搭配dnsmasq)
uci set dhcp.@dnsmasq[0].server="/example.com/8.8.8.8"
uci commit
期待您后续的实施反馈!如果遇到任何问题,随时可以回来咨询。技术之路,有您这样的探索者真好!
[点击收藏此页面] (当然这是虚拟提示~实际建议您保存此指导文档)
祝您配置顺利,网络如丝般顺滑!
我说:非常感谢,等我后续实施反馈哟!我相信会成功的!
deepseek 回答:
您的信心和积极态度已经为成功奠定了最佳基础!以下是专为您准备的「实施护航包」,方便随时取用:
实施急救锦囊
快速回滚命令
# 一键恢复默认路由
/etc/init.d/symmetric-routing stop
ip route replace default via 原主WAN网关
实时诊断三连
# 连接跟踪检查
conntrack -L -o mark | head -n 10
# 路由路径验证
ip route get 8.8.8.8 from 内网IP mark 1
# 规则生效测试
nft --debug=netlink list ruleset
分阶段实施建议
阶段① 实验室测试
# 在测试设备上模拟双WAN(需额外网卡)
ip link add veth0 type veth peer name veth1
ifconfig veth0 192.168.3.1 up
ifconfig veth1 192.168.4.1 up
阶段② 生产环境灰度上线
# 只对特定IP启用策略路由(测试机)
ip rule add from 测试机IP lookup wan1_rt
阶段③ 全量部署
# 批量添加规则(使用xargs优化)
seq 100 150 | xargs -I{} ip rule add from 192.168.1.{} lookup wan1_rt
高频调试技巧
标记可视化工具
watch -n1 'nft list table inet symmetric -a | grep -E "mark|packets"'
连接跟踪热修复
# 强制旧连接走新路径
conntrack -D -m 1 # 删除标记为1的所有连接
性能瓶颈定位
nft --handle --numeric list chain inet symmetric prerouting
Technical information
=====================
The following list covers which files have failed the integrity check. Please read
the previous linked documentation to learn more about the errors and how to fix
them.
Results
=======
- richdocuments
- INVALID_HASH
- lib/Preview/Office.php
Raw output
==========
Array
(
[richdocuments] => Array
(
[INVALID_HASH] => Array
(
[lib/Preview/Office.php] => Array
(
[expected] => d24c05d636bfdcb5e66e9d7abb94cf8ac193d37de9e88cd820ec3be40a84681137c10a37c1d128cbd00b9ddec9b9e6835e473d59980355e1458fe248e4893d8d
[current] => 054484e6f4edafb77b09ebb539172440bdf3289fda2ae709fbb0d4726d18a588164b15a958f07c0dc088e44242992eb0cab5db82c0b23c9cabb18567e3d1bd81
)
)
)
)
访问 Python 官网 Welcome to Python.org 下载最新版的 Python for Windows x64 安装程序 python-3.10.5-amd64.exe
双击安装 → Customize installation(记得勾选Add Python 3.10.5 to PATH)
Optional Features 这个步骤界面,按照默认勾选的选项即可。
Advanced Options 这个步骤界面,需勾选 Install for all user 。安装目录根据喜好设定。
顺利安装完成即可。
2、检查安装是否成功
打开 cmd 或 Windows terminal 键入 python
如下所示,表示成功
PS C:\Users\sgtfz> python
Python 3.10.5 (tags/v3.10.5:f377153, Jun 6 2022, 16:14:13) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
3、安装需要的依赖项
pyaes – AES 加解密支持
colorama – 命令行输出中的颜色
mutagen – 为输出文件写入标签和封面
MusicTagFindUtils – 从网易云音乐和 QQ 音乐查找输出文件的标签信息和封面
版本号必须大于等于 v0.1.2
requests – 网络请求库,用于下载封面信息
安装依赖项命令示例如下(直接在Windows terminal键入安装命令安装)
PS C:\Users\sgtfz> pip install colorama
Defaulting to user installation because normal site-packages is not writeable
Collecting colorama
Downloading colorama-0.4.5-py2.py3-none-any.whl (16 kB)
Installing collected packages: colorama
Successfully installed colorama-0.4.5
PS C:\Users\sgtfz> pip install mutagen
Defaulting to user installation because normal site-packages is not writeable
Collecting mutagen
Downloading mutagen-1.45.1-py3-none-any.whl (218 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 218.7/218.7 kB 533.0 kB/s eta 0:00:00
WARNING: The scripts mid3cp.exe, mid3iconv.exe, mid3v2.exe, moggsplit.exe, mutagen-inspect.exe and mutagen-pony.exe are installed in 'C:\Users\sgtfz\AppData\Roaming\Python\Python310\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed mutagen-1.45.1