Total Pageviews

Thursday 29 August 2019

mac上,利用全局代理程序ip2socks翻墙

首先在你的本地机器上,访问https://help.github.com/cn/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent ,添加ssh public key到你的github账号。

git clone git@github.com:FlowerWrong/ip2socks.git
cd ip2socks
git submodule update --init --recursive
(这一步耗时一个小时,我是挂着wireguard来操作的。)
cmake .
make
(会在当前目录下,生成可执行文件ip2socks)

yudeMacBook-Air:ip2socks brite$ ./ip2socks -h
options:
-d --debug
-h --help
-c --config
yudeMacBook-Air:ip2socks brite$ wget https://github.com/FlowerWrong/ip2socks/raw/master/scripts/config.darwin.example.yml
yudeMacBook-Air:ip2socks brite$ cp config.darwin.example.yml config.darwin.yml
yudeMacBook-Air:ip2socks brite$ cat config.darwin.yml
ip_mode: tun # tun or tap, default tun
dns_mode: udp # tcp or udp, default tcp
socks_server: 127.0.0.1
socks_port: 1080

remote_dns_server: 8.8.8.8
remote_dns_port: 53
local_dns_port: 53 # if you use your own local dns server, eg: pdnsd, dnsmasg, this is upstream dns server.
relay_none_dns_packet_with_udp: false
#custom_domian_server_file: ./scripts/block.conf;./scripts/custom_domain_server.conf;./scripts/dnsmasq-china-list/google.china.conf;./scripts/dnsmasq-china-list/apple.china.conf;./scripts/dnsmasq-china-list/accelerated-domains.china.conf; # if multi, split with ';'
gw: 10.0.0.1 # gateway of lwip netif
addr: 10.0.0.2 # ip of lwip netif
netmask: 255.255.255.0 # netmask of lwip netif
after_start_shell: './scripts/darwin_setup_utun.sh'
before_shutdown_shell: './scripts/darwin_down_utun.sh'
(你的mac机器上,需开着纸飞机
yudeMacBook-Air:ip2socks brite$ nano scripts/darwin_setup_utun.sh
(把47.52.95.27改为你的vps ip)
yudeMacBook-Air:ip2socks brite$ sudo ./ip2socks -c config.darwin.yml
(不要关闭此terminal)

然后,
sudo networksetup -setdnsservers "Wi-Fi" 127.0.0.1

cd ~/CrappyDNS-by-nekolab/src && sudo ./crappydns --listen 127.0.0.1 --port 53 --good-dns tcp://8.8.8.8:53,tcp://8.8.4.4:53
(关于CrappyDNS的用法,详见https://briteming.blogspot.com/2019/08/crappydnsdns.html )

这样,你的整台mac就处于翻墙状态了。

项目地址:
https://github.com/FlowerWrong/ip2socks/
https://github.com/FlowerWrong/ip2socks/issues/10

No comments:

Post a Comment