= How to forward ports to a Linux VPS =

I know it comes up a lot if you can get a static IP and forward ports. As we know, you can't (at this time)

I thought I would share how to forward ports
~~to~~ from a VPS. I use Digital Ocean, but the provider shouldn't matter (as long as it's Linux)
Details:
I have Wireguard setup from Home server to DO server. Home server IP is 10.8.0.3. DO IP is 10.8.0.1
DO server network adapter is eth0 and the Wireguard adapter is wg0
Of all things, I wanted to make my home IRC server available (just for fun as a test). IRC runs on port 6667
Here are the iptables commands to run to get 6667 forwarded from my public IP to my home server:
sudo iptables -A FORWARD -i eth0 -o wg0 -p tcp --syn --dport 6667 -m conntrack --ctstate NEW -j ACCEPT sudo iptables -A FORWARD -i eth0 -o wg0 -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT sudo iptables -A FORWARD -i wg0 -o eth0 -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT sudo iptables -P FORWARD DROP sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 6667 -j DNAT --to-destination 10.8.0.3 sudo iptables -t nat -A POSTROUTING -o wg0 -p tcp --dport 6667 -d 10.8.0.3 -j SNAT --to-source 10.8.0.1
EDIT: it was pointed out to me that I said forward to. It should have been forward
**from I fixed it in the post

Another option is to use autossh with a reverse pipe. I do this to a box with a static ip running nginx and then proxy via hostname and have several servers running behind starlink in this manner. A simple raspberry pi handles the autossh which also auto reconnects on any issues

I used to use autossh but found it um-reliable. If the tunnel dropped about 1/2 the time audossh would appear to be up, but the forwarded ports didn't work. I've found Wiregueard with port forwarding much more stable

How to forward ports
**from** a Linux VPS
An ssh tunnel will also work for this if for some reason you don't have root access

Nice solution. DO also offers free Outline VPN software to run in one of your DO servers. Easy click setup. Free clients for most OS and mobiles. Did not test it with port forwarding but maybe someone else tried it

I occasionally do an internet radio show, and the listeners are all used to using IRC to chat with the DJ. So yea, IRC isn't totally dead yet

== About Community ==
Members
Online