File tree 1 file changed +26
-0
lines changed 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change 38
38
- [ 7.1 OpenWRT 路由器] ( #71-openwrt-路由器 )
39
39
- [ 7.2 通过树莓派做旁路网关] ( #72-通过树莓派做旁路网关 )
40
40
- [ 7.3 安装 Clash] ( #73-安装-clash )
41
+ - [ 7.4 设置 iptables 转发] ( #74-设置-iptables-转发 )
41
42
- [ 8. 其它] ( #8-其它 )
42
43
- [ 8.1 其它方式] ( #81-其它方式 )
43
44
- [ 8.2 搭建脚本] ( #82-搭建脚本 )
@@ -595,6 +596,31 @@ rules:
595
596
596
597
然后,你就可以把你的上网设备上的 路由网关 和 DNS 服务器都手动地配置成这个网关就好了(OpenWRT应该不用配置了,树莓派的方式需要手动配置一下)
597
598
599
+ ### 7.4 设置 iptables 转发
600
+
601
+ ```
602
+ iptables -t nat -N CLASH
603
+ iptables -t nat -A CLASH -d 10.0.0.0/8 -j RETURN
604
+ iptables -t nat -A CLASH -d 127.0.0.0/8 -j RETURN
605
+ iptables -t nat -A CLASH -d 169.254.0.0/16 -j RETURN
606
+ iptables -t nat -A CLASH -d 172.16.0.0/12 -j RETURN
607
+ iptables -t nat -A CLASH -d 192.168.0.0/16 -j RETURN
608
+ iptables -t nat -A CLASH -d 224.0.0.0/4 -j RETURN
609
+ iptables -t nat -A CLASH -d 240.0.0.0/4 -j RETURN
610
+ iptables -t nat -A CLASH -p tcp -j REDIRECT --to-ports 7892
611
+ ```
612
+ 然后,你可以保存一下这些iptables的规则
613
+
614
+ ```
615
+ iptables-save > /etc/iptables.up.rules
616
+ ```
617
+ 编辑 ` //etc/network/if-pre-up.d/iptables ` ,在网卡启动的时候加载这些规则
618
+
619
+ ```
620
+ #!/bin/sh
621
+ /sbin/iptables-restore < /etc/iptables.up.rules
622
+ ```
623
+ 然后,再 ` chmod +x /etc/network/if-pre-up.d/iptables ` 加上可执行权限就好了。
598
624
599
625
## 8. 其它
600
626
You can’t perform that action at this time.
0 commit comments