LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 12-16-2016, 04:39 AM   #1
acarri
LQ Newbie
 
Registered: Mar 2004
Posts: 18

Rep: Reputation: 0
How to access chat server with private IP over the internet?


Hello everybody,

This is a tough one for me, let me try to explain myself:

I have a chat server accessible through port 5222, which works great on my LAN, but I can't access it over the internet because my router doesn't have a Public IP assigned to its external interface, it has a Private IP assigned to it, just as its internal interface but in another network, so I can't make a port forward to any computer inside my LAN, including my server, the router doesn't even have the port forward option.

Ok now, I know I can use Hamachi, Teamviewer VPN, or any other VPN service out there, BUT, that solution is not all that great, because I would have to use VPN software in tablets, phones, macs, etc, virtually in every device I want it to connect to my chat server...

So... I was wondering if there is some kind of VPN service, but with the ability to assign me a VPN IP, and also a Public IP address assign to my VPN, so I can then make a port forward????...

Something like this:

(LAN IP eth0 and VPN IP tun0) Chat Server --- Router --- INTERNET --- VPN Server (with VPN IP and PUBLIC IP [assigned to my VPN])

So, now, I can access my chat through a Public IP, which port forwards to my servers VPN IP (tun0)

Am I crazy?, or is this really possible?...

Do you have any other ideas?, I'm open to more ideas...

Thank you.

Last edited by acarri; 12-16-2016 at 05:49 AM.
 
Old 12-16-2016, 10:23 AM   #2
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,671
Blog Entries: 4

Rep: Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945
You really do need port-forwarding on your public facing router. If it doesn't have that, then it's time to buy a new one that does.

You can then set up routing between the outside world and your chat server.

Now, if it were me, I would (as I have so often preached here ... ) set up an OpenVPN tunnel such that anyone who wishes to reach your chat server must first be passing through the tunnel. Authorized chat users bearing the crypto certificates that you issued to them can connect and chat away. No one else can see that anything even exists at this public IP-address: there are no "open ports."

Notice that I'm speaking of an OpenVPN server running on your local network, accessible to the outside but being the only service accessible to the outside. (And, hidden from view with tls-auth.) Wanna chat? First you gotta connect. Then you can see the (internal) IP-address of the chat server and connect to it using port 5222. No one can eavesdrop on your chats, nor "barge in."

Last edited by sundialsvcs; 12-16-2016 at 10:25 AM.
 
Old 12-16-2016, 10:56 AM   #3
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,328
Blog Entries: 3

Rep: Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726
Quote:
Originally Posted by sundialsvcs View Post
You really do need port-forwarding on your public facing router. If it doesn't have that, then it's time to buy a new one that does.
Not all that do allow port forwarding are on an ISP that has an accessible network. When using a mobile modem, you can easily go through 7 or 8 layers of private networks before getting to any external address. In such a case it's not possible to do anything about those additional layers, only the top layer and that's not enough.

As far as I know there are two ways around that situation, both relying on SSH.

One method would be to have an external machine and create a reverse tunnel to it. Then outside clients can connect via that reverse tunnel. It's a two-step connection but can be automated with keys and some lines in ssh_config.

Another method is to set the chat server up as an onion service over Tor. Set it to listen on localhost only, then set up a tor client to forward to that port with the HiddenService directive. Then you need to tunnel the client over Tor, but that can be set up fairly easily.

And, I guess, the third option that is being avoided here is shelling out for a VPS and hosting the chat server on the VPS. That would kind of be half of the first method proposed but without the privacy or control.
 
Old 12-17-2016, 04:04 AM   #4
acarri
LQ Newbie
 
Registered: Mar 2004
Posts: 18

Original Poster
Rep: Reputation: 0
Thank you guys for the fast response.

Quote:
Originally Posted by Turbocapitalist View Post
One method would be to have an external machine and create a reverse tunnel to it. Then outside clients can connect via that reverse tunnel. It's a two-step connection but can be automated with keys and some lines in ssh_config.
I like this option (number one)... can you elaborate a little bit more please?...

Thanks in advance...
 
Old 12-17-2016, 09:20 AM   #5
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,328
Blog Entries: 3

Rep: Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726
Quote:
Originally Posted by acarri View Post
Thank you guys for the fast response.

I like this option (number one)... can you elaborate a little bit more please?...

Thanks in advance...
It's not complicated, just hard to explain.

If you have a network with machines A, B, and C such that A is unreachable from outside but B is, then you 1) connect from A to B building a reverse tunnel. Then 2) connect from C to B and then via the reverse tunnel to A.

So connecting from the inside to the outside, make a reverse tunnel:

Code:
ssh -R 9999:localhost:22 machineB.example.com
Leave that connection open (it can be automated with keys, see -N and -f for ssh as well as keys)
Then as long as that connection stays open, you can use B as a jump host (aka bastion) to reach A from C.

So on machine C connect to A via the reverse tunnel on B:
Code:
ssh -o ProxyCommand="ssh -W %h:%p machineB.example.com" -p 9999 127.0.0.1
If that works, a shortcut can be made in C's ~/.ssh/config. Then the reverse tunnel from A to B can be automated using keys. MachineA and MachineB need OpenSSH server running, the latter needs to be accessible from anywhere.

Edit: if you have a very recent version of OpenSSH, the -J option is much easier to use for step 2.

Last edited by Turbocapitalist; 12-17-2016 at 09:23 AM.
 
  


Reply

Tags
port forwarding, vpn



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LQ and Private Internet Access VPN Service jeremy Linux - News 3 02-28-2017 04:46 PM
[SOLVED] Private Internet Access jackmule Slackware 5 12-28-2015 05:23 AM
Help Me! Private network to access internet and not darqtanian Linux - Networking 1 10-10-2013 03:36 AM
private/Intranet like mail server on internet irfan1234 Linux - Server 1 08-10-2008 10:46 PM
Public Access of Internet using Private IP manas484 Linux - Security 1 01-17-2006 05:09 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 01:36 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration