diff --git a/src/openvpn/init.c b/src/openvpn/init.c
index 9371024e..3b00b49d 100644
--- a/src/openvpn/init.c
+++ b/src/openvpn/init.c
@@ -478,9 +478,9 @@ init_connection_list(struct context *c)
     if (c->options.remote_random)
     {
         int i;
-        for (i = 0; i < l->len; ++i)
+        for (i = l->len - 1; i > 0; --i)
         {
-            const int j = get_random() % l->len;
+            const int j = get_random() % (i + 1);
             if (i != j)
             {
                 struct connection_entry *tmp;
