I think I have read every topic that is close to mine but I'm still stuck :(
I have a VPS running Ubuntu 20.04, it is running an OpenVPN Server and my windows client can connect to it fine and I get the IP of 10.8.0.2 when connected.
What I'm trying to achieve is to forward udp ports 2456,2457,2458 using iptables
to my connected VPN windows client which is running a game server, so that anyone who has my VPS IP can connect to my game server hosted on my windows PC through the VPN. I am behind a cgnat so I'm just trying to give myself a public IP (my VPS) and route traffic on those ports to my windows PC VPN client.
So my VPS IP is say xxx.xxx.xxx.xxx, the IP my OpenVPN server gives me is 10.8.0.2
I have tried a ton of different iptables routing but this is the one I have worked off as the author said it worked for him on a similar setup but does not work for me:
iptables -t nat -A PREROUTING -d xxx.xxx.xxx.xxx -p udp --dport 2456 -j DNAT --to 10.8.0.2:2456
iptables -t nat -A PREROUTING -d xxx.xxx.xxx.xxx -p udp --dport 2457 -j DNAT --to 10.8.0.2:2457
iptables -t nat -A PREROUTING -d xxx.xxx.xxx.xxx -p udp --dport 2458 -j DNAT --to 10.8.0.2:2458
Forwarding is enabled:
sysctl net.ipv4.ip_forward
net.ipv4.ip_forward = 1
I am not a very good Linux user except for basic things and then following tutes. Any help will be massively appreciated! Thanks.
ip route
on each machine involved would be useful. You can watch the packets yourself with wirehark or tcpdump, and you don't have to start the whole game either, just try to make a connection with netcat. – stribika Feb 27 '21 at 16:54