I'd like to understand why trying to connect to a server in the same network, using the public IP address (provided by the router/NAT), and the port doesn't' work. (I'll assume two interfaces in the router/NAT, one connected to the internet, and the other connected to the private network. I will also assume I'm using TCP.)
You can see the diagram here:
I have a NAT table which allows connections to my internal 192.168.1.4:80 host, which is running an http server.
IP internal | Port internal | IP external Port external | Port nat 192.168.1.4 80 * * 80
If I connect from host B with ip 18.104.22.168 and port 55231, this entry would be added:
192.168.1.4 80 22.214.171.124 55231 80
And everything would work correctly. The 'loopback problem' comes when trying to connect to (126.96.36.199,80) from an internal host, such as host A 192.168.1.4 with port 60000. The datagram sent by this host would look like this:
IPsrc:192.168.1.4, IPdst:IPnat, Proto:TCP|| PortSrc: 50243, PortDst: 80
So, a new entry would be added to the NAT table:
192.168.1.4 50243 IPnat 80 60000
The datagram replies of the server would look like this:
IPsrc:192.168.1.4, IPdst:IPnat, Proto:TCP||PortSrc: 80, PortDst: 60000
I don't see the problem here; in my opinion it should work correctly. I can't see why this wouldn't work. Is it the order in which the NAT-routing is done?