Vpn

流量不會通過 vpn 路由

  • December 21, 2018

正確設置tincVPN 節點(vpn 連接有效):我設置了以下選項

net.ipv4.ip_forward =  1
iptables -t nat -A POSTROUTING -o ens2 -j MASQUERADE

如果我然後在我的客戶端上設置路線

# need this rule to connect vpn after changing default GW
ip route add $VPN_PUBLIC_ADDR via $NETWORK_GATEWAY 
ip route del default
# route traffic through vpn
ip route add default via $VPN_PRIVATE_IP

我只能訪問vpn中的主機->流量沒有被轉發,只是vpn連接正常。

我錯過了什麼?如何分析問題的原因?

**編輯:**在 vpn 伺服器端沒有設置防火牆(據我所知)

iptables -t nat -L
Chain PREROUTING (policy ACCEPT)
target     prot opt source               destination         

Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         

Chain POSTROUTING (policy ACCEPT)
target     prot opt source               destination         
MASQUERADE  all  --  anywhere             anywhere  

問題顯然出在我的 tinc 網路中:

Address = Not connectable
Subnet = 172.16.0.10/32 # Here is supposed to be the subnets tinc can route to

-----BEGIN RSA PUBLIC KEY-----
pubkey
-----END RSA PUBLIC KEY-----

更改子網(參見程式碼)有幫助

引用自:https://serverfault.com/questions/945565