diff --git a/etc/inc/captiveportal.inc b/etc/inc/captiveportal.inc index 2e26566bdf..e1d80e0ccb 100644 --- a/etc/inc/captiveportal.inc +++ b/etc/inc/captiveportal.inc @@ -1571,6 +1571,14 @@ function portal_ip_from_client_ip($cliip) { return $ip; } + $iface = exec_command("/sbin/route -n get {$cliip} | /usr/bin/awk '/interface/ { print \$2; };'"); + $iface = trim($iface, "\n"); + if (!empty($iface)) { + $ip = find_interface_ip($iface); + if (is_ipaddr($ip)) + return $ip; + } + // doesn't match up to any particular interface // so let's set the portal IP to what PHP says // the server IP issuing the request is.