Hi there! I've read a lot of posts and troubleshooting regarding my problem. Unfortunately, I can't figure out where the problem is. I can really use some help.
With that, from the VPS (185.28.23.108) I try to ping 192.168.200.1.
Using tcpdump I was able to see the package going through tun0 interface (VPS -> Client). From client to internal network (Client -> Second device).
However, the package doesn't return.
If you like to access devices inside client lan you need perform ip forward and NAT at client openvpn . Your server and all route info but it stop at client as it need routing between virtual network and client lan network.
Re: Msg not returning. Route problem
Posted: Mon Jan 09, 2023 10:19 pm
by thalesmaoa
Thanks! I'm aware of that. I think I got it write, but probably I'm missing something.
thales@vps:~$ ip r
default dev venet0 scope link
10.254.254.0/24 dev tun0 proto kernel scope link src 10.254.254.1
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1
172.18.0.0/16 dev br-d28d8278c890 proto kernel scope link src 172.18.0.1
185.28.23.0/24 dev venet0 proto kernel scope link src 185.28.23.109
192.168.200.0/24 via 10.254.254.2 dev tun0
It seems correct. All 192.168.200.0/24 is being redirected to the client 10.254.254.2. This is why I see the package going out.
user@user-virtual-machine:~$ ip r
default via 10.254.254.1 dev tun0 proto static metric 50
default via 192.168.200.1 dev ens33 proto dhcp metric 20100
10.254.254.0/24 dev tun0 proto kernel scope link src 10.254.254.2 metric 50
169.254.0.0/16 dev ens33 scope link metric 1000
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 linkdown
185.28.23.0/24 via 10.254.254.1 dev tun0 proto static metric 50
185.28.23.109 via 192.168.200.1 dev ens33 proto static metric 100
192.168.200.0/24 via 10.254.254.1 dev tun0 proto static metric 50
192.168.200.0/24 dev ens33 proto kernel scope link src 192.168.200.87 metric 100
192.168.200.1 dev ens33 proto static scope link metric 100
It also seems correct. When trying to reach my VPS 185.28.33.0/24, it uses the server IP 10.254.254.1.
Similarly, if the client machine running OpenVPN is not also the gateway for the client LAN, then the gateway for the client LAN must have a route which directs all subnets which should be reachable through the VPN to the OpenVPN client machine.
Ok! I'm confused. I saw so many successful attempts over the internet. Do I really need to make the client the gateway of my LAN?
I have a gateway with ip 192.168.200.254. I'm using a client 192.168.200.78 to connect VPN.
I'm trying to ping 192.168.200.254 over the tun0 interface from VPS.
If I SNAT to 10.254.254.1, it comes back. But I can't understand why it doesn't for the public IP.
Re: Msg not returning. Route problem
Posted: Thu Jan 12, 2023 5:36 pm
by 300000
You mess up iptables so only you can deal with that. Just remember you need ip forward and NAT at both server and client as they become node for each point of connection. Make sure name of certificate is the same file name in CDD folder if not server cant add correctly route. Let server add route by itself not by you
You cant use site to site with this one. Remove it and try again
push "redirect-gateway def1 bypass-dhcp"
Re: Msg not returning. Route problem
Posted: Fri Jan 13, 2023 10:13 pm
by thalesmaoa
You are entirely correct.
I finally found the source of the problem, but I can't fix it.
How did I found it, I was looking at my monitor for a while, just thinking about what was going on, and suddenly ping start to come.
I was like... wtf?
My config is correct, but why it took so much time ~3min to reply? I think that this is about some DNS problem, which doesn't occur using MASQUERADE.
So here is my final conf:
Server Config
local 89.117.32.207
port 1194
proto udp
dev tun
ca ca.crt
cert server.crt
key server.key
dh dh.pem
auth SHA512
tls-crypt tc.key
topology subnet
server 10.254.254.0 255.255.255.0
push "redirect-gateway def1 bypass-dhcp"
ifconfig-pool-persist ipp.txt
push "dhcp-option DNS 8.8.8.8"
push "dhcp-option DNS 8.8.4.4"
push "block-outside-dns"
keepalive 10 120
cipher AES-256-CBC
user nobody
group nogroup
persist-key
persist-tun
verb 3
crl-verify crl.pem
explicit-exit-notify