New on LowEndTalk? Please Register and read our Community Rules.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
How do I port forward through a VPS?
psychobacter
Member
in Help
I am looking for guidance on how to achieve port forwarding through my low-end VPS, which I currently use as a wireguard VPN (PiVPN). I want to torrent but my home connection is behind a CGNAT so other peers in the swarm can't make connections to me. Could anyone please advise me on how to do this? I am a novice so detailed guidance would be appreciated. Thanks!
Comments
Uh, use your VPN at home instead of on the VPS?
If you are already able to use wiregaurd then some UDP port is open in your VPS, or do you mean SSH tunneling? Sorry if I did not understand your question.
Correct me if I am wrong, you can set up torrent server on your VPS. Any torrent transfers will be made to/from your VPS?
You could also just set up a wireguard server and have your home client devices connect to it and browse as normal? At least that is what I am using right now.
Since you gave no network or O/S info, in my example below 172.19.4.254 is the tunnel endpoint at your VPS and 172.19.4.1 is the tunnel endpoint on you local server. 66.66.66.66 is your VPS external IP and the local service you wish to serve from is running on 172.19.4.1. The wireguard interface is "wg0" and the network adapter on the VPS is "eth0"
On the local server and the VPS make sure forwarding is enabled. To check use:
if you get the response
your good to forward traffic from the tunnel. If you get
Then forwarding is not enabled. To enable
This is not persistent. If you want to make it persistent across reboots, edit the /etc/sysctl.conf file in your favorite text editor and change
to
I would also add
Then after saving the file enter this command
Then add a routing table to your local server to forward outbound traffic via the tunnel.
Then on your VPS after making sure you have installed iptables add the following iptables rules. Change "wg0" to whatever the name of your VPS wireguard adapter is named, if different.
In the example above I have forwarded a tcp port, you can also forward a udp port by changing the "tcp" to "udp" in the PREROUTING line.
These iptable rules are not persistent, but if you get it working we can make them so if you let me know what o/s you are using.
I think I covered everything. Let us know how it goes.
Can you take a loo at this and help me?
https://lowendtalk.com/discussion/comment/3717821