---
title: Implementing a Load-Balancing/Failover Configuration
canonical: https://openvpn.net/community-docs/implementing-a-load-balancing-failover-configuration/
product: Community Docs
---

# Implementing a Load-Balancing/Failover Configuration

## Client

The OpenVPN client configuration can refer to multiple servers for load balancing and failover. For example:

```
remote server1.mydomain
remote server2.mydomain
remote server3.mydomain
```

This will direct the OpenVPN client to attempt a connection with server1, server2, and server3 in that order. If an existing connection is broken, the OpenVPN client will retry the most recently connected server, and if that fails, it will move on to the next server in the list. You can also direct the OpenVPN client to randomize its server list on startup so that the client load will be probabilistically spread across the server pool.

```
remote-random
```

If you would also like DNS resolution failures to cause the OpenVPN client to move to the next server in the list, add the following:

```
resolv-retry 60
```

The **60** parameter tells the OpenVPN client to try resolving each **remote** DNS name for 60 seconds before moving on to the next server in the list.

The server list can also refer to multiple OpenVPN server daemons running on the same machine, each listening for connections on a different port, for example:

```
remote smp-server1.mydomain 8000
remote smp-server1.mydomain 8001
remote smp-server2.mydomain 8000
remote smp-server2.mydomain 8001
```

If your servers are multi-processor machines, running multiple OpenVPN daemons on each server can be advantageous from a performance standpoint.

OpenVPN also supports the **remote** directive referring to a DNS name with multiple **A** records in the domain's zone configuration. In this case, the OpenVPN client randomly chooses one of the **A** records every time the domain is resolved.

## Server

The simplest approach to a load-balanced/failover configuration on the server is to use equivalent configuration files on each server in the cluster, except use a different virtual IP address pool for each server. For example:

- **server1:** `server 10.8.0.0 255.255.255.0`
- **server2:** `server 10.8.1.0 255.255.255.0`
- **server3:** `server 10.8.2.0 255.255.255.0`

---

Prev: [Connecting To a Samba Share Over OpenVPN](https://openvpn.net/community-docs/connecting-to-a-samba-share-over-openvpn.md)
Next: [Hardening OpenVPN Security](https://openvpn.net/community-docs/hardening-openvpn-security.md)
Index: https://openvpn.net/community-docs/llms.txt
