Fixing issues that happens when public or private IPv4 changes #1118
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
While Linode, DigitalOcean, and OVH (scenario A) assign the public IP to the virtual machine's network interface, other cloud providers like AWS, GCP, and Azure (scenario B) translate the public address (NAT) to the private address on the way in.
Using a hostname (domain/sub-domain) to work around a changed public IP will not work for scenario A because the IPv4 is used in the iptables for NAT. It is also ineffective when, for any reason, the private IP changes on scenario B.
The solution for this problem is to use the default gateway's interface instead of the outbound IP in iptables. Then, OpenVPN can bind on 0.0.0.0, to accommodate connections independently of the IP.
The use case that required the following changes has been in production for over 2 years, so far:
I am glad to answer any questions. Keep up with the good job!