LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-06-2008, 06:57 AM   #1
linker3000
LQ Newbie
 
Registered: May 2007
Posts: 9

Rep: Reputation: 0
Port Forwarding with iptables or ssh


Hi,

I need to access a server on a remote site from a Windows workstation via ADSL/NAT port forwarding. The server is running an OS called THEOS and I have just found out from the suppliers that the particular version of THEOS that's running will not accept a workstation connection from an IP-based client that's off the local network. I do have access to a PC on site via an RDP session but this means 'taking over' a user's PC.

One option would be a bridge/vpn to the network but I have also been reading about using iptables to do local port forwarding - there's a Linux server on site so maybe I could bounce a connection through it? THEOS Workstation needs to use UDP port 3256.

A couple of issues for which I'd appreciate some input:

iptables is not currently running on the remote linux server and I am concerned that if I turn it on I will chop off ssh access (on port 8429) and then need to make a trip to site (4 hour round trip) to fix the problem because the Linux server is headless (no monitor/keyboard) and there's no-one technical on site. Any pre-setup I can do and check? I have not really used iptables before.

I can't get my head round whether an SSH tunnel using ssh -D is an option - would this be setup between a pair of Linux servers (possible if workable)? If so, what command/s would I use?

Many thanks
 
Old 07-06-2008, 06:02 PM   #2
Lantzvillian
Member
 
Registered: Oct 2007
Location: BC, Canada
Distribution: Fedora, Debian
Posts: 210

Rep: Reputation: 41
This THEOS box, can it be connected via ssh? If so, if you can connect to the box thats your gateway and tunnel from there. My idea is this:

You ---Internet---- Gateway device -- forward traffic through or act as firewall. eth0 to eth1 for example
------ If traffic is trying to conenct with 65000 forward to eth1:1(alias ;P) which is the gateway box and from there you can do your tunnel.
 
Old 07-06-2008, 07:27 PM   #3
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 63
With 4 hours between you and the hardware, I would take the path of least risk.

It is safe to presume they have a perimeter firewall, and they have opened the RDP port so that you can access remotely? And they have also opened a port, forwarded to the Linux box's SSH port ?

Finally, how do you connect to the THEOS box (GUI app, cmd line, etc.)?
 
Old 07-06-2008, 07:34 PM   #4
estabroo
Senior Member
 
Registered: Jun 2008
Distribution: debian, ubuntu, sidux
Posts: 1,126
Blog Entries: 2

Rep: Reputation: 124Reputation: 124
If you have a linux box on your side a fairly easy way to do this is set GatewayPorts to yes in your local linux sshd config file (restart its ssh server) and the ssh -L 3526:ip_of_THEOS_box:3526 user@remote_linux_host

Then just tell your windows workstation to connect to the linux box like its the theos box and all the port 3526 access will get forwarded to the theos box and it'll look local to its network.

Once you've done what you want I'd turn off the GatewayPorts option.
 
Old 07-06-2008, 08:01 PM   #5
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 63
I think the OP indicated connection to the THEOS box is via UDP, so its not as trivial.
 
Old 07-07-2008, 01:23 AM   #6
linker3000
LQ Newbie
 
Registered: May 2007
Posts: 9

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Lantzvillian View Post
This THEOS box, can it be connected via ssh? If so, if you can connect to the box thats your gateway and tunnel from there. My idea is this:

You ---Internet---- Gateway device -- forward traffic through or act as firewall. eth0 to eth1 for example
------ If traffic is trying to conenct with 65000 forward to eth1:1(alias ;P) which is the gateway box and from there you can do your tunnel.
No SSH on THEOS - I'm just grateful it has FTP as to get data off the system I am going to run a script to dump a database to csv files, FTP them to the Linux server and then rsync via ssh to head office.
 
Old 07-07-2008, 01:25 AM   #7
linker3000
LQ Newbie
 
Registered: May 2007
Posts: 9

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Mr. C. View Post
With 4 hours between you and the hardware, I would take the path of least risk.

It is safe to presume they have a perimeter firewall, and they have opened the RDP port so that you can access remotely? And they have also opened a port, forwarded to the Linux box's SSH port ?

Finally, how do you connect to the THEOS box (GUI app, cmd line, etc.)?
Yep, perimeter firewall to which I have full access as I setup the router.

THEOS supports local serial terminals or local Windows clients using its own, proprietary GUI client software.

