Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing issues that happens when public or private IPv4 changes #1118

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

davift
Copy link

@davift davift commented Aug 24, 2024

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 have a fleet of VPN servers that scale in and out according to the demand. I use AWS ASG to increase and decrease the number of servers from a single image. Each new instance will have random private and public IPs.
  • I use DNS to select (load balance) a random server for each new connection. The VPN client resolves the hostname only once, right before starting the connection, and uses the IP until the client decides to disconnect.

I am glad to answer any questions. Keep up with the good job!

@davift
Copy link
Author

davift commented Sep 17, 2024

I also incorporated the custom DNS solution (issue #889) from PR #1108 (which was incomplete) and PR #1104 (which had no input sanitization).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant