LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
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 06-02-2009, 09:09 AM   #1
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Colombia
Distribution: Kubuntu, Debian, Knoppix
Posts: 1,982
Blog Entries: 1

Rep: Reputation: 83
Question How to connect (easily) two NATed boxes?


Hi!

I'd like to get ssh access to one box that's behind a firewall (nated) from a box that is in another network (nated, as well).

Supposing I can use another box that's accessible to both boxes, is there a way I can use that other box to get my (nated) box to get ssh access to the other nated box? Is it possible to do it with SSH tunnels?

Thanks in advance.

PS I know I could set up a VPN, but would require using software on all the boxes and I'd really like to keep it on SSH.
 
Old 06-02-2009, 10:33 AM   #2
David1357
Senior Member
 
Registered: Aug 2007
Location: South Carolina, U.S.A.
Distribution: Ubuntu, Fedora Core, Red Hat, SUSE, Gentoo, DSL, coLinux, uClinux
Posts: 1,302
Blog Entries: 1

Rep: Reputation: 107Reputation: 107
Quote:
Originally Posted by eantoranz View Post
I'd like to get ssh access to one box that's behind a firewall (nated) from a box that is in another network (nated, as well).
Can you not just add routes on each endpoint? For example
Code:
// On the first machine
[machine1:~]: route add -net 10.1.0.0 netmask 255.255.255.0 dev eth0

// On the second machine
[machine2:~]: route add -net 10.2.0.0 netmask 255.255.255.0 dev eth0
Replace "10.1.0.0" with the network of the second machine, and "10.2.0.0" with the network of the first machine.
 
Old 06-02-2009, 11:57 AM   #3
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Colombia
Distribution: Kubuntu, Debian, Knoppix
Posts: 1,982
Blog Entries: 1

Original Poster
Rep: Reputation: 83
The networks are separated. Can't just route between them (and I'm not the administrator, that's why I'm going to the "run something on the clients" solution).
 
Old 06-02-2009, 12:37 PM   #4
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Colombia
Distribution: Kubuntu, Debian, Knoppix
Posts: 1,982
Blog Entries: 1

Original Poster
Rep: Reputation: 83
I think I could set a ssh tunnel from both nated boxes to the public box.... but then is there one simple application I could use that could connect separate connections to 2 listening ports (or maybe one)? I mean, one application that could link together 2 client connections made on it?
 
Old 06-03-2009, 08:15 AM   #5
David1357
Senior Member
 
Registered: Aug 2007
Location: South Carolina, U.S.A.
Distribution: Ubuntu, Fedora Core, Red Hat, SUSE, Gentoo, DSL, coLinux, uClinux
Posts: 1,302
Blog Entries: 1

Rep: Reputation: 107Reputation: 107
Quote:
Originally Posted by eantoranz View Post
I think I could set a ssh tunnel from both nated boxes to the public box...
If you can SSH to the public box, can you not SSH from the public box to one of the other boxes?
 
Old 06-03-2009, 08:49 AM   #6
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Colombia
Distribution: Kubuntu, Debian, Knoppix
Posts: 1,982
Blog Entries: 1

Original Poster
Rep: Reputation: 83
Thanks for replying, David.

I already figured out how to do what I want. I'll post a blog entry on the solution and I'll link it here.... so don't desperate. You'll see how probably by the weekend.
 
Old 06-08-2009, 12:11 PM   #7
David1357
Senior Member
 
Registered: Aug 2007
Location: South Carolina, U.S.A.
Distribution: Ubuntu, Fedora Core, Red Hat, SUSE, Gentoo, DSL, coLinux, uClinux
Posts: 1,302
Blog Entries: 1

Rep: Reputation: 107Reputation: 107
Quote:
Originally Posted by eantoranz View Post
I'll post a blog entry on the solution and I'll link it here...
Still waiting on that blog entry...
 
Old 06-08-2009, 12:19 PM   #8
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Colombia
Distribution: Kubuntu, Debian, Knoppix
Posts: 1,982
Blog Entries: 1

Original Poster
Rep: Reputation: 83
You're right, man.... I'm sorry I didn't link here.

http://maratux.blogspot.com/2009/06/...rom-nated.html
 
Old 06-09-2009, 10:35 AM   #9
David1357
Senior Member
 
Registered: Aug 2007
Location: South Carolina, U.S.A.
Distribution: Ubuntu, Fedora Core, Red Hat, SUSE, Gentoo, DSL, coLinux, uClinux
Posts: 1,302
Blog Entries: 1

Rep: Reputation: 107Reputation: 107
Quote:
Originally Posted by eantoranz View Post
I'm sorry I didn't link here.
It was not clear from your posts that you wanted to access a Windows remote desktop via the machine in the middle.

