我在我的树莓派中设置了 OpenVpn,它工作正常,我可以从我的手机登录我的树莓派。我还为我的树莓派安装了付费 VPN(Windscribe)。当我windscribe connect
在我的树莓派中激活我的付费 vpn (windscribe) 时,问题就来了。在那之后,我再也无法用手机接触到我的覆盆子了。
我想要 OpenVPN(PiVPN),这样我就可以访问我的家庭网络,并且我想要 windscribe vpn 也可以激活以安全地浏览互联网。现在我有第一部分。当 Windscribe 不活动时,我可以访问我的家庭网络。
我一直在尝试使用 iptables 并没有成功,为接口、隧道和许多组合制定转发规则,但似乎没有任何效果。最后我重置了一切。
这是我的配置。
sudo iptables -t nat -S
-P PREROUTING ACCEPT
-P INPUT ACCEPT
-P POSTROUTING ACCEPT
-P OUTPUT ACCEPT
-A POSTROUTING -s 10.8.0.0/24 -o wlan0 -m comment --comment openvpn-nat-rule -j MASQUERADE
-A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE
pi@raspberrypi:~ $ sudo iptables -S
-P INPUT ACCEPT
-P FORWARD ACCEPT
-P OUTPUT DROP
-A OUTPUT ! -o tun+ -p tcp -m tcp --dport 53 -j DROP
-A OUTPUT ! -o tun+ -p udp -m udp --dport 53 -j DROP
-A OUTPUT -d 192.168.0.0/16 -j ACCEPT
-A OUTPUT -d 10.0.0.0/8 -j ACCEPT
-A OUTPUT -d 172.16.0.0/12 -j ACCEPT
-A OUTPUT -d 104.20.26.217/32 -j ACCEPT
-A OUTPUT -d 104.20.27.217/32 -j ACCEPT
-A OUTPUT -d 172.67.17.175/32 -j ACCEPT
-A OUTPUT -d 104.21.93.29/32 -j ACCEPT
-A OUTPUT -d 172.67.203.127/32 -j ACCEPT
-A OUTPUT -d 104.21.53.216/32 -j ACCEPT
-A OUTPUT -d 172.67.219.39/32 -j ACCEPT
-A OUTPUT -d 172.67.189.40/32 -j ACCEPT
-A OUTPUT -d 104.21.65.74/32 -j ACCEPT
-A OUTPUT -o tun+ -j ACCEPT
-A OUTPUT -d 127.0.0.1/32 -j ACCEPT
-A OUTPUT -d 209.58.129.121/32 -j ACCEPT
pi@raspberrypi:~ $ ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.111 netmask 255.255.255.0 broadcast 192.168.0.255
ether b8:27:eb:ec:6a:4b txqueuelen 1000 (Ethernet)
RX packets 19989 bytes 21885907 (20.8 MiB)
RX errors 160 dropped 4 overruns 0 frame 0
TX packets 11508 bytes 1206589 (1.1 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
loop txqueuelen 1000 (Local Loopback)
RX packets 618 bytes 201828 (197.0 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 618 bytes 201828 (197.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
tun0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST> mtu 1500
inet 10.8.0.1 netmask 255.255.255.0 destination 10.8.0.1
unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 100 (UNSPEC)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
tun1: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST> mtu 1500
inet 10.120.138.29 netmask 255.255.254.0 destination 10.120.138.29
unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 100 (UNSPEC)
RX packets 164 bytes 32755 (31.9 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 961 bytes 114896 (112.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlan0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether b8:27:eb:b9:3f:1e txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
pi@raspberrypi:~ $ ip route list
0.0.0.0/1 via 10.120.138.1 dev tun1
default via 192.168.0.1 dev eth0 src 192.168.0.111 metric 202
10.8.0.0/24 dev tun0 proto kernel scope link src 10.8.0.1
10.120.138.0/23 dev tun1 proto kernel scope link src 10.120.138.29
128.0.0.0/1 via 10.120.138.1 dev tun1
192.168.0.0/24 dev eth0 proto dhcp scope link src 192.168.0.111 metric 202
209.58.129.121 via 192.168.0.1 dev eth0
pi@raspberrypi:~ $ ip rule list
0: from all lookup local
32766: from all lookup main
32767: from all lookup default
更新:我找到了本教程,它帮助了我很多 comparitech.com/blog/vpn-privacy/raspberry-pi-vpn 。但是我发现当我设置这两条规则时
ip rule add from 192.168.1.2 lookup 101
ip route add default via 192.168.1.1 table 101
我可以访问 vpn,但我无法像以前那样使用 192.168.0.111 ping 我的 vpn 服务器,现在我必须使用 10.8.0.1。Any Ideas how to enable ping to 192.168.0.111 – tseres 12 分钟前 删除