Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何让所有流量都走minivtun #11

Open
threekidney opened this issue Feb 9, 2017 · 19 comments
Open

如何让所有流量都走minivtun #11

threekidney opened this issue Feb 9, 2017 · 19 comments

Comments

@threekidney
Copy link

安装并连接了minivtun,能ping 通minivtun的服务器内网IP,但是流量不经minivtun服务器走,尝试修改iptables跟route还是不行,请问具体应该怎么设置让所有流量都走minivtun服务器端呢?

@boytm
Copy link

boytm commented Feb 9, 2017

客户端定2条路由规则就行:
ip route add your_minivtun_server_ip/32 dev eth_xx ## 排除 minivtun client 与 server
ip route replace 0.0.0.0/0 dev mv0 via minivtun_server_inner_ip ## 所有流量走 minivtun

@threekidney
Copy link
Author

你好,我的客户端系统是ubuntu12.04,请问你说的要怎么写呢?然后服务器端需要写什么不?还是直接运行就可以了?麻烦你抽空帮忙解答一下,先谢谢啦

@boytm
Copy link

boytm commented Feb 9, 2017

假定我本地网卡是eth0,网关地址是 192.168.1.1,minivtun 服务器地址 9.9.9.9;minivtun 客户端网口 mv0,内网网关 10.7.0.1,minivtun 自己地址 10.7.0.100。
确保minivtun 正常运行能 ping 通后,然后minivtun客户端上运行
ip route replace 9.9.9.9/32 dev eth0 via 192.168.1.1
ip route change default dev mv0 via 10.7.0.1

@threekidney
Copy link
Author

非常感谢你的帮忙,现在OK了

@threekidney
Copy link
Author

你好,再请教你一下,我想把minivtun的网络分享给第二块网卡(第二块网卡接着路由器wan口),让其他电脑可以接上路由器lan口直接经minivtun服务器上网,可以实现吗?应该怎么设置呢?

@boytm
Copy link

boytm commented Feb 10, 2017

路由器的网关地址设为 minivtun 所在机器的第二个网卡地址;

同时 minivtun 所在机器再做下面3步:
sysctl -w net.ipv4.ip_forward=1 ## 开路由功能。直接编辑 /etc/sysctl.conf 也可
iptables -t nat -A POSTROUTING -o mv0 -j MASQUERADE ## mv0 口出去的包做 SNAT
iptables -t mangle -A FORWARD -o mv0 -p tcp -m tcp --tcp-flags SYN,RST SYN -m comment --comment "minivtun (mtu_fix)" -j TCPMSS --clamp-mss-to-pmtu ## TCP mss

@threekidney
Copy link
Author

实在是太谢谢您了,都设置OK了

@luckypoem
Copy link

@boytm
我的客户机器是mac,让所有流量都走minivtun的命令该如何写?
谢谢回复

@luckypoem
Copy link

我已安装tuntaposx

@boytm
Copy link

boytm commented Feb 1, 2018

改默认路由表就行。参考 https://apple.stackexchange.com/questions/33097/how-to-change-the-default-gateway-of-a-mac-osx-machine
route change default -interface $INTF

@luckypoem
Copy link

@boytm

yudeMacBook-Air:~ brite$ echo $INTF
yudeMacBook-Air:~ brite$

$INTF指什么?

@lixingcong
Copy link

mv0

@luckypoem
Copy link

@lixingcong
可否写一篇在mac上,使用minivtun翻墙的文章?

@liyangyijie
Copy link

@luckypoem 参考shadowvpn darwin脚本

@luckypoem
Copy link

@liyangyijie 我看了https://github.com/shadowsocks-backup/ShadowVPN ,没看到shadowvpn darwin脚本。你能在此把它贴出来吗

@luckypoem
Copy link

在 mac上,运行:
sudo route add vps-public-ip router-ip
sudo route delete default
sudo route add default vps-internal-ip

终于可以用此vpn翻墙了

@luckypoem
Copy link

今天我的mac开机后,我运行:
cd ~/minivtun/src && sudo ./minivtun -r my-vps-ip:1414 -a 10.7.0.2/24 --key iloveson -d
提示:*** open_tun() failed: No such file or directory.

怎么回事?怎么解决?
@liyangyijie

谢谢你的回复

@luckypoem
Copy link

重新安装TUNTAP driver for Mac OS X: http://tuntaposx.sourceforge.net
"*** open_tun() failed: No such file or directory."问题解决。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants