Instalei o OpenVPN (PiVPN para ser mais específico) em um Raspberry Pi, e até acho que consegui me conectar à Internet através do túnel VPN após a instalação, mas agora ele não funciona mais. Posso conectar-me ao servidor VPN usando um terminal SSH quando a conexão VPN é estabelecida, mas não consigo acessar nenhuma outra máquina na rede local ou na Internet. É como se uma rota estivesse faltando.
Aqui estão os detalhes da minha instalação:
SO: Raspbian GNU/Linux 9 (stretch)
Versão do OpenVPN: 2.4.0
Saída de 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
Saída de 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 é minha LAN e 10.8.0.0 é a rede virtual VPN.
Saída de 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
Algo errado no meu roteamento impedindo que os pacotes encontrem seu caminho de uma sub-rede para outra? Quando conectado ao servidor VPN, não posso nem ping 8.8.8.8
da máquina cliente.
UPDATE: Adicionando o meu arquivo server.conf Open VPN:
Alguém pode me dizer o que route 0.0.0.0
significa?
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