I am trying to set up a server that can on one hand connect to an OpenVPN server (Server 1) as client, and act as a OpenVPN server itself (Server 2). The server (server 2) would then route all the data from its clients to its server (Server 1).
When the the Server (Server 2) is connected to the main VPN server (Server 1), its ip becomes unreachable. The reason is that all traffic goes through the VPN. This means that there is no way to connect to it as a client. I have also turned off routing all the data when the server (Server 2) is connected to the main server (Server 1) in order to bridge the interfaces tun0 (Server 2 to the clients) and tun1 (Server 1 to Server 2) but this also did not work.
I have been experimenting with routing tables and interfaces etc. for two days now but I was not able to make it work. Also variations of this answer did not help.
Current OpenVPN Server 1 to Server 2 client configuration:
client
dev tun
proto tcp
remote X.X.X.X XX
resolv-retry infinite
nobind
persist-key
persist-tun
remote-cert-tls server
auth SHA512
cipher AES-256-CBC
ignore-unknown-option block-outside-dns
block-outside-dns
verb 3
--pull-filter ignore redirect-gateway
Current Interfaces:
docker0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
tun0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST> mtu 1500
tun1: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST> mtu 1500
veth92e943f: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
Current IP Table:
-P INPUT ACCEPT
-P FORWARD ACCEPT
-P OUTPUT ACCEPT
-N DOCKER
-N DOCKER-ISOLATION-STAGE-1
-N DOCKER-ISOLATION-STAGE-2
-N DOCKER-USER
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
-A FORWARD -j DOCKER-USER
-A FORWARD -j DOCKER-ISOLATION-STAGE-1
-A FORWARD -o docker0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -o docker0 -j DOCKER
-A FORWARD -i docker0 ! -o docker0 -j ACCEPT
-A FORWARD -i docker0 -o docker0 -j ACCEPT
-A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -s 10.8.0.0/24 -j ACCEPT
-A DOCKER-ISOLATION-STAGE-1 -i docker0 ! -o docker0 -j DOCKER-ISOLATION-STAGE-2
-A DOCKER-ISOLATION-STAGE-1 -j RETURN
-A DOCKER-ISOLATION-STAGE-2 -o docker0 -j DROP
-A DOCKER-ISOLATION-STAGE-2 -j RETURN
-A DOCKER-USER -j RETURN
Current routing table:
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 XX.XX.XX.1 0.0.0.0 UG 100 0 0 eth0
10.8.0.0 0.0.0.0 255.255.255.0 U 0 0 0 tun0
10.8.0.0 0.0.0.0 255.255.255.0 U 0 0 0 tun1
XX.XX.XX.0 0.0.0.0 255.255.252.0 U 0 0 0 eth0
169.254.169.254 XX.XX.XX.10 255.255.255.255 UGH 100 0 0 eth0
172.17.0.0 0.0.0.0 255.255.0.0 U 0 0 0 docker0
I would appreciate your help.