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 (,

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


Yes, it is possible.

Each end of the tunnel must have interfaces in respective end's private networks. That is, for example must have an address in network and must have an address in 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 network, they need to have a route in their routing table that tells them to route packets to via 192.168.20.x, where x is the octet corresponding to the other interface of the server.

Then, the server at has to have a routing table entry which tells that packets to network have to be sent via, 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?.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.