Estou tentando fazer com que um servidor OpenVPN funcione no meu Raspberry Pi. O Raspberry Pi está executando o Arch Linux com o OpenVPN versão 2.3.8-2.
Atualmente, consigo conectar-me ao servidor a partir do dispositivo Android, mas não consigo acessar a Internet (no entanto, posso acessar o dispositivo que hospeda o servidor OpenVPN pingando seu endereço eth0 192.168.86.3 ou pingando-o sobre tun0 em 10.8 .0.1). Eu tentei muitas configurações diferentes com o servidor OpenVPN e iptables, mas ainda não tive sorte e gostaria de ajuda.
Aqui está a configuração do meu servidor:
port 443
proto tcp
dev tun0
ca /etc/openvpn/keys/ca.crt
cert /etc/openvpn/keys/key.crt
key /etc/openvpn/keys/key.key
dh /etc/openvpn/keys/dh4096.pem
tls-auth /etc/openvpn/keys/ta.key 0
user nobody
group nobody
server 10.8.0.0 255.255.255.0
persist-key
persist-tun
ifconfig-pool-persist ipp.txt
topology subnet
push "redirect-gateway def1"
push "route 192.168.86.0 255.255.255.0"
push "dhcp-option DNS 8.8.8.8"
push "dhcp-option DNS 192.168.86.1"
keepalive 10 120
comp-lzo
status openvpn-status.log
log-append /var/log/openvpn.log
verb 4
Configuração do meu cliente:
client
dev tun
proto tcp
remote SERVER_IP 443
resolv-retry infinite
nobind
user nobody
group nobody
persist-key
persist-tun
<ca>
-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----
</ca>
<cert>
-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----
</cert>
<key>
-----BEGIN PRIVATE KEY-----
...
-----END PRIVATE KEY-----
</key>
key-direction 1
<tls-auth>
-----BEGIN OpenVPN Static key V1-----
...
-----END OpenVPN Static key V1-----
</tls-auth>
comp-lzo
verb 3
Saída da rota em execução no dispositivo Android:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.8.0.0 * 255.255.255.0 U 0 0 0 tun0
Regras do iptables no servidor:
# Generated by iptables-save v1.4.21 on Mon Nov 9 20:43:23 2015
*mangle
:PREROUTING ACCEPT [5137:447124]
:INPUT ACCEPT [3884:334912]
:FORWARD ACCEPT [624:36889]
:OUTPUT ACCEPT [2554:269872]
:POSTROUTING ACCEPT [3178:306761]
COMMIT
# Completed on Mon Nov 9 20:43:23 2015
# Generated by iptables-save v1.4.21 on Mon Nov 9 20:43:23 2015
*nat
:PREROUTING ACCEPT [737:37974]
:INPUT ACCEPT [413:18792]
:OUTPUT ACCEPT [7:508]
:POSTROUTING ACCEPT [0:0]
-A POSTROUTING -o eth0 -j MASQUERADE
COMMIT
# Completed on Mon Nov 9 20:43:23 2015
# Generated by iptables-save v1.4.21 on Mon Nov 9 20:43:23 2015
*filter
:INPUT ACCEPT [3878:334408]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [2564:271200]
-A INPUT -i tun+ -j ACCEPT
-A FORWARD -i tun+ -j ACCEPT
COMMIT
# Completed on Mon Nov 9 20:43:23 2015
O ping 8.8.8.8 falha. O ping 10.8.0.1 é bem-sucedido. O ping 192.168.86.3 também é bem-sucedido.
Editar: detalhes adicionais adicionados
Aqui está a saída do ifconfig no servidor:
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.86.3 netmask 255.255.255.0 broadcast 192.168.86.255
inet6 fe80::30a2:e462:a8e7:64b8 prefixlen 64 scopeid 0x20<link>
ether b8:27:eb:59:26:90 txqueuelen 1000 (Ethernet)
RX packets 39226 bytes 8815553 (8.4 MiB)
RX errors 0 dropped 100 overruns 0 frame 0
TX packets 14621 bytes 1395612 (1.3 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
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 0 (Local Loopback)
RX packets 131 bytes 10414 (10.1 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 131 bytes 10414 (10.1 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 4719 bytes 369475 (360.8 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 12 bytes 984 (984.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
E o resultado da execução do "traceroute 8.8.8.8" do cliente, enquanto eu estou nisso.
traceroute to 8.8.8.8 (8.8.8.8), 64 hops max, 52 byte packets
1 10.8.0.1 (10.8.0.1) 2.718 ms 5.771 ms 2.981 ms
2 * * *
3 * * *
4 * * *
// And so on...
Editar: informações adicionais
Saída de sysctl -n net.ipv4.ip_forward
1