0

I have 2 remote servers, one Linux box and one Windows Box. The Windows box is running MS SQL Server. It's behind a firewall, and I can only access it from my Linux box (I can netcat to the Windows box on port 1433 so that's working ok).

I'd like to use the linux box as a proxy so I can connect to the MS-SQL Server from my desktop.

I've tried setting up IP tables on the linux box with the following config, but my desktop still won't connect.

#!/bin/sh

echo 1 > /proc/sys/net/ipv4/ip_forward

iptables -F
iptables -t nat -F
iptables -X
iptables -t nat -A PREROUTING -p tcp --dport 1433 -j DNAT --to-destination xxx.xxx.xxx.xxx:1433

Any help would be greatly appreciated!

0

Hi try the following: `

iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 1433 -j DNAT --to xxx.xxx.xxx.xxx:1433 iptables -A FORWARD -p tcp -d xxx.xxx.xxx.xxx --dport 1433 -j ACCEPT

I will try to explain in short the flow. So first the prerouting in nat which you already did was ok.

The NAT prerouting is the last chain before the first router decision is made. Because it's traffic with a destiny other then your host the router decision will be to handle it over to Mangle forward and filter forward. Which is why you also need to add the foward rule to accept traffic towards your MS SQL host.

  • I tried this - still doesn't work. Not to worry though, I used HAProxy to do what I needed in the end. – Tom Apr 18 '18 at 23:48
-2

I ended up using HA Proxy to do what I need - was very easy, config file is below.

listen sql-db
    bind *:2233
    mode tcp
    balance leastconn
    acl db_white_list src 0.0.0.0 xxx.xxx.xxx.xxx #(my desktop IP)
    tcp-request connection reject if !db_white_list
    option log-health-checks
    server server1 xxx.xxx.xxx.xxx:2233 check port 2233 inter 1000
  • 3
    This needs a lot more details. – Sven Apr 18 '18 at 19:18

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.