0

I'm sorry if this problem has already been explained in another thread, but I couldn't find a solution to my problem anywhere.

I have a question about the attached network diagram. Can I permanently share the port of any service from the host 192.168.1.21 under router R2 to the host 192.168.1.121 under router R1? There is a 192.168.1.112 server in the network under router R1, which is connected to the 192.168.1.20 server under router R2 via the tun0 network (OpenVPN).

I am able to successfully tunnel the ports via SSH, but I would like a permanent solution. I will be grateful for your help.

All servers have a Linux operating system.

diagram

EDIT: 2024-03-08

I changed the address inside the network under R2 to 192.168.2.0.I added routes to both routers. Below is the result after executing tracert on PC1.

tracert 1

tracert 2

the router's website (192.168.2.1) is not displayed in the browser. The address 192.168.2.21 should lead to another server. The 192.168.2.21 server can be pinged without any problems inside the 192.168.2.0 network.

Tracert from 192.168.2.21 to 192.168.1.1

tracert

router configuration 192.168.1.1

R1 config

router configuration 192.168.2.1

R2 config

server configuration

local 192.168.1.112
port 1194
proto tcp4
dev tun
ca ca.crt
cert server-dell.crt
key server-dell.key  # This file should be kept secret
dh dh2048.pem
server 10.8.0.0 255.255.255.0
#ifconfig 10.8.0.1 255.255.255.0
ifconfig-pool-persist /var/log/openvpn/ipp.txt
client-config-dir ccd
;push "route 192.168.1.0 255.255.255.0"
;push "route 10.8.0.0 255.255.255.0"
;push "route 192.168.2.0 255.255.255.0"
;route 192.168.2.0 255.255.255.0
client-to-client
push "route 192.168.1.0 255.255.255.0"
push "route 10.8.0.0 255.255.255.0"
push "route 192.168.2.0 255.255.255.0"
route 192.168.2.0 255.255.255.0
keepalive 10 120
tls-auth ta.key 0 # This file is secret
cipher AES-256-CBC
status /var/log/openvpn/openvpn-status.log
verb 3

ccd configuration

ifconfig-push 10.8.0.10 255.255.255.0
iroute 192.168.2.0 255.255.255.0

I tried different configuration variant.

Edit: 2024-03-09

from PC1 level (192.168.1.120) I am able to display the service from 10.8.0.1 in the browser but I am not able to display the service from 10.8.0.10 or 192.168.2.20. From vm windows 10 (192.168.2.22) I am able to display the service from the address 192.168.1.112. The client's LAN sees the openvpn server's LAN as if the server's LAN does not see the client's LAN.

EDIT 2024-03-10

don't know if it is important, but the client of the tun0 network is another host from the same LAN. The host IP is 192.168.2.115. It's not in the diagram

EDIT: 2024-03-11

After adding the appropriate rules in iptables, my openVPN server (10.8.0.1 or 192.168.1.112) is now able to ping LAN machines on the client side and display programs in the browser (e.g. Webmin). Unfortunately, from the LAN level on the server side (e.g. PC1 192.168.2.120) I am not able to ping the machines on the client's LAN side (e.g. Webadmin does not work).

EDNIT 2024-03-12

Success. I finally managed to make a LAN to LAN connection. The solution was the following commands executed on the OpenVPN server.

iptables -t nat -A POSTROUTING -o enp2s0  -j MASQUERADE
iptables -A INPUT -i tun0 -j ACCEPT
iptables -A FORWARD -i tun0 -o enp2s0 -J ACCEPT
iptables -A FORWARD -i tun0 -o enp2s0 -j ACCEPT
iptables -A FORWARD -i enp2s0 -o tun0 -j ACCEPT
8
  • Not as shown in the diagram. The easiest way is probably directly attaching your VMs to the 10.8.0.0 vpn network. Otherwise, the R1 and R2 networks need to be separate for basic routing, like 192.168.1.0/24 and 192.168.2.0/24. Then you could add a route on R1 or PC1 to the R2 network via the vpn server for example, but currently PC1 would assume the R2 network is directly attached
    – Cpt.Whale
    Commented Feb 22 at 17:54
  • I changed the network address for R2 and now it is 192.168.2.0. I have configured the OpenVPN server and now the server can ping 192.168.2.1 but PC1 cannot. Can I ask for some advice?
    – Vodek
    Commented Mar 8 at 14:10
  • Does PC1 or R1 have a route to the 192.168.2.0/24 network? You may be able to tell with tracert 192.168.2.1 for example, and see if the next hops go through the vpn or out to the internet instead
    – Cpt.Whale
    Commented Mar 8 at 15:15
  • I added additional information about tracert in the content
    – Vodek
    Commented Mar 8 at 16:40
  • It looks like the route on R1 is working correctly, but maybe not on R2 - do the routers have ping/tracert tools? Can you try and tracert from a VM like 192.168.2.21 to R1?
    – Cpt.Whale
    Commented Mar 8 at 17:08

0

You must log in to answer this question.

Browse other questions tagged .