diff --git a/src/nm-openvpn-service-openvpn-helper.c b/src/nm-openvpn-service-openvpn-helper.c
index 9823d94..ca51926 100644
--- a/src/nm-openvpn-service-openvpn-helper.c
+++ b/src/nm-openvpn-service-openvpn-helper.c
@@ -40,6 +40,7 @@
 #include <dbus/dbus-glib-lowlevel.h>
 #include <dbus/dbus-glib.h>
 #include <NetworkManager.h>
+#include <netdb.h>
 
 #include "nm-openvpn-service.h"
 #include "nm-utils.h"
@@ -288,6 +289,7 @@ main (int argc, char *argv[])
 	GValue *dns_domain = NULL;
 	struct in_addr temp_addr;
 	gboolean tapdev = FALSE;
+	struct hostent *tmp_he;
 
 	g_type_init ();
 
@@ -300,7 +302,18 @@ main (int argc, char *argv[])
 	config = g_hash_table_new (g_str_hash, g_str_equal);
 
 	/* External world-visible VPN gateway */
-	val = addr_to_gvalue (getenv ("trusted_ip"));
+	val = NULL;
+	tmp = getenv ("trusted_ip");
+	if (!tmp)
+		tmp = getenv ("remote_1");
+	if (tmp) {
+		if (inet_aton (tmp, &temp_addr) == 0) {
+			tmp_he = gethostbyname (tmp);
+			if (tmp_he != NULL)
+				val = uint_to_gvalue (((struct in_addr *) (tmp_he->h_addr_list[0]))->s_addr);
+		} else
+			val = addr_to_gvalue(tmp);
+	}
 	if (val)
 		g_hash_table_insert (config, NM_VPN_PLUGIN_IP4_CONFIG_EXT_GATEWAY, val);
 	else
