Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've got a situation where a remote pcs is vpn'ed to my Ubuntu box, and I'm wondering how I set the Ubuntu box up to redirect calls to specific ports over to the PC.

Any Ideas?

share|improve this question
Can you add some further details to your question? What ports specifically and you're trying to forward the ports from the Ubuntu box back to the PC that's VPN'ing into the Ubuntu box? It's not making a lot of sense as it stands so it's hard to help. – slm Dec 30 '12 at 5:02
I'm trying to forward all connections to the Ubuntu box's port 8181 to the PC on the other side of a VPN's port 8181 – Shane Gadsby Dec 30 '12 at 7:32
This? internet -> ubuntu box(8181) -> VPN -> PC ? – slm Dec 30 '12 at 14:06
up vote 0 down vote accepted

The remote PC should receive on its port 8181 whatever packets are sent to the Ubuntu box on port 8181?

To test, you can : from your remote PC, connect to the Ubuntu via VPN, and then ssh to the Ubuntu once connected via the vpn, and in that SSH session, setup a Reverse Port Forwarding: localhost:8181 8181 : this will forward everything coming to port 8181 on the Ubuntu to go, via the tunnel (so the ssh needs to be up) to the PC on port 8181.

Advantage: easy to test and setup. Drawback: ssh needs to stay up (needs keepalive)

Otherwise, if you really want to forward from the Ubuntu to the connected PC, it depends on the type of VPN you use, its firewalling rules, the PC's firewalling rules, etc. Much more difficult to setup (especially if you cuold have several PCs coming in). Try the SSH tunneling way first.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.