建立 VPN 隧道后能够通过 ssh 进入 OpenVPN 服务器,但无法连接到服务器端 LAN 或互联网上的其他机器

建立 VPN 隧道后能够通过 ssh 进入 OpenVPN 服务器,但无法连接到服务器端 LAN 或互联网上的其他机器

我在Raspberry Pi上安装了OpenVPN(更具体地说是PiVPN),我什至认为安装后我可以通过VPN隧道连接到互联网,但现在它不再工作了。建立 VPN 连接后,我可以使用 SSH 终端连接到 VPN 服务器,但无法访问 LAN 或 Internet 上的任何其他计算机。就好像缺少了一条路线。

以下是我的安装详细信息:

操作系统:Raspbian GNU/Linux 9 (stretch)

OpenVPN版本:2.4.0

输出来自ifconfig

enxb827ebd63367: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.0.1.16  netmask 255.0.0.0  broadcast 10.255.255.255
        inet6 fe80::7bc4:3085:b661:9a31  prefixlen 64  scopeid 0x20<link>
        ether b8:27:eb:d6:33:67  txqueuelen 1000  (Ethernet)
        RX packets 31518  bytes 22185202 (21.1 MiB)
        RX errors 0  dropped 24  overruns 0  frame 0
        TX packets 7395  bytes 632561 (617.7 KiB)
        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
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1  (Local Loopback)
        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

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
        inet6 fe80::de9a:e04b:bfbe:ba61  prefixlen 64  scopeid 0x20<link>
        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 29  bytes 1392 (1.3 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

输出来自sudo route -n

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.0.1.1        0.0.0.0         UG    202    0        0 enxb827ebd63367
10.0.0.0        0.0.0.0         255.0.0.0       U     202    0        0 enxb827ebd63367
10.8.0.0        0.0.0.0         255.255.255.0   U     0      0        0 tun0

10.0.1.0 是我的 LAN,10.8.0.0 是 VPN 虚拟网络。

输出来自sudo iptables -S -t nat

-P PREROUTING ACCEPT
-P INPUT ACCEPT
-P OUTPUT ACCEPT
-P POSTROUTING ACCEPT
-A POSTROUTING -s 10.8.0.0/24 -o enxb827ebd63367 -j MASQUERADE

我的路由有什么问题导致数据包无法从一个子网到达另一个子网吗?当连接到 VPN 服务器时,我什至无法ping 8.8.8.8从客户端计算机连接。

更新:添加我的 Open VPN server.conf 文件:

有人能告诉我什么route 0.0.0.0意思吗?

dev tun
proto udp
port 1194
ca /etc/openvpn/easy-rsa/pki/ca.crt
cert /etc/openvpn/easy-rsa/pki/issued/server.crt
key /etc/openvpn/easy-rsa/pki/private/server.key
dh /etc/openvpn/easy-rsa/pki/dh2048.pem
topology subnet
server 10.8.0.0 255.255.255.0
# server and remote endpoints
ifconfig 10.8.0.1 10.8.0.2
# I ADDED THIS ROUTE BUT IT DID NOT HELP: Route to LAN
push "route 10.0.1.0 255.255.255.0"
# Add route to Client routing table for the OpenVPN Server
push "route 10.8.0.1 255.255.255.255"
# Add route to Client routing table for the OPenVPN Subnet
push "route 10.8.0.0 255.255.255.0"
# your local subnet
push "route 0.0.0.0 "
# Set your primary domain name server address for clients
push "dhcp-option DNS 8.8.8.8"
push "dhcp-option DNS 8.8.4.4"
# Override the Client default gateway by using 0.0.0.0/1 and
# 128.0.0.0/1 rather than 0.0.0.0/0. This has the benefit of
# overriding but not wiping out the original default gateway.
push "redirect-gateway def1"
client-to-client
duplicate-cn
keepalive 10 120
tls-version-min 1.2
tls-auth /etc/openvpn/easy-rsa/pki/ta.key 0
cipher AES-256-CBC
auth SHA256
comp-lzo
user nobody
group nogroup
persist-key
persist-tun
#crl-verify /etc/openvpn/crl.pem
status /var/log/openvpn-status.log 20
status-version 3
log /var/log/openvpn.log
verb 1

相关内容