From aab5e7b2ffe9221b73feaec59d65e613f42e2de5 Mon Sep 17 00:00:00 2001
From: Henry N <henrynmail-github@yahoo.de>
Date: Thu, 26 Mar 2020 21:22:22 +0100
Subject: [PATCH] Fix getting pulic interface in IPv6 only (#578)

In a IPv6 only environment, the variable $NIC would be empty and iptables in add-openvpn-rules.sh will fail by missing argument.
---
 openvpn-install.sh | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/openvpn-install.sh b/openvpn-install.sh
index d6508b2..ab84a6c 100755
--- a/openvpn-install.sh
+++ b/openvpn-install.sh
@@ -606,6 +606,9 @@ function installOpenVPN () {
 
 	# Get the "public" interface from the default route
 	NIC=$(ip -4 route ls | grep default | grep -Po '(?<=dev )(\S+)' | head -1)
+	if [[ -z "$NIC" ]] && [[ "$IPV6_SUPPORT" = 'y' ]]; then
+		NIC=$(ip -6 route show default | sed -ne 's/^default .* dev \([^ ]*\) .*$/\1/p')
+	fi
 
 	if [[ "$OS" =~ (debian|ubuntu) ]]; then
 		apt-get update