1

I'm connecting two networks (Clients A and B) together using OpenVPN. Let's say Client A is behind a NAT with IP addresses 192.168.20.x and Client B is behind a NAT with IP Addresses 172.16.1.x. Is there a way I can configure my setup such that the clients can communicate with machines inside each other's subnets through an OpenVPN server (10.8.0.1, 255.255.255.0)?

For example, if Client A's internal IP is 192.168.20.50 and Client B is 172.16.1.50, is there any way that Client A can ping or tracert to Client B successfully using its private IP address?

Max Cohen
  • 11
  • 2

1 Answers1

0

Yes, it is possible.

Each end of the tunnel must have interfaces in respective end's private networks. That is, for example 10.8.0.1 must have an address in 192.168.20.0/24 network and 10.8.0.2 must have an address in 172.16.1.0/24 network (I guessed the netmasks for the networks just for example, your setup might be different).

Then, you need to enable proper routing on the devices.

For clients in 192.168.20.0/24 network, they need to have a route in their routing table that tells them to route packets to 172.16.1.0/24 via 192.168.20.x, where x is the octet corresponding to the other interface of the 10.8.0.1 server.

Then, the server at 10.8.0.1 has to have a routing table entry which tells that packets to 172.16.1.0/24 network have to be sent via 10.8.0.2, that is, the other end of the tunnel.

Then you need to have corresponding rules for the other end of the tunnel, swapping network addresses.

Easiest way to implement this is to run the OpenVPN server / client on the router for that network. Then one doesn't need to add the routing rules for each client, since the routing is handled by the default gateway. In this case, one only need the routing rule at the OpenVPN server / client.

If OpenVPN server / client is a different machine than the default router, then one needs to distribute the network routes to the clients. One way to do this is via DHCP. One method is described in How can I configure my DHCP server to distribute IP routes?.

Tero Kilkanen
  • 34,499
  • 3
  • 38
  • 58