Some firewall models allow port translation. Meaning changing one port coming in (inbound) to some other port, using some protocol. Furthermore, they can also change the internal port to become some external port (outbound traffic) to the original port again.
This is the DMZ external firewall model below. Suppose I want all of this to happen on the server directly using iptables instead of using the DMZ firewall. What commands could allow this to happen on a CentOS 6 server?
DMZ network rule model:
Suppose I have TCP traffic and the public port is 8082 and the internal port is 8081? So for example, Tomcat (the client) in the DMZ would send a TCP packet outside the external DMZ firewall as port 8081, and then the packet would be sent through the internet as 8082 to some public IP. And then the reverse, suppose a request from some public IP was sent to this same server on 8082, and as it entered the DMZ of this server, the port would then change to 8081.
- public port = 8082
- internal port = 8081
iptables network rule model:
- port external to server = 8082
- port Tomcat is sending and receiving TCP requests on physical server = 8081