HELP: Forwarding Traffic to VPN Client

Business solution to host your own OpenVPN server with web management interface and bundled clients.
Post Reply
tinkering
OpenVpn Newbie
Posts: 1
Joined: Thu Jun 01, 2023 10:43 pm

HELP: Forwarding Traffic to VPN Client

Post by tinkering » Thu Jun 01, 2023 10:56 pm

I am running Access Server in AWS, and I have a web server running at port 5000 in my VPN client.
I would like to forward all port 5000 traffic to my client.
Tried using IpTables but unfortunately does not reflect my commands from the command line. Currently trying the configuration with NFtables but still not forwarding traffic to my client's web service.


nft 'add chain nat POSTROUTING { type nat hook postrouting priority 100 ; }'
nft 'add chain nat PREROUTING { type nat hook prerouting priority -100; }'

nft 'add rule nat PREROUTING ip daddr 172.31.29.25 tcp dport {5000} dnat 192.168.10.66:5000'

nft add rule nat POSTROUTING masquerade

----------------------------------------------

EC2 private IP: 172.31.29.25
VPN client IP: 192.168.10.66

I am setting this up since my home network is under CGNAT. I hope someone can help me out.

tieumyxinhdep
OpenVpn Newbie
Posts: 2
Joined: Fri Jun 02, 2023 7:20 am

Re: HELP: Forwarding Traffic to VPN Client

Post by tieumyxinhdep » Fri Jun 02, 2023 7:25 am

To forward traffic from port 5000 to your VPN client's web server, you can try the following steps:

1: Make sure you have the necessary administrative privileges to configure the network settings.

2: Check if IP forwarding is enabled on your Access Server instance. Run the following command to verify:
sysctl net.ipv4.ip_forward
If the output is net.ipv4.ip_forward = 1, then IP forwarding is already enabled. If not, you can enable it by running:
sysctl -w net.ipv4.ip_forward=1

3: Set up port forwarding using iptables. Run the following command:
css
iptables -t nat -A PREROUTING -p tcp --dport 5000 -j DNAT --to-destination 192.168.10.66:5000
This command forwards incoming traffic on port 5000 to your VPN client's IP address and port.

4: Enable IP masquerading to allow the response packets to be routed back to the source. Run the following command:
css
iptables -t nat -A POSTROUTING -j MASQUERADE
Make sure to save the iptables rules so they persist across reboots.

Please note that the above steps assume you're using iptables. If you prefer using NFtables, the syntax may vary slightly, but the general concept remains the same.

After applying the necessary configuration, you should be able to access your web server running on your VPN client from outside the network using the EC2 instance's public IP address and port 5000.

If you continue to experience issues, it may be helpful to consult the documentation for your specific VPN server software or seek assistance from their support channels.

User avatar
openvpn_inc
OpenVPN Inc.
Posts: 1333
Joined: Tue Feb 16, 2021 10:41 am

Re: HELP: Forwarding Traffic to VPN Client

Post by openvpn_inc » Sat Jul 01, 2023 2:53 pm

Hi,

You can setup DMZ in Access Server. Please check the below guide if that is what you are trying to achieve.
https://openvpn.net/vpn-server-resource ... ss-server/

Regards,
.\kionci
Image OpenVPN Inc.
Answers provided by OpenVPN Inc. staff members here are provided on a voluntary best-effort basis, and no rights can be claimed on the basis of answers posted in this public forum. If you wish to get official support from OpenVPN Inc. please use the official support ticket system: https://openvpn.net/support

lizardslair
OpenVpn Newbie
Posts: 1
Joined: Fri Dec 29, 2023 8:30 pm

Re: HELP: Forwarding Traffic to VPN Client

Post by lizardslair » Fri Dec 29, 2023 8:33 pm

Just a gratitude post for @tieumyxinhdep. With those 3 commands I was able to configure my public cloud server to accept traffic on a port of my choice and pass it through the OpenVPN layer to a client machine in another location running a web server and it works flawlessly. :D

Post Reply