1

Brief description

I've got two systems, a VPS which is connected directly to the internet, and a system in my basement behind my router (NAT). I'd like to take the VPS and forward all requests on one of it's IP addresses, on any port, to the system in my basement.

I've connected the two using OpenVPN, and I successfully accomplished what I set out to do- I can use the following procedure to forward all requests on the IP to the machine in my basement.

  1. Connect machines via OpenVPN
  2. Run the following command on the internet facing VPS iptables -t nat -A PREROUTING -d public.facing.vps.ip -j DNAT --to-destination basement.computer.vpn.ip
  3. Run the following commands on the basement machine echo '100 VPN' >> /etc/iproute2/rt_tables (only once) ip rule add from vpn.subnet/24 table VPN ip route add default via vpn.gateway.ip table VPN

This works consistently, but I took the final set of commands from this article which talks strictly about it in the context of GRE tunnels, and I've had a very difficult time trying to understand the meaning in the last step.

My question

Is it possible to have OpenVPN server, or configure the client, to automatically do the (policy based?) routing to return packets through the tunnel?

I'm unsure as to the exact meaning of the bottom set of commands, which is why I've found it tricky to 'translate' them from their current expression into an openvpn 'route'

It seems that they are something called 'policy based routing'- when a packet comes from the vpn subnet, it will route it back through the vpn gateway (by changing it's routing table to 'VPN')

I'd like to have this done automatically by OpenVPN because I would presume OpenVPN can perform a similar act on windows, something I've yet to figure it. It'd also be nice to have this done automatically so that I could then automate the iptables rule for forwarding traffic on a public IP to a VPN client.

Files

Configuration Files

Your Answer

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

Browse other questions tagged or ask your own question.