title: OpenVPN - How do you NAT a client to another client's network
body: <p>I have a openVPN server setup on a AWS instance and I would like to use it to route traffic from my home client (client1, 192.168.0.0/24) to a client(client2, 10.81.0.0/16) on a machine on a second network through the openVPN server. I want to route the connections from client1 to client2's network so that I can connect to several devices in client2's network. However I dont have control over the gateway in client2's network so I can't add a route back to the vpn.</p>
  <p>As far as I can tell I have the openVPN configuration setup in that once client1 and client2 are connected I can access client2 from client1, the routes are also setup so that if I ping a machine on client2's network the traffic is routed through the vpn but no response happens as client2's network devices do not know how to route the vpn ips back to client2.</p>
  <p>I am assuming that I need to setup nat masqurading at client2 but I am unsure how to properly handle this as I am not that familiar with iptables.</p>
  <p>tried on client2:</p>
  <pre><code>iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE
  </code></pre>
  <p>server.conf</p>
  <pre><code>port 1194
  proto udp
  dev tun
  user nobody
  group nogroup
  persist-key
  persist-tun
  keepalive 10 120
  topology subnet
  server 10.8.0.0 255.255.255.0
  ifconfig-pool-persist ipp.txt
  client-to-client
  route 10.81.0.0 255.255.0.0
  push &quot;route 10.81.0.0 255.255.0.0&quot;
  dh none
  ecdh-curve prime256v1
  ... encryption info ...
  client-config-dir /etc/openvpn/ccd
  status /var/log/openvpn/status.log
  verb 3
  </code></pre>
  <p>ccd/client2</p>
  <pre><code>iroute 10.81.0.0 255.255.0.0
  </code></pre>