转载注明来源: 本文链接 来自osnosn的博客,写于 2025-11-20.
default via 10.100.9.1tracert -d -w 1 202.12.12.12测试,数据走的是wan1traceroute -n -w 1 202.12.12.12测试,数据走的是wan1ip route add 10.100.0.0/16 via 10.100.9.1 table 100 metric 10 ## 10.100网段还是走wan1
ip route add 0.0.0.0/0 via 192.168.8.1 table 100 metric 50 ## 其他数据走wan2
对应的luci操作,Network -> Routing -> Static IPv4 Routes -> 添加路由
---- 1 ----
- General Settings
- Interface: wan1
- Route type: unicast #默认值
- Target: 10.100.0.0/16
- Gateway: 10.100.9.1
- Advanced Settings
- Metric: 10
- Table: 100
- 其他内容: 默认/留空/不改变
---- 2 ----
- General Settings
- Interface: wan2
- Route type: unicast #默认值
- Target: 0.0.0.0/0
- Gateway: 192.168.8.1
- Advanced Settings
- Metric: 50
- Table: 100
- 其他内容: 默认/留空/不改变
ip rule add from all fwmark 100 lookup 100 pref 3002Network -> Routing -> IPv4 Rules -> 添加规则
- General Settings
- Priority: 3002
- Route type: unicast #默认值
- Table: 100
- Advanced Settings
- Firewall mark: 100
- 其他内容: 默认/留空/不改变
Firewall mark 支持 "值/掩码"格式,比如 luci中写 "0x64/0xff" 表示 "fwmark 0x64/0xff"
tracert -d -w 1 202.12.12.12测试,数据走的是wan1traceroute -n -w 1 202.12.12.12测试,数据走的是wan1nft add rule inet fw4 mangle_output ip daddr 202.12.12.12 counter meta mark set 0x64
对应的luci操作,Network -> Firewall -> Traffic Rules -> 添加规则
- General Settings
- protocol: Any
- Source Zone: Device (output)
- Output Zone: Any zone
- Destination address: 202.12.12.12
- Action: XOR firewall mark
- XOR mark: 100
- Advanced Settings
- Restrict to address family: IPv4 only
- 其他内容: 默认/留空/不改变
XOR mark 支持 "值/掩码"格式,比如 luci中写 "0x64/0xff" 表示 "meta mark set meta mark & 0xffffff64 | 0x64"
tracert -d -w 1 202.12.12.12测试,数据走的是wan1traceroute -n -w 1 202.12.12.12测试,数据走的是wan2nft add rule inet fw4 mangle_prerouting iifname "br-lan" ip daddr 202.12.12.12 counter meta mark set 0x64
对应的luci操作,Network -> Firewall -> Traffic Rules -> 添加规则
- General Settings
- protocol: Any
- Source Zone: LAN
- Destination Zone: Any zone
- Destination address: 202.12.12.12
- Action: XOR firewall mark
- XOR mark: 100
- Advanced Settings
- Restrict to address family: IPv4 only
- 其他内容: 默认/留空/不改变
XOR mark 支持 "值/掩码"格式,比如 luci中写 "0x64/0xff" 表示 "meta mark set meta mark & 0xffffff64 | 0x64"
tracert -d -w 1 202.12.12.12测试,数据走的是wan2nft add rule inet fw4 mangle_output meta nfproto ipv4 udp dport { 34567, 34568 } counter meta mark set 0x64
nft add rule inet fw4 mangle_output meta nfproto ipv4 tcp dport 22 counter meta mark set 0x64
对应的luci操作,Network -> Firewall -> Traffic Rules -> 添加规则
----1----
- General Settings
- protocol: UDP
- Source Zone: Device (output)
- Output Zone: Any zone
- Destination port: 34567 34568 #空格隔开的两个端口号
- Action: XOR firewall mark
- XOR mark: 100
- Advanced Settings
- Restrict to address family: IPv4 only
- 其他内容: 默认/留空/不改变
----2----
- General Settings
- protocol: TCP (为了测试22端口)
- Source Zone: Device (output)
- Output Zone: Any zone
- Destination port: 22
- Action: XOR firewall mark
- XOR mark: 100
- Advanced Settings
- Restrict to address family: IPv4 only
- 其他内容: 默认/留空/不改变
XOR mark 支持 "值/掩码"格式,比如 luci中写 "0x64/0xff" 表示 "meta mark set meta mark & 0xffffff64 | 0x64"
PostUp/PreDown, 把 wg 的路由写入到 table 100 中。Table = 100。PostUp/PreDown的方法,可能是通过"Import configuration"导入配置的办法,把PostUp/PreDown添加进去。PostUp/PreDown设置,也可以。ip rule add from all fwmark 100 lookup main suppress_prefixlength 0 pref 3001Network -> Routing -> IPv4 Rules -> 添加规则
- General Settings
- Priority: 3001
- Route type: unicast #默认值
- Table: main
- Advanced Settings
- Firewall mark: 100
- Prefix suppressor: 0
- 其他内容: 默认/留空/不改变
Firewall mark 支持 "值/掩码"格式,比如 luci中写 "0x64/0xff" 表示 "fwmark 0x64/0xff"
FwMark = 0x64。Network -> Firewall -> Port Forwards -> 添加规则
- General Settings
- Restrict to address family: Auto 或者 ipv4 only
- protocol: Any 或者 按需选择
- Source Zone: wan
- External port: 留空 或 1-65535
- Destination Zone: lan
- Internal IP address:
- Internal port: 留空 或 1-65535
- Advanced Settings
- 保留默认值
- 其他内容: 默认/留空/不改变
这条dmz规则,必须是最后一条规则。否则它后面的规则都不生效。*/3 * * * * /usr/bin/wireguard_watchdog--end----
转载注明来源: 本文链接 https://www.cnblogs.com/osnosn/p/19309459.html
来自 osnosn的博客 https://www.cnblogs.com/osnosn/ .
登录查看全部
参与评论
手机查看
返回顶部