#download chinaip
https://raw.githubusercontent.com/17mon/china_ip_list/master/china_ip_list.txt#tun2socks
https://github.com/xjasonlyu/tun2socks/releases/download/v2.4.1/tun2socks-darwin-amd64.ziphttps://github.com/xjasonlyu/tun2socks/releases/download/v2.4.1/tun2socks-darwin-amd64-v3.ziphttps://github.com/xjasonlyu/tun2socks/wiki/Examples#macossudo ./tun2socks-darwin-amd64 -device utun123 -proxy socks5://127.0.0.1:1080 -interface en0
sudo ifconfig utun123 198.18.0.1 198.18.0.1 up
pf.conf
#skip lo0
set skip on lo0
#china ip table
table <BYPASS_SNET> persist file "./china_ip_list.txt"
#ip
#本机 ip
local_ip= "192.168.1.2"
#局域网段
lan_net = "192.168.1.3/24"
#本机局域网上网接口
ext_if1 = "en0"
#网关 ip
ext_gw1 = "192.168.1.1"
#tun2socks
ext_if2 = "utun123"
ext_gw2 = "198.18.0.1"
#nat
no nat log on $ext_if1 from $local_ip to any
nat log on $ext_if1 from $lan_net to any -> $ext_if1
nat log on $ext_if2 from $lan_net to any -> $ext_if2
pass in log on $ext_if1 route-to ($ext_if2 $ext_gw2) proto {tcp udp} from any to {!<BYPASS_SNET> } port {80 443}
#加载生效 pf 规则
sudo pfctl -e -f pf.conf
#pflog0
sudo ifconfig pflog0 create
sudo tcpdump -n -e -ttt -i pflog0
保证 dns 结果正确
把 lan 其它设备的网关设置为 macos ip 就可以了
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
https://www.v2ex.com/t/888071
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.