diff --git a/lib/OperatingSystems/DefaultOs.php b/lib/OperatingSystems/DefaultOs.php index 2d331fab..c313e01e 100644 --- a/lib/OperatingSystems/DefaultOs.php +++ b/lib/OperatingSystems/DefaultOs.php @@ -137,8 +137,10 @@ public function getNetworkInfo(): array { $result['hostname'] = \gethostname(); $dns = shell_exec('cat /etc/resolv.conf |grep -i \'^nameserver\'|head -n1|cut -d \' \' -f2'); $result['dns'] = $dns; - $gw = shell_exec('ip route | awk \'/default/ { print $3 }\''); - $result['gateway'] = $gw; + $ip_route = $this->executeCommand('ip route'); + preg_match_all("/^default.*\bvia ([[:xdigit:].:]+)\b/m", $ip_route, $matches); + $allgateways = implode(' ', $matches[1]); + $result['gateway'] = $allgateways; return $result; } diff --git a/lib/OperatingSystems/FreeBSD.php b/lib/OperatingSystems/FreeBSD.php index 1651e82e..3ca24f72 100644 --- a/lib/OperatingSystems/FreeBSD.php +++ b/lib/OperatingSystems/FreeBSD.php @@ -136,8 +136,9 @@ public function getNetworkInfo(): array { $alldns = implode(' ', $matches[0]); $result['dns'] = $alldns; $netstat = $this->executeCommand('netstat -rn'); - preg_match("/(?<=^default).*\b\d/m", $netstat, $gw); - $result['gateway'] = $gw[0]; + preg_match_all("/^default\s+([[:xdigit:].:]+)\b/m", $netstat, $matches); + $allgateways = implode(' ', $matches[1]); + $result['gateway'] = $allgateways; } catch (\RuntimeException $e) { return $result; }