I have the following setup:

  • 1 VPS with public IP 222 running Wordpress
  • 1 VPS with public IP 444 running OpenVPN server

The login pages of the Webserver are restricted to requests from 444 using ufw to prevent any bruteforce attempts. To setup the VPN server I used the following script: https://github.com/Nyr/openvpn-install It forwards all VPN traffic to its public IP 444. So far, so good.

Now my hosting provider offers virtual networks for internal routing. The webserver has e.g. and the VPN Server What I want is that the VPN server routes all traffic addressed to 222 through its interface to All other traffic should go to the public interface 444. How do I set this up (Ubuntu 20.40)?


The basic setup here is to add routes On VPN server: ip route add 222 via dev x The webserver needs to allow this traffic, and also route back.

When you have these basic routes and iptables rules figured out, you can start into applying them to the distros (Ubuntus) standard network configuration tools.

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.