I am trying to connect OpenVPN Server lan and client lan. OpenVPN Server is running in AWS VPC and OpenVPN Client running in in office lan.
Here is a diagram :
After reading through the [
https://openvpn.net/community-resources/how-to/]doc[/url] I have Routing table for OpenVPN Server
$ route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.2.2.1 0.0.0.0 UG 100 0 0 ens5
10.2.2.0 0.0.0.0 255.255.255.0 U 0 0 0 ens5
10.2.2.1 0.0.0.0 255.255.255.255 UH 100 0 0 ens5
10.8.0.0 0.0.0.0 255.255.255.0 U 0 0 0 tun0
Routing table for OpenVPN Client
$ route -n
Kernel IP routing table
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.8.0.1 128.0.0.0 UG 0 0 0 tun0
0.0.0.0 10.24.11.1 0.0.0.0 UG 202 0 0 eth0
10.8.0.0 0.0.0.0 255.255.255.0 U 0 0 0 tun0
10.24.11.0 0.0.0.0 255.255.255.0 U 202 0 0 eth0
38.xxx.225.181 10.24.11.1 255.255.255.255 UGH 0 0 0 eth0
128.0.0.0 10.8.0.1 128.0.0.0 UG 0 0 0 tun0
I have disabled
Source/Destination Check for OpenVPN Server (EC2 Instance), enabled IP forwarding (net.ipv4.ip_forward = 1) on OpenVPN Server & OpenVPN Client.
added route for 10.24.11.0/24 & 10.8.0.0/24 in VPC route table pointing to OpenVPN Server interface.
After doing this configuration I am able to ping 10.2.1.145 from OpenVPN Client and OpenVPN Client on tun0 ip (10.8.0.2) from 10.2.1.145, but can't ping local lan ip (10.24.11.0) of the OpenVPN Client from 10.2.1.145. I tried adding route for 10.24.11.0/24 network
sudo ip route add 10.24.11.0/24 via 10.8.0.2 dev tun0
on OpenVPN Server. But still was not able to ping.
OpenVPN Server Routing table after added routes.
$ route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.2.2.1 0.0.0.0 UG 100 0 0 ens5
10.2.2.0 0.0.0.0 255.255.255.0 U 0 0 0 ens5
10.2.2.1 0.0.0.0 255.255.255.255 UH 100 0 0 ens5
10.8.0.0 0.0.0.0 255.255.255.0 U 0 0 0 tun0
10.24.11.0 10.8.0.2 255.255.255.0 UG 0 0 0 tun0
Also to ping 10.2.1.145 from 10.24.11.37, I added
route add -net 10.8.0.0 netmask 255.255.255.0 gw 10.24.11.235
route add -net 10.2.0.0 netmask 255.255.0.0 gw 10.24.11.235
on 10.24.11.37. But not able to ping it.
I want to make subnets from both side can talk to each other via OpenVPN tunnel. Any help is appreciated.