I have a server hosted by a provider which uses Cisco ASA to do nat. The problem I have is that the internal server that is nat-ed with a public ip will see its public ip as source ip. This basically breaks an application which will try to bind to the external ip for some reason.
The provider will not disclose its configuration on the ASA and I'm asking if anyone can explain what sort of nat is this and what can I ask the provider to do - at this point they say it's all working for them ...
thanks!
Does your host use a DNS name? If so, ask for DNS rewrite to be enabled on the Cisco ASA NAT rule for your host.
Does the application allow manual override of where it binds? I assume this is ruled-out already.
Is the external IP listed in /etc/hosts?
From here, I'm going to go out there a little with this answer and focus on the application, not the nat. In particular, I'm going to explore what you can do outside the application to trick it. This would only be for the desperate. This will assume a Linux operating system.
First, the application must somehow obtain the IP address from outside itself. This will ultimately be a file access (/sys/...), a C library call, or an external executable (/sbin/ifconfig). We can try to find how it obtains this information via strace.
The output will be very verbose and technical, but may help you determine the mechanism used by the app to determine the IP.
Here is an example of "hostname -i", which resolves the main IP of my desktop machine:
We can see that it tries several techniques, then actually finds a match in the /etc/hosts file.
Now, ways to trick it:
1) If the app reads from /sys, then a little hard to trick short of a hand-crafted chroot environment.
2) If the app makes a C library call, a custom shared library may be loaded with the app to override and alter the behavior of the corresponding library call. Unrelated, I've used this trick to temporarily disable the "fsync" call for an application that requires it under normal operation.
3) If the app calls an executable (/sbin/ifconfig?), the it is possible to replace this executable with a version that selectively alters its behavior for this application only. Consider setting an environment variable for the app only and checking in the custom executable.
This may be way off topic and is not real specific, but I just want to share a high level idea of how you can trick an application when all other options have been exhausted and you just have to "make it work".
ok, I gotchya. I have this same complaint about NAT routers in general. It is so frustrating when you cannot connect to the external point of view from inside. This is quite often the case with many routers.
You can work around this issue by using NAT within your Linux iptables to redirect an attempt to connect to the outside IP with a connection to the internal IP. The application will not even know its connection destination has been altered. For all purposes, it'll think it has connected outside.
It would be something like:
You can be as selective as you want, even doing this NAT only for specific users with the "-m owner ! --uid-owner 0" type of match.