RT, 用 fwmark 做分流操作,
iptables -t mangle -N GFW iptables -t mangle -F GFW iptables -t mangle -A GFW -d 0.0.0.0/7 -j RETURN iptables -t mangle -A GFW -d 10.0.0.0/8 -j RETURN iptables -t mangle -A GFW -d 127.0.0.0/8 -j RETURN iptables -t mangle -A GFW -d 169.254.0.0/16 -j RETURN iptables -t mangle -A GFW -d 172.16.0.0/12 -j RETURN iptables -t mangle -A GFW -d 192.168.0.0/16 -j RETURN iptables -t mangle -A GFW -d 224.0.0.0/4 -j RETURN iptables -t mangle -A GFW -d 240.0.0.0/4 -j RETURN #此处省略 8 千行 .... #add mark iptables -t mangle -A GFW -j MARK --set-xmark 0x400 # 追加到 mangle prerouting 链 iptables -t mangle -A PREROUTING -i br0 -j GFW #route table 400 ip rule add fwmark 0x400 table 400 ip -4 route add 0.0.0.0/0 dev wg0 table 400
实际使用过程中,打开网页很慢。 如果不加 return , 让所有流量都通过 wg0 走,会很快,秒开。 请问 是 mangle 表 对 return 支持度不够,还是 route 表记录太多导致的问题?
![]() | 1 hyq 2021-09-14 14:37:39 +08:00 你这个 8000 行,不如试试配合 ipset 使用 |
2 guanyin9cn OP @hyq 主要是有的设备,比如 hw 光猫,不支持 ipset , 缺少 ipset 内核模块,编译难度巨大无比。只能采用这种取巧的方法。 |
3 guanyin9cn OP @hyq #1 这是目前找到的,能在 光猫缺少 tproxy.ko, ipset.ko 的情况下,同时代理 tcp 和 udp 的 方法。 |
![]() | 4 hyq 2021-09-14 14:58:17 +08:00 有个精简版的 chnroute,准确度低一点,但是条数很少,可以测试下是不是条目数的问题 https://ikk.me/archives/default/chnroute-mini.html/comment-page-1 |
5 guanyin9cn OP @hyq 有可能是,晚上回去试试。 第一次 导入比较慢,导入成功后,用 iptables-save -t mangle > gfw-mangle, 保存。 以后用 iptables-save --table=mangle < gfw-mangle,秒导。 |
6 CRVV 2021-09-14 16:46:50 +08:00 iptables 是一个 chain,这么写是 O(n) 的复杂度。 路由表是 trie,对数复杂度。 用 iptables 当然会很慢 |