While the SSH port forwarding solution is straightforward, there are other ways to solve your problem.

However, if you only had SSH access, and no administrator rights on any of the boxes, then you are probably limited to the solution you used.
 
Old 06-09-2009, 07:52 PM   #10
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Colombia
Distribution: Kubuntu, Debian, Knoppix
Posts: 1,982
Blog Entries: 1

Original Poster
Rep: Reputation: 83
Oh, well.... I didn't want to get Remote Desktop access to a windows box (God forbid!). I wanted to get (and actually got) access to a SSH service... and that's plenty. :-D
 
Old 06-10-2009, 04:50 AM   #11
David1357
Senior Member
 
Registered: Aug 2007
Location: South Carolina, U.S.A.
Distribution: Ubuntu, Fedora Core, Red Hat, SUSE, Gentoo, DSL, coLinux, uClinux
Posts: 1,302
Blog Entries: 1

Rep: Reputation: 107Reputation: 107
Quote:
Originally Posted by eantoranz View Post
Oh, well.... I didn't want to get Remote Desktop access to a windows box
What means this, then:
Quote:
Originally Posted by your_blog
So say I want to enable access to a remote desktop service of a windows box that's on my private network...
 
Old 06-10-2009, 07:53 AM   #12
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Colombia
Distribution: Kubuntu, Debian, Knoppix
Posts: 1,982
Blog Entries: 1

Original Poster
Rep: Reputation: 83
That's just an example of what you can do. It's not necessarily that I wanted or needed to do that. As I said, the ultimate goal was to get SSH access to a GNU/Linux box... it's right at the beginning of the article.
 
Old 06-10-2009, 09:33 AM   #13
David1357
Senior Member
 
Registered: Aug 2007
Location: South Carolina, U.S.A.
Distribution: Ubuntu, Fedora Core, Red Hat, SUSE, Gentoo, DSL, coLinux, uClinux
Posts: 1,302
Blog Entries: 1

Rep: Reputation: 107Reputation: 107
Quote:
Originally Posted by eantoranz View Post
As I said, the ultimate goal was to get SSH access to a GNU/Linux box... it's right at the beginning of the article.
ok. We have established what you actually wanted to do. Now I am assuming your boxes are connected like this:
Code:
    -------------      ---------- 
    |           |     (          )
    | Machine 1 |<--->( Internet )
    |           |     (          )
    -------------      ---------- 
                            |
                            |
                            |
                      -------------
                      |           |
                      | Machine 3 |
                      |           |
                      -------------
                            |
                            |
                            |
    -------------      ---------- 
    |           |     (          )
    | Machine 2 |<--->( Internet )
    |           |     (          )
    -------------      ----------
If this is correct, you can SSH from "Machine 1" to "Machine 3", and then you can SSH from "Machine 3" to "Machine 2". I know it means an extra login/password combination, but it is simpler than two SSH tunnels. And if you use keys, then you can eliminate the need to type the password.

Let me know if I missed something.
 
Old 06-10-2009, 09:42 AM   #14
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Colombia
Distribution: Kubuntu, Debian, Knoppix
Posts: 1,982
Blog Entries: 1

Original Poster
Rep: Reputation: 83
The problem is, David, that Machine 2 is nated to internet too. So it's impossible to reach machine 2 from machine 3 (or 1, of course).
 
Old 06-10-2009, 12:52 PM   #15
David1357
Senior Member
 
Registered: Aug 2007
Location: South Carolina, U.S.A.
Distribution: Ubuntu, Fedora Core, Red Hat, SUSE, Gentoo, DSL, coLinux, uClinux
Posts: 1,302
Blog Entries: 1

Rep: Reputation: 107Reputation: 107
Quote:
Originally Posted by eantoranz View Post
So it's impossible to reach machine 2 from machine 3 (or 1, of course).
Then how do the tunnels work?

Maybe I do not understand what you mean by "NATed". I am assuming that the firewalls are forwarding the SSH port to the "NATed" machines. If that assumption is incorrect, I would love to know exactly what is being forwarded.
 
  


Reply

Tags
nat, ssh


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
How connect easily to other LAN PCs via hostname? Haz2a Linux - Networking 7 11-12-2007 04:41 PM
Cannot connect to router from boxes bluesman2333 Linux - Networking 7 06-03-2005 09:57 PM
connect 2 Linux boxes via crossover cable forbuto Linux - Networking 1 10-21-2004 06:38 PM
connect 2 linux boxes horoscope_man Linux - Networking 8 03-16-2004 11:08 PM
Networking problems. Can't connect to any other boxes. cirofren Linux - Networking 2 10-19-2003 06:34 AM


All times are GMT -5. The time now is 04:01 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration