Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Routing to my home server
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.

Routing to my home server

Hi,

I wondered if anyone knew of a guide for forwarding traffic from a vps I have to my home server. I want to do this because I want to avoid port blocks and to enable me to use a static ip. I was thinking I could setup openvpn to connect from my home server to the vps, then route all incoming traffic on the vps's ip through the vpn to the home server? Is that wise? Will it work?

Comments

  • netomxnetomx Moderator, Veteran

    Yes

  • @netomx said:
    Yes

    Would I also be able to host a vpn server on my home server at the same time? Also, do you know of better ways to do this? Like any specific software?

  • Look into ssh port forwarding and reverse port forwarding if you just need one or a few ports that is easi

  • On the VPS machine, set "GatewayPorts yes" in sshd_config, then run this on your home machine. In this example, remoteserver is the DNS name of the VPS machine and port 80 is what we're redirecting:

    ssh -o TCPKeepAlive=yes -R 3306:localhost:3306 -g -f -n -N remoteserver

    -R sets up a reverse tunnel which listens on localhost of the remoteserver on port 3306 (the second 3306 above) and directs it to localhost port 3306 of the local machine. -g makes it a gateway port, which means anyone can connect to port 3306 on remoteserver, not just via localhost. -f puts ssh in the background, -N means don't run a command on remoteserver, and -n redirects /dev/null to stdin.

    If you want to make this automatic by putting this in a script, set up keys and take out the -f and -n. This way the script can wait a few seconds and try again when ssh returns.

    If you want to use privileged ports, you'll have to do it as root in order to bind on remoteserver. Never use passwords with remote root ssh.

    Thanked by 1sc754
  • Got it working, used iptables to forward all ports bar the ssh and vpn port on the vps machine. Everything goes to the pi and works perfectly.

Sign In or Register to comment.