From f86fa91cf94ed2d49df1e41ffbdf2f235fba5163 Mon Sep 17 00:00:00 2001 From: jim-p Date: Thu, 22 Dec 2011 10:03:49 -0500 Subject: [PATCH] Take routing table into account when figuring out which IP address to use for talking to CP clients. --- etc/inc/captiveportal.inc | 8 ++++++++ 1 file changed, 8 insertions(+) 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.