Or, is there an iptables extension for DNAT that dynamically handles a changing public IP address, similar to MASQUERADE?
I need to configure DNAT on the gateway to forward incoming HTTP requests to the private PC hosting the website. The challenge is that the gateway’s public IP address is assigned from DHCN and changes dynamically.
Here’s what I have done:
- Gateway PC: Connected to the Internet with a dynamically assigned IP address from DHCP.
- SNAT Setup: The gateway uses MASQUERADE to provide Internet access for several private PCs.
- Internal HTTP Server: A private PC with a static private IP address serves an HTTP website. It needs to be accessible from the Internet.
- Dynamic DNS: Enabled so Internet users can resolve the latest IP of my gateway.
Current Understanding:
I know that I could handle this by using a combination of DNAT and a script that updates iptables rules whenever the gateway’s public IP changes. However, I am looking for a more seamless solution.
So, I am expecting a MASQUERADE counterpart for DNAT. Is there an existing iptables extension or method that acts like MASQUERADE for SNAT but applies to DNAT, automatically handling the dynamically changing public IP of the gateway? If not, are there any recommended approaches or best practices for achieving this functionality?
JCav is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.