Iptables – TCP traffic on port 1433 blocked by NAT rules

amazon-web-servicesiptablesnat;sql server

We have a SQL server that is hosted on AWS, the SQL server it not directly accessible on the internet, it relies on a NAT box to route traffic to it.

We are trying to set up a Linked SQL server from this server to another one outside of AWS, this requires the two SQL servers to talk to each other on port 1433 TCP.

The relevant sections from the iptable look like this:

target prot source destination

DNAT udp anywhere anywhere udp dpt:ms-sql-m to:172.10.10.10:1434

DNAT tcp anywhere anywhere tcp dpt:ms-sql-s to:172.10.10.10:1433

From our own testing we know that we can link any server to the one on AWS but not the other way around.

Does anything look wrong? The problem started occurring when our intfra engineer 'removed and added them same rules' Are there any clues in that? Is order relavent?

Using tracetcp we found the following:

Doing this command on the aws sql server 'tracetcp.exe 183.23.53.22 1433' where the ip is that of the other externally hosted server, it would get to the destination in 1 hop, but it would also do the same reguardless of any random ip address we tried.

enter image description here

Where as if we did the same command but on another other port other than 1433, it would hit the NAT box first and then do many hops

enter image description here

Best Answer

Check your iptables rules with iptables-save and re-post them. Verify that your DNAT rules have some method of excluding traffic originating from inside the network, for example -i <extif>, ! -i <intif>, or ! -s 172.10.10.10. I strongly suspect it is resending your packets back to the internal origin server.