Last edited by linker3000; 07-07-2008 at 01:26 AM.
 
Old 07-07-2008, 02:26 AM   #8
linker3000
LQ Newbie
 
Registered: May 2007
Posts: 9

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Mr. C. View Post
I think the OP indicated connection to the THEOS box is via UDP, so its not as trivial.
Yes, UDP.

Does this refer to the ssh redirection plan?

Thanks
 
Old 07-07-2008, 02:30 AM   #9
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 63
There is no real trouble with establishing a secure connection to an internal box; the question here, if I'm understanding, is how you ensure all the right packets get to THEOS. Some thoughts:

If the firewall/router has VPN software, this might be the most straightforward, and useful. Your system simply becomes a member of the remote network, and THEOS is none the wiser.

Because THEOS uses UDP, to use SSH and a tunnel, you'll have to also do some trickery to force UDP into a FIFO, to push that down the tunnel. Only testing will determine if this will ultimately work for you. ( I'm assuming you don't want to open the UDP port that THEOS listens on, a risky proposition at best.).

A third alternative is to setup a simple Windows box on the inside, that is your connection station. Then you can use RDP, VNC, or even the old, but venerable NetMeeting.

Perhaps yet another option is a serial cable from the Linux box to the THEOS box.

Lets see if any of these grabs your interest.
 
Old 07-07-2008, 02:58 AM   #10
linker3000
LQ Newbie
 
Registered: May 2007
Posts: 9

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Mr. C. View Post
There is no real trouble with establishing a secure connection to an internal box; the question here, if I'm understanding, is how you ensure all the right packets get to THEOS. Some thoughts:

If the firewall/router has VPN software, this might be the most straightforward, and useful. Your system simply becomes a member of the remote network, and THEOS is none the wiser.

Because THEOS uses UDP, to use SSH and a tunnel, you'll have to also do some trickery to force UDP into a FIFO, to push that down the tunnel. Only testing will determine if this will ultimately work for you. ( I'm assuming you don't want to open the UDP port that THEOS listens on, a risky proposition at best.).

A third alternative is to setup a simple Windows box on the inside, that is your connection station. Then you can use RDP, VNC, or even the old, but venerable NetMeeting.

Perhaps yet another option is a serial cable from the Linux box to the THEOS box.

Lets see if any of these grabs your interest.
Cheers,

VPN is a possibility - all routers are Drayteks and support a hardware VPN.

THEOS box is well away from the Linux one and getting them together would be problematic - although a mains-borne/wireless serial link might be a way forward.

I may stick with taking over a local PC via RDP for now because once I have setup the file transfer scripts on the THEOS server they will be run by local staff anyway.

Thanks for the ideas.
 
Old 07-07-2008, 07:48 AM   #11
estabroo
Senior Member
 
Registered: Jun 2008
Distribution: debian, ubuntu, sidux
Posts: 1,126
Blog Entries: 2

Rep: Reputation: 124Reputation: 124
Well what I mentioned before will also work with UDP with the use of another program and a slight port change

ssh -L 33526:127.0.0.1:33526 user@remote_linux_host

on the local linux side run socat
socat udp4-listen:3526,reuseaddr,fork tcp:localhost:33526

on remote linux side run socat
socat tcp4-listen:33526,reuseaddr,fork UDP:ip_of_THEOS_box:3526


http://www.zarb.org/~gc/html/udp-in-ssh-tunneling.html
 
Old 07-07-2008, 08:41 AM   #12
linker3000
LQ Newbie
 
Registered: May 2007
Posts: 9

Original Poster
Rep: Reputation: 0
Many thanks to everyone who replied - I think it's time for me to do some work with all that's been suggested.
 
  


Reply



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
IPCHAINS port forwarding and IPTABLES port forwarding ediestajr Linux - Networking 26 01-14-2007 07:35 PM
iptables help! DROP ssh port, but allow to connect to ssh if from 2222 port kandzha Linux - Networking 4 09-13-2006 09:10 AM
SSH Port Forwarding with IPTables & DNAT MercurioBlue Linux - Networking 2 08-24-2006 11:17 PM
iptables don't do port forwarding gomen Linux - Networking 4 12-26-2005 03:05 PM
Port forwarding in iptables gauge73 Linux - Networking 7 07-08-2005 02:22 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:00 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