Why is nat required when proxy is enough? [closed]

Solution 1:

MadHatter has written an excellent layman's explanation of the differences between proxies and NAT.

For more technical details I suggest you read up on the OSI model and the TCP/IP model. Nat operates at later 3 of the OSI model (the network layer, IP in this case) and proxies generally operate at layer 7 (the Application layer, HTTP or whatever you're proxying).

NAT and proxies are also trying to solve slightly different problems. NAT is hiding a number of private IPs behind a smaller number of public IPs to alleviate the shortage of IP addresses, while proxies are creating a network "choke point" for security, auditing or performance reasons

Solution 2:

It seems to me that you've grasped the fundamentals here quite well, and the short answer is, that if you're using a proxy with a public address, you don't need NAT - for the protocols which are mediated by the proxy.

However, there are more protocols in heaven and earth than are dreamt of in your philosophy; not all of them are proxiable, and proxies don't exist even for all that are, so NAT is a handy fallback for those.

Edit: A proxy is a computing device that works on an application level. An HTTP proxy receives HTTP requests for a remote site, and as you pointed out, it goes off to that site itself and makes the request, and passes the answer back to the requesting client. But it has to understand HTTP at a detailed level in order to do this.

Similarly, you might write an FTP proxy, but it would have to understand the details of MKD, DELE, LIST, and suchlike ftp protocol commands, in order to correctly proxy the client's requests. Any proxy that wants to work transparently generally has to intimately understand the internals of the protocol in order to proxy that protocol.

SOCKS is to some extent an exception to this rule, but that's because the SOCKS protocol puts in place a more general interface for proxying, requiring each client to be SOCKSified, and therefore capable of making the right requests of the SOCKS proxy in order to set up the kind of proxying each requires, which isn't exactly transparent.