1

My Setup:
Debian 10 from Azure
Windows 10 from Azure

Debian 10 is a clean new server from Azure with only OpenVPN installed and set up using the script from this Repository.

Windows 10 is full of programs and has Xampp running on it and I can connect to Debian 10 from Windows 10 with both OpenVPN and SSH.

Issue:
I don't want to give away my Windows 10 IP address but I want people to access the website on Xampp using the Debian 10 IP.

Goal:
I can port forward or Tunnel all the requests made to the Debian IP TCP port (80, 443, 3000, 8080) to the Windows 10 Port through OpenVPN, or if it can be done with SSH.

Progress:
I have set up OpenVPN on Debian with the script from here and it's successful and my Windows 10 connects with the OpenVPN.

Windows 10 firewall is disabled.

I try using C2S with Bitverse SSH to forward port, it only works locally.

There is a Topics on OpenVPN forum that try to do this but is not comprehensive enough. this is the link

Please, if anyone can forward all ports or those specific ports from Linux to Windows, using any method please let me know how I can do it. Thank you so much in advance.

0

1 Answer 1

0

OpenVPN is a tool that manager pseudo interface cryto and route to links these pseudo interface from a point to another.

You are looking to forward port from your debian machine, which is fine, but it is not a job for OpenVPN, it is a job for a firewall, like iptables or nftables on linux.

If you want to do this with iptables here is a few directions.

Notice what is your VPN lan and what IP do your debian use has Openvpn server (it is usually tun0 on debian). lets call it your Debian_VPN_IP

Notice what is your public IP address for your debian machine.

Notice what is your internals IP address given by your OpenVPN on your Windows10 machine. Your windows machine should have a new interface with such IP lets call it your Windows_VPN_IP.

active ip forward on your debian machine so the packet flows through your routes, then use nat table in iptables on Debian to forward the desired traffic from your Debian to your Windows

iptables -t nat -A PREROUTING -p tcp -m tcp --dport 443 -j DNAT --to-destination <your Windows_VPN_IP>
iptables -t filter -A FORWARD -d <your Windows_VPN_IP> -p tcp -m tcp --dport 443 -j ACCEPT

repeat these two lines for every port you want forwarded

Now set a route on your windows machine to your windows routeur only for your debian public IP, and set your default route on your windows machine to your VPN interface via your Debian VPN IP

et voila.

NB: this not a complete setup, your have to complete your firewall to allow block whatever you need, and secure exposed services.

4
  • root@server1:~# iptables -t nat -A PREROUTING -p tcp -m tcp --dport 443 -j DNAT --to-destination 10.8.0.2 root@server1:~# iptables -f filter -A FORWARD -d 10.8.0.2 -p tcp -m tcp --dport 443 -j ACCEPT Bad argument filter' Try iptables -h' or 'iptables --help' for more information. Jan 12, 2022 at 4:34
  • your Windows_VPN_IP = 10.8.0.2 Jan 12, 2022 at 4:36
  • sorry, typo, it's a "t", I correct the statement.
    – dominix
    Jan 12, 2022 at 4:40
  • Thank you so much, it works. Jan 12, 2022 at 5:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .