Tenho dois servidores VPN (Wireguard e OpenVpn) e meu objetivo é que os clientes conectados a ambos os servidores possam se comunicar entre eles. Digamos que o laptop A esteja conectado ao servidor VPN wireguard e o laptop B esteja conectado ao OpenVpn, devo ser capaz de fazer ping/área de trabalho remota, etc. de A para B. Se A e B estiverem conectados ao servidor wireguard ou openvpn, eles serão capazes para se comunicar corretamente para desktop remoto/ssh/ping etc.
Os servidores são servidores Ubuntu 20 e consigo fazer ping entre si sem nenhum problema.
A configuração é assim:
Proteção de arame:
Public IP: 1.2.3.4
Native IP: 10.0.0.235
Wireguard Server IP: 10.36.135.1
Wireguard Client IP: 10.36.135.2 onwards.
OpenVPN:
Public IP: 4.3.2.1
Native IP: 10.0.0.21
OpenVPN Server IP: 10.187.86.1
OpenVPN Client IP: 10.187.86.1 onwards.
Cada cliente se conecta ao servidor VPN usando o IP público do servidor e obtém o endereço IP do cliente VPN. Por exemplo,
Portátil A:
IP VPN Wireguard: 10.36.135.2
Portátil B:
IP OpenVPN: 10.187.86.2
Posso executar ping em ambos os servidores 10.0.0.XXX de cada cliente sem problemas. No entanto, não consigo executar ping em 10.36.135.2 de 10.187.86.2.
Acho que provavelmente preciso adicionar uma rota em cada servidor para que eles possam se comunicar, mas não tenho certeza de qual rota adicionar.
Capturei algumas informações sobre cada servidor.
Proteção de arame
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9000 qdisc pfifo_fast state UP group default qlen 1000
link/ether 02:00:17:01:90:cd brd ff:ff:ff:ff:ff:ff
altname enp0s3
inet 10.0.0.235/24 brd 10.0.0.255 scope global ens3
valid_lft forever preferred_lft forever
inet6 fe80::17ff:fe01:90cd/64 scope link
valid_lft forever preferred_lft forever
3: wg0: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1420 qdisc noqueue state UNKNOWN group default qlen 1000
link/none
inet 10.36.135.1/24 scope global wg0
valid_lft forever preferred_lft forever
ubuntu@wireguard:~$ route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default _gateway 0.0.0.0 UG 0 0 0 ens3
default _gateway 0.0.0.0 UG 100 0 0 ens3
10.0.0.0 0.0.0.0 255.255.255.0 U 0 0 0 ens3
10.36.135.0 0.0.0.0 255.255.255.0 U 0 0 0 wg0
link-local 0.0.0.0 255.255.0.0 U 0 0 0 ens3
link-local 0.0.0.0 255.255.0.0 U 100 0 0 ens3
ubuntu@wireguard:~$ sudo ip route show table all
default via 10.0.0.1 dev ens3
default via 10.0.0.1 dev ens3 proto dhcp src 10.0.0.235 metric 100
10.0.0.0/24 dev ens3 proto kernel scope link src 10.0.0.235
10.36.135.0/24 dev wg0 proto kernel scope link src 10.36.135.1
169.254.0.0/16 dev ens3 scope link
169.254.0.0/16 dev ens3 proto dhcp scope link src 10.0.0.235 metric 100
local 10.0.0.235 dev ens3 table local proto kernel scope host src 10.0.0.235
broadcast 10.0.0.255 dev ens3 table local proto kernel scope link src 10.0.0.235
local 10.36.135.1 dev wg0 table local proto kernel scope host src 10.36.135.1
broadcast 10.36.135.255 dev wg0 table local proto kernel scope link src 10.36.135.1
local 127.0.0.0/8 dev lo table local proto kernel scope host src 127.0.0.1
local 127.0.0.1 dev lo table local proto kernel scope host src 127.0.0.1
broadcast 127.255.255.255 dev lo table local proto kernel scope link src 127.0.0.1
::1 dev lo proto kernel metric 256 pref medium
fe80::/64 dev ens3 proto kernel metric 256 pref medium
local ::1 dev lo table local proto kernel metric 0 pref medium
local fe80::17ff:fe01:90cd dev ens3 table local proto kernel metric 0 pref medium
multicast ff00::/8 dev ens3 table local proto kernel metric 256 pref medium
multicast ff00::/8 dev wg0 table local proto kernel metric 256 pref medium
ubuntu@wireguard:~$
OpenVPN
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9000 qdisc pfifo_fast state UP group default qlen 1000
link/ether 02:00:17:02:d0:1b brd ff:ff:ff:ff:ff:ff
altname enp0s3
inet 10.0.0.21/24 brd 10.0.0.255 scope global ens3
valid_lft forever preferred_lft forever
inet6 fe80::17ff:fe02:d01b/64 scope link
valid_lft forever preferred_lft forever
3: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UNKNOWN group default qlen 100
link/none
inet 10.187.86.1/24 brd 10.187.86.255 scope global tun0
valid_lft forever preferred_lft forever
inet6 fe80::5c26:311e:f863:db1e/64 scope link stable-privacy
valid_lft forever preferred_lft forever
ubuntu@openvpn:~$ route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default _gateway 0.0.0.0 UG 0 0 0 ens3
default _gateway 0.0.0.0 UG 100 0 0 ens3
10.0.0.0 0.0.0.0 255.255.255.0 U 0 0 0 ens3
10.187.86.0 0.0.0.0 255.255.255.0 U 0 0 0 tun0
link-local 0.0.0.0 255.255.0.0 U 0 0 0 ens3
link-local 0.0.0.0 255.255.0.0 U 100 0 0 ens3
ubuntu@openvpn:~$ sudo ip route show table all
default via 10.0.0.1 dev ens3
default via 10.0.0.1 dev ens3 proto dhcp src 10.0.0.21 metric 100
10.0.0.0/24 dev ens3 proto kernel scope link src 10.0.0.21
10.187.86.0/24 dev tun0 proto kernel scope link src 10.187.86.1
169.254.0.0/16 dev ens3 scope link
169.254.0.0/16 dev ens3 proto dhcp scope link src 10.0.0.21 metric 100
local 10.0.0.21 dev ens3 table local proto kernel scope host src 10.0.0.21
broadcast 10.0.0.255 dev ens3 table local proto kernel scope link src 10.0.0.21
local 10.187.86.1 dev tun0 table local proto kernel scope host src 10.187.86.1
broadcast 10.187.86.255 dev tun0 table local proto kernel scope link src 10.187.86.1
local 127.0.0.0/8 dev lo table local proto kernel scope host src 127.0.0.1
local 127.0.0.1 dev lo table local proto kernel scope host src 127.0.0.1
broadcast 127.255.255.255 dev lo table local proto kernel scope link src 127.0.0.1
::1 dev lo proto kernel metric 256 pref medium
fe80::/64 dev ens3 proto kernel metric 256 pref medium
fe80::/64 dev tun0 proto kernel metric 256 pref medium
local ::1 dev lo table local proto kernel metric 0 pref medium
local fe80::17ff:fe02:d01b dev ens3 table local proto kernel metric 0 pref medium
local fe80::5c26:311e:f863:db1e dev tun0 table local proto kernel metric 0 pref medium
multicast ff00::/8 dev ens3 table local proto kernel metric 256 pref medium
multicast ff00::/8 dev tun0 table local proto kernel metric 256 pref medium
ubuntu@openvpn:~$