diff --git a/etc/inc/captiveportal.inc b/etc/inc/captiveportal.inc
index 774d2af44eaef13cf9530f7c7ec25f5692ad4871..51085bad529c5e8d87ed44a8fa780aa3f38f9d08 100644
--- a/etc/inc/captiveportal.inc
+++ b/etc/inc/captiveportal.inc
@@ -2195,7 +2195,7 @@ function portal_ip_from_client_ip($cliip) {
 		}
 	}
 
-	$route = route_get($cliip);
+	$route = route_get($cliip, 'inet', true);
 	if (empty($route)) {
 		return false;
 	}
diff --git a/etc/inc/util.inc b/etc/inc/util.inc
index bc5178dee615b7f7a6a041e835cd7a358db68fef..f994d0834105b3271225bd65bdaa422245fe49b7 100644
--- a/etc/inc/util.inc
+++ b/etc/inc/util.inc
@@ -2685,6 +2685,10 @@ function route_get($target, $ipprotocol = '', $useroute = false) {
 			}
 		} else {
 			$gateway = exec("/sbin/route -n{$inet} get {$target} | /usr/bin/awk '/gateway:/{print $2}'");
+			if (!$gateway) {
+				// non-local gateway
+				$gateway = get_interface_mac($interface);
+			}
 		}
 		$result[] = array('gateway' => $gateway, 'interface-name' => $interface);
 	} else {
@@ -2738,7 +2742,7 @@ function route_del($target, $ipprotocol = '') {
 		return false;
 	}
 
-	$route = route_get($target, $ipprotocol);
+	$route = route_get($target, $ipprotocol, true);
 
 	if (empty($route)) {
 		return;
diff --git a/usr/local/www/system_routes_edit.php b/usr/local/www/system_routes_edit.php
index 43232a6dfe028ba75f59f3ffe40fd251b15ecdf4..d5c52747790ff2902b152938d1a451ebd6e02ddb 100644
--- a/usr/local/www/system_routes_edit.php
+++ b/usr/local/www/system_routes_edit.php
@@ -200,7 +200,7 @@ if ($_POST['save']) {
 					if (is_ipaddrv6($dts)) {
 						$family = "-inet6";
 					}
-					$route = route_get($dts);
+					$route = route_get($dts, '', true);
 					if (!count($route)) {
 						continue;
 					}
