参考这个帖子 sunp.eu.org/t/800581
不过,我改进了他的方法,采用 iptables + ipset + fwmark + route rule 让特定流量走 warp
# warp.sh
# ipset
ipset create warp hash:ip hashsize 4096
sleep 1
wg-quick up vpn-client
# just for
sysctl -w net.ipv4.conf.vpn-client.rp_filter=2
iptables -A OUTPUT -t mangle -m set --match-set warp dst -j MARK --set-mark 0x400
ip rule add fwmark 0x400 table 1000
ip route add 0.0.0.0/0 dev vpn-client table 1000
# all
iptables -t nat -A POSTROUTING -o vpn-client -j MASQUERADE
dnsmasq 里加要走 warp 的 ipset
# dnsmasq.conf
ipset=/google.com/warp
