Disqus 无法加载。如果您是管理员,请参阅故障排除指南

luckypoem • 5 年之前

hello.
我看到这里https://tunsafe.com/develop... 说TunSafe开源了。然后,
在mac机器上,
git clone https://github.com/TunSafe/...
cd TunSafe
sh ./build_osx.sh
TunSafe目录里就生成了可执行文件tunsafe。
然后我运行了sudo route add my-vps-ip/32 192.168.0.1
显示:add net my-vps-ip: gateway 192.168.0.1
然后运行:sudo ./tunsafe start -n utun9
显示:No IPv4 address configured

怎么解决问题?谢谢你。

Melvin Wang • 5 年之前

utun9 配置里是不是忘记配置my-vps-ip的地址了?配置文件格式https://tunsafe.com/user-gu...
https://github.com/TunSafe/...
#Usage (from a Terminal):
#sudo ./tunsafe Config.conf
你写的 start -n utun9 参数是什么意思,在哪看到的,我没有mac机器测试

Melvin Wang • 5 年之前

C:\Program Files\TunSafe>TunSafe.com --help
Usage: tunsafe <cmd> [<args>]

Available subcommands:
show: Shows the configuration and status of the interfaces
set: Change the configuration or the peer list
start: Start TunSafe on an interface
stop: Stop TunSafe on an interface
log: Display recent log entries
genkey: Writes a new private key to stdout
genpsk: Writes a new preshared key to stdout
pubkey: Reads a private key from stdin and writes its public key to stdout
To see more help about a subcommand, pass --help to it

C:\Program Files\TunSafe>TunSafe.com start --help
Usage: tunsafe start <interface> [<filename>]

Melvin Wang • 5 年之前

./tunsafe start [-d/--daemon] [-n <interface-name>] [<filename>]
你配置文件怎么没有在参数列表后面,要确保格式正确,占位符要替换为正确的地址。
可以去官网https://tunsafe.com/vpn 申请一个配置文件,记得要替换私钥。

luckypoem • 5 年之前

hi.

yudeMacBook-Air:TunSafe brite$ sudo ./tunsafe start -n utun9 /etc/wireguard/wg0.conf
Password:
Loading file: /etc/wireguard/wg0.conf
Error opening udp
yudeMacBook-Air:TunSafe brite$ cat /etc/wireguard/wg0.conf
[Interface]
ListenPort = 11940
PrivateKey = (hidden)

[Peer]
PublicKey = (hidden)
AllowedIPs = 192.168.0.0/24
Endpoint = my-vps-ip:51820
PersistentKeepalive = 25
yudeMacBook-Air:TunSafe brite$

上面的Error opening udp是什么意思?如何解决呢?

Melvin Wang • 5 年之前

我的配置
[Interface]
PrivateKey = [hidden]
Address = 10.0.0.3/24
DNS = 8.8.8.8

[Peer]
PublicKey = [hidden]
AllowedIPs = 0.0.0.0/0
Endpoint = vps-ip:51820
PersistentKeepalive = 25

其中[Interface] Address要跟服务器的在同一个IP段

Melvin Wang • 5 年之前

可能UDP端口无法打开,[Interface] 中 ListenPort = 11940 可以去掉,由TunSafe自动选择端口

luckypoem • 5 年之前

hi.

yudeMacBook-Air:tunsafe brite$ sudo ./tunsafe start -n utun9 /etc/wireguard/wg0.conf
Password:
Loading file: /etc/wireguard/wg0.conf
No IPv4 address configured
Run: /sbin/route -q add 192.168.0.0/24 0.0.0.1
add net 192.168.0.0: gateway 0.0.0.1
Sending handshake...
Retrying handshake, attempt 2...
Retrying handshake, attempt 3...
Retrying handshake, attempt 4...
^CCtrl-C detected. Exiting. Press again to force quit.
Run: /sbin/route -q delete 192.168.0.0/24 0.0.0.1
delete net 192.168.0.0: gateway 0.0.0.1
yudeMacBook-Air:tunsafe brite$

又出现了No IPv4 address configured这个错误,
如何解决?谢谢你。

Melvin Wang • 5 年之前

你需要在[Interface]里加入Address = ****/24,要与服务器配置的Address在同一网段,把你服务器配置和客户端配置都贴出来。

luckypoem • 5 年之前

客户端配置文件内容:
[Interface]
PrivateKey = hidden
Address = 10.0.0.2/24
DNS = 8.8.8.8
MTU = 1420

[Peer]
PublicKey = hidden
Endpoint = my-vps-ip:21039
AllowedIPs = 0.0.0.0/0, ::0/0
PersistentKeepalive = 25

服务器端配置文件内容:
[Interface]
PrivateKey = hidden
Address = 10.0.0.1/24
PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -A FORWARD -o wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
PostDown = iptables -D FORWARD -i wg0 -j ACCEPT; iptables -D FORWARD -o wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
ListenPort = 21039
DNS = 8.8.8.8
MTU = 1420

[Peer]
PublicKey = hidden
AllowedIPs = 10.0.0.2/32

然后我在mac上运行:
sudo ./tunsafe start ~/wg-client-from-bwg-kvm-vps.conf
Password:
Loading file: /Users/brite/wg-client-from-bwg-kvm-vps.conf
Run: /sbin/ifconfig utun1 10.0.0.2 mtu 1420 10.0.0.2 netmask 255.255.255.0 up
Run: /sbin/route -q add 10.0.0.0/24 10.0.0.2
add net 10.0.0.0: gateway 10.0.0.2
Run: /sbin/route -q add my-vps-ip/32 10.0.0.1
add net my-vps-ip: gateway 10.0.0.1
Run: /sbin/route -q add 0.0.0.0/1 10.0.0.1
add net 0.0.0.0: gateway 10.0.0.1
Run: /sbin/route -q add 128.0.0.0/1 10.0.0.1
add net 128.0.0.0: gateway 10.0.0.1
Sending handshake...
Connection established. IP 10.0.0.2

但是我访问显示IP的网站,显示的还是我的isp分配给我的ip而非vps的IP。
为什么?如何解决?谢谢你

Melvin Wang • 5 年之前

你这里已经连接上服务器了,10.0.0.1和10.0.0.2应该互相能ping通,ssh 10.0.0.1应该也是通的,证明隧道已经通了。至于访问https://httpbin.org/ip 显示的ip是否是服务器ip要看你本地路由表默认网关否是10.0.0.1。10.0.0.1就相当于10.0.0.0/24子网中的路由器,要把它的优先级提高。这部分不同平台的命令不一样,你可以搜索双网卡默认路由优先级的内容。比较关键的就是/sbin/route -q add 0.0.0.0/1 10.0.0.1这个命令没有效果,你可以用traceroute命令测试路由路径。

luckypoem • 5 年之前

哦,我会做了:
sudo route add vps-public-ip router-ip
sudo route delete default
sudo route add default vps-internal-ip

访问显示IP的网站,显示的就是vps的IP了