Skip to contentSkip to conversation

behavior of remote address with more than one A record

Openvpn-devel David Sommerseth 2 participants 3 messages May 12, 2011

lore
Share & tools
lore
#0 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Whoops, forgot Cc to openvpn-devel.

David S.

- -------- Original Message --------
Subject: Re: [Openvpn-users] behavior of remote address with more than
one A record
Date: Thu, 12 May 2011 17:22:45 +0200
From: David Sommerseth <[email protected]...>
To: William Cooley <[email protected]...>
CC: Jan Just Keijser <[email protected]...>, openvpn-users <[email protected]>

Quoted 36 lines · William Cooley
Quoted 34 lines · Jan Just Keijser
Quoted 14 lines · William Cooley

I'd like to have a remote address setting that has two A records. The client should randomly try to connect to one of the addresses and if it fails it should either try the other IP address or do a randomize operation on the IP selection again.
In previous versions of openvpn if you specified a domain that resolved to two or more IP addresses you'd get a long line like /RESOLVE: NOTE: vpndomain.com resolves to 2 addresses, choosing one by random/
and I believe it performed as I described above.
However it looks like with openvpn 2.1.4 and newer you simply get /RESOLVE: NOTE: vpndomain.com resolves to 2 addresses/
and if it fails to connect to the first IP address it never tries the other address and simply indefinitely tries to connect to the same address.

Quoted 4 lines

Was there some type of change in the code that was not mentioned in the changelog? Does any one have more information on this? Is there a setting that can restore this behavior?

it's mentioned in the changelog:

* Implemented multi-address DNS expansion on the network field of route commands.

When only a single IP address is desired from a multi-address DNS expansion, use the first address rather than a random selection.

but it seems this had the unintentional side-effect , namely what you describe.
this is either a bug or it should have been documented better.

cheers,

Quoted 8 lines
Quoted 2 lines

JJK

Yes I say this but I assumed it only applied to the route command. The man pages for both 2.1 and 2.2 still say

Quoted 3 lines

If *host* is a DNS name which resolves to multiple IP addresses, one will be randomly chosen, providing a sort of basic load-balancing and failover capability.

So can this be called a bug?

Let me first start with this last question. No, this is not a bug. I will explain this better.

This change came in commit f9b2ada0eece0615 / SVN r6291 [1] and was discussed in a couple of developer meetings last spring.

To summarize it quickly:

The previous behaviour was prune to misbehave in many setups. DNS servers will by default do this kind of round-robin load balancing. So if you had two servers with IN A records (f.ex: serverA and then serverB), OpenVPN would not consider the order of these two records and take one randomly. After the TTL for this record expires and OpenVPN again does a name lookup (lets say there have not been any other requests to the DNS for this IN A record in this case) the order would be different (f.ex: serverB and then serverA). In this case OpenVPN most likely pick the same host as it used the first time, and then "un-randomise" the order. Which would again lead to no load balancing at all.

So the conclusion was to not do any randomisation in OpenVPN at all, and trust that the DNS server does its round-robin job. And lowering the TTL for these IN A addresses used for OpenVPN servers will therefore give a better control of the round-robin handling - resulting in load balancing.

You can test this by making sure the TTL is set low enough on your server records (say 60 seconds), make sure that your client will do a new DNS lookup with the proper TTL (you can check this with 'dig'). Then connect to your server and break the connection after one minute and then reconnect. In this case, if the DNS server does the job properly, it would now give your second server - which OpenVPN should use.

kind regards,

David Sommerseth

[1]
<http://openvpn.git.sourceforge.net/git/gitweb.cgi?p=openvpn/openvpn-testing.git;a=commitdiff;h=f9b2ada0eece06158cc3ce6f6348bd431dfd7f0a>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAk3L/jkACgkQDC186MBRfrr61QCgl2HQt5VR6QwUyUdnzF9kSmTk 8DoAn0dl44UWCp/KJtn/P0Jl4CPjDCi0
=c7SN
-----END PGP SIGNATURE-----

#1 lore raw
Quoted 6 lines

You can test this by making sure the TTL is set low enough on your server records (say 60 seconds), make sure that your client will do a new DNS lookup with the proper TTL (you can check this with 'dig'). Then connect to your server and break the connection after one minute and then reconnect. In this case, if the DNS server does the job properly, it would now give your second server - which OpenVPN should use.

But this is about load-balancing, whereas the OP's issue is with fail-over. If the TTL is not low enough then the fail-over will not happen (OpenVPN will keep trying to connect to same first host in the list). It seems that for fail-over, OpenVPN should do a single DNS request and then cycle though the list of hosts it received.

Stefan

#2 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 7 lines · Stefan Monnier
Quoted 6 lines

You can test this by making sure the TTL is set low enough on your server records (say 60 seconds), make sure that your client will do a new DNS lookup with the proper TTL (you can check this with 'dig'). Then connect to your server and break the connection after one minute and then reconnect. In this case, if the DNS server does the job properly, it would now give your second server - which OpenVPN should use.

Quoted 5 lines

But this is about load-balancing, whereas the OP's issue is with fail-over. If the TTL is not low enough then the fail-over will not happen (OpenVPN will keep trying to connect to same first host in the list). It seems that for fail-over, OpenVPN should do a single DNS request and then cycle though the list of hosts it received.

Fair enough, but playing the devils advocate, would you use a load-balancing feature (round-robin) as fail-over solution generally?

Rightfully enough, the former behaviour could be used for both, but the fail-over would still just be a side-effect - which still would be prune to get the same host again, due to TTL and randomisation of that result could pick the same host again.

For a more proper and cleaner fail-over solution, you can use multiple
- --remote options together with --remote-random. This can also be used for load-balancing as well.

kind regards,

David Sommerseth
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAk3MTMIACgkQDC186MBRfrrxyQCgpfOxcPJqNZAgDzR739HsCg/8 utgAnA7NHvmDw8fokZpsHQDa7q45BB3K
=xzG8
-----END PGP SIGNATURE-----