Advertisement

08.14.2006 at 04:47AM PDT, ID: 21953329
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.2

SQL Server via ssh tunnel and iptables port forwarding

Asked by anorakgirl in Linux Network Security

Tags: , , , ,

Hi,

I have the following situation:

From a server (<webserver>) on the internet, I want to connect to a SQL Server database on an internal windows server (call it <dbserver>), via a linux server (call it <myserver>), both of which are inside a firewall.

My plan is this:

1. Set up port 1433 on <myserver> to forward to <dbserver>. I have done this by adding the following in iptables:

iptables -I INPUT 1 -p tcp --dport 1433 -i eth0 -j ACCEPT
iptables -t nat -I PREROUTING -p tcp --dport 1433 -i eth0 -j DNAT --to <dbserver>:1110
iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o eth0 -j SNAT --to-source <myserver>

This seems to work -from an internal machine, if I do
telnet <myserver> 1433, i get a response from SQL Server on <dbserver>

2. Set up a remote ssh tunnel to <webserver> from <myserver>

I have done this using the command:

ssh -f -SgR1433:localhost:1433 <webserver>

When I test, on <webserver> I get the following:
[xxx@webserver]$ telnet localhost 1433
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Connection closed by foreign host.

--------------------

I tried setting up the tunnel directly on the windows server <dbserver> instead, and it all works fine - when I do as above I get the same output, but without the line "Connection closed by foreign host.".

So the tunnel seems to work if I have it on <dbserver>, but if I have it on <myserver> and then use iptables to forward port 1433, it disconnects. I know it is getting as far as <myserver> because if I set up the tunnel with verbose output I get (on <myserver>):

debug: Ssh2ChannelTcpFwd/sshchtcpfwd.c:524/ssh_channel_ftcp_open_request: open request for remote forwarded TCP/IP channel
debug: Received remote TCP/IP forward connect for port 1433 from 127.0.0.1:34674
warning: Connecting to localhost:1433 failed (remote forward, port 1433)

It is not a problem with the firewall on <webserver> as I have tried with that stopped.

I guess it must be a problem with how I have set up the port forwarding, but it works if you connect to the port directly rather than through the tunnel.

Any suggestions?? Thanks.













Start Free Trial
[+][-]08.15.2006 at 12:19AM PDT, ID: 17316120

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.15.2006 at 01:12AM PDT, ID: 17316255

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.15.2006 at 08:19PM PDT, ID: 17323209

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]08.19.2006 at 02:40PM PDT, ID: 17349255

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Linux Network Security
Tags: iptables, ssh, tunnel, sql, port
Sign Up Now!
Solution Provided By: ee_ai_construct
Participating Experts: 2
Solution Grade: B
 
 
 
Loading Advertisement...
20081112-EE-VQP-42