So, I have this slight dilemma: I am not allowed to host an IRC server on my VPS, but I am allowed to use tunneling of some sort to let users connect to an IRC server I have set up locally on my Mac Mini.

Basically - how would I go about tunneling connections to port 6667 of my VPS to my Mac Mini without opening a port in my router (that's what I get for having a technically inclined dad)? I've read up a little on SSH port forwarding, but after about 3 hours of constant googling and trying things out, I just can't seem to get it to work. I've also been considering things like Himmachi(or whatever it's actually called now) and then somehow route the Himmachi IP of my Mac Mini to be public.

I know that my writing probably sounds hopelessly confused, but that's because I'm hopelessly confused as to where I could go from here.

I'd appreciate any help in this subject.


You need a reverse tunnel.

From your mac you ssh to your linux VPS, creating a reverse tunnel.

ssh -R *:6667: tristan@linux

That connects from your mac-mini to your linux VPS. It makes ssh listen on all interfaces (*) on port 6667. Any traffic it finds (on port 6667 of your VPS) it sucks down the tunnel and punts back into the localhost on your mac-mini ( onto port 6667.

You can also use,

ssh -f -N -R *:6667: tristan@linux

so that you don't see a terminal session (-f backgrounds ssh after asking for your password, and the -N stops it running a remote command). To close the tunnel you'll need to find the process on your mac and kill it.

DCC operations won't work properly, but IRC might.

Caveat: I do not know if this will work for more than one IRC user connection

Note: Depending on why you've been told you can't run an IRC Daemon on your VPS, this technique might be an issue as well (i.e. if port 6667 is blocked inbound to your VPS).

On the VPS, you need to ensure GatewayPorts is enabled in the sshd_config file (usually /etc/ssh/sshd_config).

  • The command runs without a problem, but it shows me the standard shell I'd get by just doing the regular ssh hostname. Is this normal? And then, when I attempt to connect to port 6667 using either nc or an IRC client, I get a "Connection Refused" error. Any ideas?
    – Tristan
    Jul 13 '11 at 20:35
  • Yes you get a shell, because you're creating a session to set the tunnel up. I did forget to include some sshd config in my answer so I'll add that now - but it's possible your host or your VPS has a firewall blocking access as well. Jul 13 '11 at 21:13
  • Thanks for the update - I inquired about this at my host and they were fine with it as long as I kept it secure and didn't host the ircd itself on my VPS. Why? I don't know. I now got a bit farther with my IRC client - I get the "Socket closed by remote peer" error. I presume this is an issue with my IRCD?
    – Tristan
    Jul 13 '11 at 21:15
  • I also get this error on the shell: "connect_to port 6667: failed."
    – Tristan
    Jul 13 '11 at 21:21
  • Could be, hard to tell, I don't have an ircd on my local machine so it's not something I can easily test. I know the reverse tunnel works for simple stuff, but I've never tried it with an irc daemon and I've never tried it for something which expects multiple incoming connections. Would be a lot easier if you could convince your father to allow incoming connections, because the reverse tunnel isn't any more secure in the end. Jul 13 '11 at 21:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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